6

I am using glossaries package in my document and I have some long term names. This breaks my layout. I tried to apply:

\setlength{\glspagelistwidth}{0.3\linewidth}

And it did not work at all. If I use:

\setlength{\glsdescwidth}{0.3\linewidth}

it will work on the description side, but I need the term side to have its width reduced not the description one. If I use:

\setlength{\glsdescwidth}{0.7\linewidth}

it will not give me the expected result either.

How can I fix this?

The minimum working example I could get (I tried to be the closest possible to my situation):

\documentclass{book}

\usepackage{lipsum}

\usepackage[utf8]{inputenc}

\usepackage[acronym]{glossaries}

\renewcommand*{\glossaryentrynumbers}[1]{}

\newcommand{\dictentry}[2]{%
  \newglossaryentry{#1}{name={#1},description={#2}}%
  \glsadd{#1}%
}
\newcommand{\dictentryspec}[3]{%
  \newglossaryentry{#1}{name={#2},description={#3},sort={#1}}%
  \glsadd{#1}%
}
\newcommand{\acronentry}[2]{%
  \newglossaryentry{acro#1}{type=\acronymtype, name={#1},description={#2}, first={#2 (#1)}}%
  \glsadd{acro#1}%
}



\makeglossaries

\setlength{\glsdescwidth}{\dimexpr\linewidth-10\tabcolsep}
\renewcommand{\glsnamefont}[1]{\textbf{#1}}
\glstoctrue

\newglossarystyle{clong}{%
\glossarystyle{long}
\renewcommand{\glsgroupskip}{}
}
\begin{document}
My document.

\acronentry{AD}{Sample 1}
\dictentry{really long or long long long long term 1}{\lipsum[1]}
\dictentryspec{really long or long long long long term 2 in place}{used when I have é or â in glossaries}{\lipsum[1]}

\cleardoublepage
\renewcommand*{\arraystretch}{1.5}
\setlength{\glspagelistwidth}{0.3\linewidth}
\printglossary[type=\acronymtype,style=clong]
\cleardoublepage
\printglossary[type=main,style=clong]
\cleardoublepage
\end{document}
3
  • 2
    What glossary style do you use? (A minimal working example would be even better.)
    – lockstep
    Jun 26 '11 at 23:10
  • @lockstep I'm using long list style. I will try to make a minimal working example.
    – Weslei
    Jun 26 '11 at 23:13
  • @lockstep I updated the question with an example that reflects my case.
    – Weslei
    Jun 26 '11 at 23:28
9

You are using the style long which is defined within the glossary-long.sty file (can be found in the glossaries folder in /tex/latex/glossaries)

It defines the style (partly) as

\newglossarystyle{long}{%
  \renewenvironment{theglossary}%
     {\begin{longtable}{lp{\glsdescwidth}}}%
     {\end{longtable}}%
  \renewcommand*{\glossaryheader}{}%
.
.
.

As you can see, indeed the description width is a p column with width \glsdescwidth but the first column is a simple l column.

It is easy to define a new style by simply copying the definition and creating your own style (you already did this basically to remove the group skip, this is just an extension). This should do the trick

\documentclass{article}

\usepackage[nomain,acronym]{glossaries}
\makeglossaries


\newglossarystyle{clong}{%
 \renewenvironment{theglossary}%
     {\begin{longtable}{p{.3\linewidth}p{\glsdescwidth}}}%
     {\end{longtable}}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glstarget{##1}{##2} & ##3\glspostdescription\space ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     & \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}%
  %\renewcommand*{\glsgroupskip}{ & \\}%
}

\usepackage{lipsum}
\newacronym{test}{Some very very long text that just wont break}{\lipsum[1]}

\begin{document}
\glsaddall
\printglossary[type=\acronymtype,style=clong]

\end{document}

Printing the glossay twice, one with long and the second time with the redefined clong style gives

enter image description here

5
  • Thanks for your answer, but it did not work :-( I need to shorten the term side, and after replacing my style with yours it still won't work.
    – Weslei
    Jun 26 '11 at 23:50
  • sorry I forgot to actually change the column type. The above definition will work
    – Martin H
    Jun 26 '11 at 23:53
  • Now it worked perfectly! Thank you very much!
    – Weslei
    Jun 26 '11 at 23:58
  • Hi, I had a problem with your solution. If you can, please take a look at the question
    – Weslei
    Jul 17 '11 at 21:03
  • I solved the issue using @egreg solution to the other question. I think you should fix your answer in the commented line.
    – Weslei
    Jul 17 '11 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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