[Tex/LaTex] \BeforeBeginEnvironment not doing anything

environmentsetoolboxglossariesmulticol

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?

Best Answer

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