增加词汇表中描述宽度和数字列表宽度以匹配目录

增加词汇表中描述宽度和数字列表宽度以匹配目录

我希望通过(底部)创建的词汇表glossaries与目录(顶部)的宽度相同。我希望词汇表中的数字与点和描述文本之间的间距与目录中的间距相等。

比较

我觉得通过修改描述宽度可以部分实现这一点\glsdescwidth

这是一个最小的工作示例:

\documentclass{report}

\usepackage{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}

\usepackage[toc]{glossaries}
\makeglossaries
\renewcommand*\glspostdescription{\cftdotfill{\cftsecdotsep}}

\begin{document}

\tableofcontents

\newglossaryentry{K}{name={kind of long name},description={King of long description}}

\newglossaryentry{S}{name={some long name},description={Super super super super super super super super super super super super super super super super super long description}}

\printglossary[style=long]

\chapter{Chap 1}

\gls{K}

\gls{S}

\end{document}

要编译该示例,您必须makeglossaries在调用之间使用latex

答案1

也许可以开始这样做?只要词汇表中的条目页码不是太多,这种方法至少是有效的:

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{report}

\usepackage{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}

\usepackage[toc]{glossaries}
\makeglossaries

% tabular goodies:
\usepackage{array}

% a bigger glossary description width:
\setlength\glsdescwidth{.7\textwidth}

% adapt `long' glossarystyle
\newglossarystyle{mylong}{%
  \glossarystyle{long}% base this style on the `long' style
  % no indent before the longtable:
  \setlength\LTleft{0pt}%
  % the following relies on the `tocloft' package being loaded;
  % formatting of page numbers:
  \renewcommand\cftchappagefont{}%
  % renew the table: both columns together now have \textwidth:
  \renewenvironment{theglossary}%
    {%
      \begin{longtable}
        {
          @{}>{\raggedright}
            p{\dimexpr\textwidth-\glsdescwidth-2\tabcolsep\relax}
          p{\glsdescwidth}
          @{}
        }
    }%
    {\end{longtable}}%
  % the entry is formatted with \cftchapfilnum instead of
  % \glspostdescription:
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} &
    ##3%\glspostdescription
    \cftchapfillnum{##5}\\
  }%
}

% show page dimensions:
\usepackage{showframe}

\begin{document}

\tableofcontents

\newglossaryentry{K}{
  name={kind of long name},
  description={King of long description}}

\newglossaryentry{S}{
  name={some long name},
  description={Super super super super super super super super super super
    super super super super super super super long description}}

{\let\clearpage\relax% never do this! only for demonstration purposes!
\printglossary[style=mylong]
}

\chapter{Chap 1}

\gls{K} \gls{S}

\end{document}

在此处输入图片描述

相关内容