I would like my formula index to look more like my tabular index.

tabular index

But at the moment it still looks like this. Without clamps. Besides, it's too far out of the frame on the right (showframe=true ist activated).

formula index

The sorting should also be sorted according to usage. I am trying to get this layout:

(1) T=XXX looooongergap haptische Transparenz .......................12
(2) Y=XXX looooongergap Admittanz mechanische.......................23

My Code MWE

\newacronym{MIC}{MIC}{Microsoft oder so} 
\newacronym{MIC2}{MIC2}{Microsoft oder so} 
description={Ein Winkel}, 
sort=symbolphi, type=symbolslist 



%\newglossary{eqlg}{formula}{eqnd}{eqx}{Formelverzeichnis}[equation] %doesnt work

\renewcommand*{\theequation}{\if@mainmatter \thechapter.\fi\arabic{equation}} 

\usepackage{chngcntr}            %coun­ter­within  and counterwithout 


\printglossary[title=Abkürzungsverzeichnis, type=\acronymtype] 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\printglossary[type=formula,nonumberlist=false, style=long3col] %  alternative long4col
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Test text davor mit \gls{MIC2} \gls{MIC} und \gls{symb:Phi} 
und text danach 


I hope my information will help you help me. Thanks

EDIT1: I have tried it with sort=1 unfortunately this also doesn't work

  • A comment on the problem of solving this problem would also be nice. Or an alternative
    – protter
    Jul 9, 2019 at 11:09

1 Answer 1


Here goes an attempt at recreating what you are asking:

%!TEX TS-program = lualatex
    % \usepackage[ngerman]{babel}% Uncomment to see German version
    \usepackage{tabu}% For our custom style using longtabu env.
    % \usepackage{showframe}
    \usepackage[super]{nth}% Superscript 1st, 2nd, ...

% Write some .bib files.
% These need to be processed with
% bib2gls <base filename>
% which writes them to *.glstex files, to be read by this document.
% \GlsXtrLoadResources tells glossaries-extra where to find the files.

    description={An angle},

    description={Some other, less important formula},
    description={A formula},
    description={The last, not important formula},

    symbols,% Initializes type 'symbols' etc. automatically
    record,% Required for bib2gls

\newglossary*{formulae}{Formulae}[equation]% Starred variant automates things

% Add custom key for a 'unit' field for symbols:

    sort=use,% Sort by order of use
    category={same as type},% Required for \glssetcategoryattribute
    % sort-field=description,% Sort by description field

% Create aliases to save typing.
% \sym is like \gls{sym.}, but allows mods like \gls+{}[<after>]

% indexonlyfirst can also be a package option, for all glossaries
% Index only on first use for certain categories, as set manually above.
% https://tex.stackexchange.com/a/318886/120853

% Modify name displayed for groups (default is to print group name verbatim, in this case 'greek' instead of 'Greek')

\RequirePackage{glossary-longextra} % Long, elaborate base style, providing e.g. 'long3col' for the abbreviations etc.

