4

I'm attempting to do something similar to Two column glossary, making an extant glossary style wrap into multiple columns. I've followed the suggestion in the comment to the first answer, i.e. use etoolbox to put the theglossary environment inside \multicols. The problem is, only the \AfterEndEnvironment seems to be doing anything. This code:

\documentclass{article}
\usepackage{glossaries}
    \setacronymstyle{long-sc-short}
\newacronym{acr}{acr}{Acronym}
\makeglossaries
\newglossarystyle{twocollong}{
    \glossarystyle{long}
    \BeforeBeginEnvironment{thegl‌​ossary}{\begin{multicols}{2}}
    \AfterEndEnvironment{theglossary}{\end{multicols}}
    }
\begin{document}
Text text 
\acrshort{acr} 
text text

\printglossary[style=twocollong]

\end{document}

gives me the error that '\begin{document} is ended by \end{multicols}'. Commenting out only the \AfterEndEnvironment line (and leaving in \BeforeBeginEnvironment) gives me a working document - no errors about \begin{multicols} being ended by \end{document}. It seems as if \BeforeBeginEnvironment isn't inserting anything at all.

What am I doing wrong here?

5
  • You have two invisible characters between thegl and ossary in the argument to \BeforeBeginEnvironment. In any case this won't work, because the long glossary style uses longtable that can't be used in a multicols environment.
    – egreg
    Apr 30, 2014 at 16:12
  • ...now I'm getting an 'environment \multicols undefined' error, even using list instead of long.
    – Sjiveru
    Apr 30, 2014 at 16:38
  • Of course you need \usepackage{multicol}.
    – egreg
    Apr 30, 2014 at 16:41
  • Why not just use one of the styles defined in glossary-mcols.sty described in the Multicols Style section of the user manual? Apr 30, 2014 at 16:44
  • Those don't quite look like what I'm wanting, since I want the definitions in a separate column. I may have no choice, though, if I can't wrap long. (I don
    – Sjiveru
    Apr 30, 2014 at 16:54

1 Answer 1

5

The following defines a new glossary style based on mcoltree that produces a tabular-like appearance:

\documentclass{article}

\usepackage{glossaries}
\usepackage{glossary-mcols}

\makeglossaries

\newlength\acrwidth

\appto\newacronymhook{%
  \settowidth{\acrwidth}{\textsc{\the\glsshorttok}}%
  \addtolength{\acrwidth}{1em}%
  \ifdim\acrwidth>\glstreeindent
    \setlength{\glstreeindent}{\acrwidth}%
  \fi
}

\setacronymstyle{long-sc-short}

\newacronym{acr}{acr}{Acronym}
\newacronym{acr2}{acr2}{Acronym2}
\newacronym{acr3}{acr3}{Acronym3}
\newacronym{acr4}{acr4}{Acronym4}
\newacronym{acr5}{acr5}{Acronym5}
\newacronym{acr6}{acr6}{Acronym6}
\newacronym{acr7}{acr7}{Acronym7}
\newacronym{acr8}{acr8}{Acronym8}
\newacronym{acr9}{acr9}{Acronym9}
\newacronym{acr10}{acr10}{Acronym10}

\newglossarystyle{mystyle}{%
  \setglossarystyle{mcoltree}%
  \renewcommand{\glossentry}[2]{%
    \hangindent\glstreeindent\relax
    \parindent0pt\relax
    \makebox[\glstreeindent][l]{%
       \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}%
    \glossentrydesc{##1}\glspostdescription\space##2\par
  }%
}

\begin{document}

Text text 
text text
\glsaddall

\printglossary[style=mystyle]

\end{document}

Result:

Image of resulting glossary

1
  • This is exactly what I was wanting! Thank you!
    – Sjiveru
    Apr 30, 2014 at 20:58

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.