1

I want to put a longbooktabs glossary in a minipage environment, but when I do that it curiously loses the bottomrule. Is there anything I can do about that?

As Nicola Talbot commented it suffices to put a longtable in a minipage environment to recreate the issue, see the shorter MWE below.

sample mwe output

Original MWE

Don’t forget to run makeglossaries.

\documentclass{scrartcl}
\usepackage{glossaries}
\usepackage{glossary-longbooktabs}
\makeglossaries
\newglossaryentry{ex}{name={sample},description={an example}}
\begin{document}
A \gls{ex} glossary with \texttt{style=long-booktabs} has a \texttt{bottomrule}:

\printglossary[style=long-booktabs]

But if put in a minipage, the \texttt{bottomrule} vanishes:

\begin{minipage}{\linewidth}
\printglossary[style=long-booktabs]
\end{minipage}
\end{document}

Shorter MWE

\documentclass{article}
\usepackage{longtable,booktabs}
\begin{document}
\begin{minipage}{\linewidth}
  \begin{longtable}{l}
    \toprule
    Col\\
    \midrule\endhead
    \bottomrule\endfoot
    A\\
  \end{longtable}
\end{minipage}
\end{document}
1

The longtable environment is designed for spanning multiple pages, but the contents of a minipage can't be broken and that's causing interference. Since a minipage can't span multiple pages, it's best to use tabular rather than longtable inside it. (I'm assuming you only have a short glossary that can fit on a single page.)

You could define your own style that works like longtable but uses tabular instead:

\documentclass{scrartcl}
\usepackage{glossaries}
\usepackage{glossary-longbooktabs}

\newglossarystyle{tabular}{%
  \renewenvironment{theglossary}%
     {\begin{tabular}{lp{\glsdescwidth}}}%
     {\bottomrule\end{tabular}}%
  \renewcommand*{\glossaryheader}{%
    \toprule \bfseries \entryname & \bfseries
  \descriptionname\tabularnewline\midrule}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
  \renewcommand{\subglossentry}[3]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription\space
     ##3\tabularnewline
  }%
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{\glspenaltygroupskip}%
  \fi
}

\makeglossaries
\newglossaryentry{ex}{name={sample},description={an example}}

\begin{document}
A \gls{ex} glossary with \texttt{style=long-booktabs} has a \texttt{bottomrule}:

\printglossary[style=long-booktabs]

In a minipage using \texttt{tabular} instead of \texttt{longtable}:

\noindent
\begin{minipage}{\linewidth}
\printglossary[style=tabular]
\end{minipage}
\end{document}

image of glossaries

An alternative approach is to use one of the supplementary long styles defined in glossary-longextra, which is provided with the glossaries-extra package. You can switch to using tabular instead of longtable by using:

\GlsLongExtraUseTabulartrue

before the style is set. The long-name-desc style is similar to the long-booktabs style but it doesn't include the location list. Your example includes it, but if your real document has nonumberlist then this might be a convenient option:

\documentclass{scrartcl}
\usepackage[postdot]{glossaries-extra}
\usepackage{glossary-longextra}

\makeglossaries
\newglossaryentry{ex}{name={sample},description={an example}}

\begin{document}
A \gls{ex} glossary with \texttt{style=long-booktabs} has a \texttt{bottomrule}:

\printglossary[style=long-booktabs]

In a minipage using \texttt{tabular} instead of \texttt{longtable}:

\noindent
\begin{minipage}{\linewidth}
\GlsLongExtraUseTabulartrue % use before style is set
\printglossary[style=long-name-desc]
\end{minipage}
\end{document}

image of sample glossaries

The glossary-longextra styles are designed to fill the page width. If you don't want this you can redefine \glslongextraSetDescWidth to do nothing:

\documentclass{scrartcl}
\usepackage[postdot]{glossaries-extra}
\usepackage{glossary-longextra}

\makeglossaries
\newglossaryentry{ex}{name={sample},description={an example}}

\begin{document}
A \gls{ex} glossary with \texttt{style=long-booktabs} has a \texttt{bottomrule}:

\printglossary[style=long-booktabs]

In a minipage using \texttt{tabular} instead of \texttt{longtable}:

\noindent
\begin{minipage}{\linewidth}
\GlsLongExtraUseTabulartrue % use before style is set
\renewcommand{\glslongextraSetDescWidth}{}% don't adjust \glsdescwidth
\printglossary[style=long-name-desc]
\end{minipage}
\end{document}

image of glossaries

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.