\newcommand*{\glshdrfont}[1]{\textbf{#1}} % Font for gls table heads

\newglossarystyle{symbunitlong}{% https://tex.stackexchange.com/a/269571/120853
    \setglossarystyle{long-name-desc-loc} % Base new style on existing one. This is quite important, since it implements all otherwise missing but maybe required commands, like \glsgroupskip if --group option is used for bib2gls

    \renewcommand*{\glossaryheader}{}% Remove it

    {\begin{longtabu}{rp{0.5\linewidth}p{\glspagelistwidth}l}} % Use Longtabu over longtable, the latter caused inexplicable issues with 'Column widths have changed, rerun Latex'


        \glshdrfont{\glsgetgrouptitle{##1}} & \glshdrfont{\descriptionname} & \glshdrfont{\pagelistname} & \glshdrfont{Unit}\tabularnewline

        \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
        \glossentrydesc{##1}\glspostdescription & ##2 & \glsentryunit{##1}\tabularnewline
    } % Use glsentryuseri to access entry, not glsuseri: https://tex.stackexchange.com/a/281772/120853

\newglossarystyle{formulaelong}{% https://tex.stackexchange.com/a/269571/120853
    \setglossarystyle{long-name-desc-loc} % Base new style on existing one. This is quite important, since it implements all otherwise missing but maybe required commands, like \glsgroupskip if --group option is used for bib2gls

    \renewcommand*{\glossaryheader}{}% Remove it

    {\begin{longtabu}{lp{0.4\linewidth}l}} % Use Longtabu over longtable, the latter caused inexplicable issues with 'Column widths have changed, rerun Latex'

    % Renew \glossaryheader to something empty is this is not wanted:
        \glshdrfont{Formula} & \glshdrfont{\descriptionname} & \glshdrfont{\nth{1} Use} \tabularnewline

        \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
        \glossentrydesc{##1}\glspostdescription\dotfill & (##2) \tabularnewline
    } % Use glsentryuseri to access entry, not glsuseri: https://tex.stackexchange.com/a/281772/120853


\addchap{Glossaries}% addchap from KOMA script
\setglossarysection{section}% In book/report, knock down one level to sections
\printunsrtglossary[type=formulae, style=formulaelong]

Text before, with \abb{microsoft}, \abb{apple} and \sym{angle}!
Text after.
Using the first again.
We index only the first, so it won't show up in the glossary:

So perhaps a couple of notes on that. Because it is more modern and powerful, I compiled with lualatex and am telling whatever IDE is in use that intent via the magic comment %!TEX TS-program = lualatex.

I switched the entire process over to use bib2gls, mainly because that is what I am comfortable with. The main difference is that glossary entries of all sorts now reside in their own *.bib files, with entry formats much like the ones found in conventional bibliography files. This should be self-explanatory.

If we load glossaries-extra, we do not have to load glossaries. Further, in loading with the package options abbreviations, symbols and index, these glossaries and types are automatically initiated and provided. This gives access to commands like \printunsrtsymbols.

The glossaries are now printed 'unsorted', because the sorting is done by bib2gls, an external Java-tool that you should already have in your LaTeX distribution. So now, the compilation process has one more step and goes

lualatex <filename>
biblatex --group <filename>
lualatex <filename>

After that, appropriate *.glstex files should reside in the correct place and act as auxiliary files. The --group option is important here to get Greek (and later probably Roman) symbols sorted properly.

We tell our document/glossaries-extra where to look for the *.bib files by invoking \GlsXtrLoadResources. Only in its options should entries like group or type go. If you say e.g. group=greek within the bib-file already, you get a warning because such a field is considered 'internal' by bib2gls. Within the \GlsXtrLoadResources options, the key key (...) for your intents is sort=use, which sorts the entries by first use in the document. If you do not provide this, I am pretty sure the default of bib2gls is to sort by order of occurrence in the bib-file, which is different (on purpose ) from the order of use in our example.

Since the glossary type symbols was already automatically generated, no need to do that anymore. We only need to create, using newglossary*, the non-standard 'Formulae' glossary.

You were using an entry name of symb:Phi. Some thoughts on that:

  • the entry name itself should not contain a prefix like symb: or in my case sym.. It would lead to a lot of repetition. Instead, this is abstracted away into the label-prefix option for GlsXtrLoadResources
  • Since we are using a glossary at all in order to elevate the symbol declarations, it does not make sense to then label the entries by their symbol name, like Phi for a \varphi symbol. Like always in LaTeX, write what you mean, not what just looks right. In this case, we mean to type the symbol for an angle. That can be any symbol, but \varphi just happens to represent it in that moment. In that vein, the entry label should reflect the entry's meaning, so in this case it is angle.
  • same idea applies to abbreviations; if the abbreviation's label is something like MIC already, we lose the meaning and run into the danger of running out of labels, general confusion. Also, source code readability will suffer a bit. A sentence like The angle is \sym{angle}. is quite easy to read still, with perfectly clear meaning, allowing us to spot mistakes easily. Note that you can also issue \glsdesc to print the description field of angle.

If we issue indexonlyfirst, we can do so for an entire category. First, we need to assign a category to the entries we just loaded by issuing the category key with value same as type. Then, we can call \glssetcategoryattribute to index only the first occurrence of entries of the category. Only these are then referenced in the page list (the page list is denoted by ##2 in the style declarations).

Symbols also generally have units. While glossaries-extra has the excellent capability to assign values to the user1 etc. fields, we should, since we are so certain about our intents, issue a wholly new field using \glsaddkey{unit}....

As a base style, we use glossaries-longextra. However, we do not use it directly but define our own styles derived from long-name-desc-loc, because that happens to roughly resemble what we are after already.

One key feature here is probably usage of \dotfill in the table cells, filling the horizontal space up to the page list with dots, like in the List of Tables etc.

Also, assign some alias commands that also allow for the modifications that are possible with the base \gls commands, e.g. \gls{}[<append>]. These save us the trouble of having to repeat the label-prefix at every \gls{} call.

Note how due to commands like \descriptionname, the document is largely language agnostic and can easily accept German language as well, by using babel, or in case of lualatex rather polyglossia.

Lastly, you asked for a layout like

(1) T=XXX looooongergap haptische Transparenz .......................12

(2) Y=XXX looooongergap Admittanz mechanische.......................23


While the page list, or in this case the page of first occurrence of the formula, is now intact, you seem to want the equation number in the left-most column?

I admit, I have no idea where to even start on that. glossaries/glossaries-extra is extremely good at indexing via the page numbers, and it comes naturally and is easy enough to implement and modify. Since that already provides a rather distinct, unambiguous reference, adding a second reference in the form of the equation number seems redundant. If you just wanted a numbered list on the left that starts from (1) and simply counts up in integers, I would consider that redundant and better left out, too.

If you want to replace the page number in the right-most column with the Equation label of first use, that might be a decent idea. Still, I would have no idea how to achieve that at all. It would also be very prone to breakage, since nothing keeps use from issuing \formula{<label>} outside of the equation environment. Or what if we happen to be inside equation*?

glossaries extra symbols page 1

glossaries extra symbols page 2

glossaries extra symbols page 3

Edit 1

Based on your comment, I revisited the situation and as it turns out, glossaries remains brilliant and despite what I thought, offers simple embedding of arbitrary counters via \newglossary*{formulae}{Formulae}[equation], i.e. the trailing optional argument. This now turns the number list from a page list to the equation number list, and the glossary prints:

glossary with equation numbers as number list

Edit 2

As per your most recent comment, the equation number is now also in parentheses. Maybe look into mathtools and \newtagform if you want to use brackets etc. The key here is to enclose the number list, (##2).

equation number list in glossaries with parentheses

  • 1
    Thank you very much. \newglossary*{label}{title}[equation] should do the magic.
    – protter
    Jul 17, 2019 at 8:46
  • Is there a possibility to ad "something" here to get the formula number in brackets all the way to the front? \renewcommand*{\glossentry}[2]{% \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & \glossentrydesc{##1}\glspostdescription\dotfill & ##2 \tabularnewline }
    – protter
    Jul 17, 2019 at 8:47
  • 1
    To have a complete answer, I edited based on your two comments, implementing the parentheses manually.
    – Alex Povel
    Jul 17, 2019 at 8:59
  • thank you very much for editing the article. Now it looks like I want it to be. Now I just have to add it to my main document :D
    – protter
    Jul 17, 2019 at 11:16

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.