2

As a follow-up to this answer, replacing \makeglossaries and \printglossary with \makenoidxglossaries and \printnoidxglossary results in a white page without printed glossaries. What is missing here?

\documentclass{scrbook}                           % documentclass: scrbook
\usepackage{siunitx}
\usepackage[acronym,toc]{glossaries}              % use glossaries-package


\setlength{\glsdescwidth}{15cm}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist


\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\makenoidxglossaries                                   % activate glossaries-package


% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
    \newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
        description={Geometrical value},
        unit={},
        type=symbolslist}

    \newglossaryentry{height}{name=\ensuremath{h},
        description={Height of tower},
        unit={\si{m}},
        type=symbolslist}

    \newglossaryentry{energyconsump}{name=\ensuremath{P},
        description={Energy consumption},
        unit={\si{kW}},
        type=symbolslist}




% ==== EXEMPLARY ENTRY FOR ACRONYMS LIST ========================================
    \newacronym{VRBD}{VRBD}{Violet-Red-Bile-Glucose-Agar}


% ==== EXEMPLARY ENTRY FOR MAIN GLOSSARY ========================================
    \newglossaryentry{Biofouling}{name=Biofouling,description={Some description}}


\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
  \begin{longtable}{lp{0.6\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
  {\end{longtable}}%
%
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Sign & \bfseries Description & \bfseries Unit \\
  \hline
  \endhead}
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1}  \tabularnewline
}
}


\begin{document}

    \glsaddall

    \printnoidxglossary[type=\acronymtype,style=long]  % list of acronyms
    \printnoidxglossary[type=symbolslist,style=symbunitlong]   % list of symbols
    \printnoidxglossary[type=main]                     % main glossary

\end{document}
  • 1
    You need a sort value for all your symbols or use sort=use or sort=def in the symbols list. (I don't recommend switching to \makenoidxglossaries. Is there a particular reason for it?) – Nicola Talbot Sep 5 '17 at 15:58
  • @NicolaTalbot there is no particular reason, but I just want to keep using \makenoidxglossaries since I already have been using it from the beginning. – Diaa Sep 5 '17 at 16:01
3

The glossaries package provides three ways of sorting and collating the glossary information: using TeX (option 1), using makeindex (option 2) or using xindy (option 3). The extension package glossaries-extra provides a fourth option (bib2gls).

These methods sort according to the value of the sort field. In your example, you haven't used the sort key in any of your definitions, so the value of the sort field has to be determined programmatically, but this varies according to the sorting option.

In the case of makeindex or xindy (\makeglossaries), the sort value is obtained by copying the name value and then sanitizing it. This means that, for example, where you have

name=\ensuremath{P}

the sort field becomes the sequence of characters \ e n s u r e m a t h { P } so when the information is written to the external file read by makeindex / xindy no expansion occurs.

When using TeX to sort (\makenoidxglossaries) the sanitization is switched off. This method uses a very primitive comparison and is designed just for words not symbols. Now when the sort field is constructed, the value is copied over from the name, but it expands as the field value is set. Before this expansion occurs, standard diacritic commands (such as \") are temporarily redefined to effectively strip accents to allow for a simple ASCII comparison.

For example, if you have

name = {\'{e}lite}

then

  • with makeindex the sort value is the sequence of characters \ ' { e } l i t e which makeindex will put in the "Symbols" letter group (since it starts with a backslash), not in the more intuitively obvious "E" letter group;
  • with xindy the sort value is written to the file as \'{e}lite but xindy is intelligent enough to strip commands and braces, so the sort value effectively becomes elite;
  • with TeX the sort value loses the accent commands during the expansion that occurs when the sort field is set, so the sort value becomes elite.

The \makenoidxglossaries method isn't suitable for sorting symbols (such as \ensuremath{P}) when the default word-ordering setting is on because of this expansion. The other methods aren't particularly suitable for sorting symbols using word order either: makeindex is the most tolerant (but the resulting order may look strange); xindy will fail on symbols like \ensuremath{\pi}.

If you have entries that represent symbols rather than words then you need to explicitly set the sort value, for example:

\newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
    sort={pi},
    description={Geometrical value},
    unit={},
    type=symbolslist}

or use a different sorting rule or sanitize the sort value (using the sanitizesort package option).

The glossaries-extra package, when used with the symbols package option, provides \glsxtrnewsymbol which automatically sets the sort to the label (which can't have special characters anyway). The symbols package option automatically creates a glossary with the label symbols, so

\glsxtrnewsymbol[description={Geometrical value},
    unit={},
    type=symbolslist]{symb:Pi}{name=\ensuremath{\pi}}

is equivalent to

\newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
    sort={symb:Pi},
    type={symbols},
    category={symbol},
    description={Geometrical value},
    unit={}}

(The category key is only available with the extension package.)

If you really want to use \makenoidxglossaries (although I don't recommend it, as it's much slower), here are your possible options:

  1. Explicitly use the sort key when defining the symbols:

    \documentclass{scrbook}
    \usepackage{siunitx}
    \usepackage[acronym,toc]{glossaries}
    
    \newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist}
    
    \makenoidxglossaries % use TeX to sort
    
    \newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
      sort={pi},
      description={Geometrical value},
      type=symbolslist}
    
    \newglossaryentry{height}{name=\ensuremath{h},
      sort={h},
      description={Height of tower},
      type=symbolslist}
    
    \newacronym{VRBD}{VRBD}{Violet-Red-Bile-Glucose-Agar}
    
    \newglossaryentry{Biofouling}{name=Biofouling,description={Some description}}
    
    \begin{document}
    
    \glsaddall
    
    \printnoidxglossary[type=\acronymtype]
    \printnoidxglossary[type=symbolslist]
    \printnoidxglossary[type=main]
    
    \end{document}
    
  2. Use the sanitizesort package option.

    \documentclass{scrbook}
    \usepackage{siunitx}
    \usepackage[acronym,toc,sanitizesort]{glossaries}
    
    \newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist}
    
    \makenoidxglossaries % use TeX to sort
    
    \newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
      description={Geometrical value},
      type=symbolslist}
    
    \newglossaryentry{height}{name=\ensuremath{h},
      description={Height of tower},
      type=symbolslist}
    
    \newacronym{VRBD}{VRBD}{Violet-Red-Bile-Glucose-Agar}
    
    \newglossaryentry{Biofouling}{name=Biofouling,description={Some
    description}}
    
    \begin{document}
    
    \glsaddall
    
    \printnoidxglossary[type=\acronymtype]
    \printnoidxglossary[type=symbolslist]
    \printnoidxglossary[type=main]
    
    \end{document}
    
  3. Change the sort rule to either def or use for the symbols. This method is faster as no actual sorting occurs with this rule. (The main and acronyms glossaries will still be sorted.)

    \documentclass{scrbook}
    \usepackage{siunitx}
    \usepackage[acronym,toc]{glossaries}
    
    \newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist}
    
    \makenoidxglossaries % use TeX to sort
    
    \newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
      description={Geometrical value},
      type=symbolslist}
    
    \newglossaryentry{height}{name=\ensuremath{h},
      description={Height of tower},
      type=symbolslist}
    
    \newacronym{VRBD}{VRBD}{Violet-Red-Bile-Glucose-Agar}
    
    \newglossaryentry{Biofouling}{name=Biofouling,description={Some description}}
    
    \begin{document}
    
    \glsaddall
    
    \printnoidxglossary[type=\acronymtype]
    \printnoidxglossary[type=symbolslist,sort=use]
    \printnoidxglossary[type=main]
    
    \end{document}
    
  4. Use \glsxtrnewsymbol with the glossaries-extra package (or provide a similar command). Note that switching to glossaries-extra requires the abbreviation style to be set for the acronyms to long-short if you want to replicate the style used in the above.

    \documentclass{scrbook}
    \usepackage{siunitx}
    \usepackage[acronym,symbols]{glossaries-extra}
    
    \makenoidxglossaries % use TeX to sort
    
    \glsxtrnewsymbol
      [description={Geometrical value}]
      {symb:Pi}{\ensuremath{\pi}}
    
    \glsxtrnewsymbol
      [description={Height of tower}]
      {height}{\ensuremath{h}}
    
    \setabbreviationstyle[acronym]{long-short}
    
    \newacronym{VRBD}{VRBD}{Violet-Red-Bile-Glucose-Agar}
    
    \newglossaryentry{Biofouling}{name=Biofouling,description={Some description}}
    
    \begin{document}
    
    \glsaddall
    
    \printnoidxglossary[type=\acronymtype]
    \printnoidxglossary[type=symbols,title={Symbolslist}]
    \printnoidxglossary[type=main]
    
    \end{document}
    

