[Tex/LaTex] glossaries: \printglossaries prints too wide

glossariesmargins

I'm using the glossaries package, and when I issue \printglossaries:

\printglossaries
\makeglossaries

the glossary is waaaaaay too wide:

ttp://i.stack.imgur.com/9Rgdw.png

My package options are

\usepackage[acronym,sort=def,
  style=long,
  nolist
]{glossaries}

Setting

\setlength{\textwidth}{4.65in}

right before the \printglossaries is promptly ignored, and I couldn't find any option in the glossaries documentation to influence the width.

When I use twoside as a scrreprt option, the effect is much more pronounced.

Any ideas why this might happen or how I would fix it?

Best Answer

[OPs answer moved from the question]

Just adjusting \glsdescwidth doesn't help, because you will have to readjust when your longest entry changes. So use a custom glossaries style instead:

\newlength{\glstargetwidth}%
\newlength{\glshspace}%

\newglossarystyle{mylong}{%
% put the glossary in the longtable environment:
\renewenvironment{theglossary}{%
\setlength{\glstargetwidth}{0.29\textwidth}%
\setlength{\glshspace}{0.02\textwidth}%
\setlength{\glsdescwidth}{0.69\textwidth}%
\setlength{\tabcolsep}{0pt}%
\setlength{\extrarowheight}{12pt}%
\begin{longtable}%
{p{\glstargetwidth} @{\hspace{\glshspace}}  p{\glsdescwidth}}}%
{\end{longtable}}%
% have nothing after \begin{theglossary}:
\renewcommand*{\glossaryheader}{}%
% have nothing between glossary groups:
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glsgroupskip}{}%
% set how each entry should appear:
\renewcommand*{\glossaryentryfield}[5]{%
\raggedright\strong{\glstarget{##1}{##2}}% the entry name
##4% the symbol 
&##3,% the description
\space ##5% the number list 
\\
}%
% set how sub-entries appear:
\renewcommand*{\glossarysubentryfield}[6]{%
\glossaryentryfield{##2}{##3}{##4}{##5}{##6}}%
}
\renewcommand*{\glstextformat}[1]{\textcolor{black}{#1}}

\glossarystyle{mylong}

This will fix the width of your entry column, breaking the entry names when necesary.