5

I am using the glossaries package to print a list of acronyms and another one with symbols at the beginning of my document. Since I want my definitions to be aligned and occupy the whole width of the text, I decided to use the long style. This, however, changes the counter for the tables in my document, since glossaries uses the longtable package internally to create its lists. Is there a way to suppress this behavior?

I would not like to use \setcounter{table}{-2} since this is a reusable template and I don't always print both lists. I was expecting to have a more elegant solution.

Here is an MWE.

\documentclass{report}
\usepackage[acronym,symbols]{glossaries}
\setglossarystyle{long}

% my custom formatting
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\glsdescwidth{\linewidth}

\newglossaryentry{a}{type=symbols,name={\ensuremath{a}},sort=a,
description={A}}
\newglossaryentry{b}{type=symbols,name={\ensuremath{b}},sort=b,
description={B}}

\newacronym{c}{C}{The letter C}

\makeglossaries

\begin{document}
\gls{a} \gls{b} \gls{c} 

\printglossaries

\begin{table}
\caption{This table should be table 1.}
\end{table}

\end{document}

1 Answer 1

3

The longtable issue of using the table counter is well-known and is not restricted to the usage of glossaries and its various long.... glossary styles.

Here is a small solution by defining a new glossarystyle based on the long style, replacing the surrounding longtable environment with longtable*, which isn't incrementing the table counter. You need the caption package for this:

\newglossarystyle{mylong}{%
    \setglossarystyle{long}% base this style on the long style
    \renewenvironment{theglossary}{%
      \begin{longtable*}{lp{\glsdescwidth}}}%
    {\end{longtable*}}%
    }

\setglossarystyle{mylong} % Set the new style

The redefinition of theglossary is based on the original version, just replacing longtable with longtable* here.


\documentclass{report}

\usepackage{caption}

\usepackage[acronym,symbols]{glossaries}


%\setglossarystyle{long}

% my custom formatting
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\glsdescwidth{\linewidth}

\newglossaryentry{a}{type=symbols,name={\ensuremath{a}},sort=a,
description={A}}
\newglossaryentry{b}{type=symbols,name={\ensuremath{b}},sort=b,
description={B}}

\newacronym{c}{C}{The letter C}

\newglossarystyle{mylong}{%
\setglossarystyle{long}% base this style on the long style
\renewenvironment{theglossary}{%
  \begin{longtable*}{lp{\glsdescwidth}}}%
{\end{longtable*}}%
}

\setglossarystyle{mylong}

\makeglossaries

\begin{document}
\listoftables
\gls{a} \gls{b} \gls{c} 

\printglossaries

\begin{table}
\caption{This table should be table 1.}
\end{table}

\end{document}

enter image description here

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.