For comparison, here's a bib2gls version which sorts the symbols according to the description, the abbreviations according to the short form and the regular terms according to the name:

\RequirePackage{filecontents}
\begin{filecontents*}{symbols.bib}
@symbol{symb:Pi,
  name={\ensuremath{\pi}},
  description={Geometrical value}
}

@symbol{height,
  name={\ensuremath{h}},
  description={Height of tower}
}
\end{filecontents*}

\begin{filecontents*}{abbreviations.bib}
@acronym{VRBD,
  short={VRBD},
  long={Violet-Red-Bile-Glucose-Agar}
}
\end{filecontents*}

\begin{filecontents*}{entries.bib}
@entry{Biofouling,
  name={Biofouling},
  description={Some description}
}
\end{filecontents*}

\documentclass{scrbook}

\usepackage{siunitx}
\usepackage[record,acronym,symbols]{glossaries-extra}

\GlsXtrLoadResources[
  src={symbols},% data in symbols.bib
  type=symbols,% put these entries in the 'symbols' glossary
  selection={all},% select all entries in .bib file
% sort @symbol entries by 'description' if 'sort' field missing:
  symbol-sort-fallback={description}
]

% style must be set before relevant \GlsXtrLoadResources:
\setabbreviationstyle[acronym]{long-short}

\GlsXtrLoadResources[
  src={abbreviations},% data in abbreviations.bib
  type=acronym,% put these entries in the 'acronym' glossary
  selection={all},% select all entries in .bib file
% sort @acronym entries by 'short' if 'sort' field missing:
  abbreviation-sort-fallback={short}
]

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  type=main,% put these entries in the 'main' glossary
  selection={all}% select all entries in .bib file
]

\begin{document}

\printunsrtglossaries
\end{document}

If the document is called myDoc.tex then the build process is:

pdflatex myDoc
bib2gls myDoc
pdflatex myDoc

Or if you want letter groups:

pdflatex myDoc
bib2gls -g myDoc
pdflatex myDoc

The symbols are ordered according to the description:

Symbols π Geometrical value h Height of tower

I can change this to order according to the Unicode values of h (0x0068) and π (0x03C0):

\GlsXtrLoadResources[
  src={symbols},% data in symbols.bib
  type=symbols,% put these entries in the 'symbols' glossary
  selection={all},% select all entries in .bib file
% sort @symbol entries by 'name' if 'sort' field missing:
  symbol-sort-fallback={name},
  sort=letter-nocase% case-insensitive letter sort
]

Symbols h Height of tower π Geometrical value

  • This is an encyclopedic answer which I need to go through it attentively. I highly appreciate the effort and time you took. – Diaa Sep 6 '17 at 10:54

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.