Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want my glossary created via glossaries (bottom) to have the same width as my table of contents (top). I would like the numbers in the glossary to have a large space away from the dots and description text equal to that in the table of contents.

compare

I feel that this is partly possible by modifying the description width via \glsdescwidth.

Here is a minimal working example:

\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}

To compile the example, you must use makeglossaries in between calls to latex.

share|improve this question
    
The long style uses a longtable to set the style. You need to take care that the table has an overall with of \textwidth and possibly have to set the length \LTleft to zero. The first thing should be doable by adapting the long style for a custom style, I guess –  cgnieder Jun 7 '13 at 20:01
    
I am totally fine with using some other style than long to get the desired result. –  James Rohal Jun 8 '13 at 1:39

1 Answer 1

up vote 2 down vote accepted

Maybe something along these lines is a start? This works at least as long as there aren't too many page numbers for an entry in the glossary:

% 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}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.