4

For my thesis the reviewers suggested that I add a list of symbols below each equation.

Based on Multiple glossaries with different styles i came up with this:

\documentclass[12pt,twoside,booktabs,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[acronym,toc,shortcuts]{glossaries}
\usepackage{amsmath} 


\newglossary[ch1]{formel}{ch2}{ch3}{Symbols}

\makenoidxglossaries
\setacronymstyle{long-short}

\newglossarystyle{formel_altlong4colheader}{%
\setglossarystyle{altlong4colheader}%
%
\renewcommand*{\glossaryheader}{%
    \bfseries Symbol
   & \bfseries Description
   & \bfseries Unit\\
   \hline
   \\\endhead}%
 \renewcommand{\glossentry}[2]{%
 \glstarget{##1}{\glossentryname{##1}}%
 & \glossentrydesc{##1}%
 & \glossentrysymbol{##1}%
 \tabularnewline % end of row
 }%
}


\setlength{\glsdescwidth}{3in}

\include{glossar}

\newcommand{\glsfull}[1]{%
%\glstarget{#1} %don't know what this would be for.
\glossentryname{#1}\quad : \quad%
  \glossentrydesc{#1}\quad[\glossentrysymbol{#1}]
}

\newcommand{\glsfullA}[1]%
{& \glossentryname{#1} & \glossentrydesc{#1} & [\glossentrysymbol{#1}]%
}

%-----Formel---
\newglossaryentry{CDDLimit}
{%
name={$CDD_{Limit}$},
description={Cooling Degree Day Limit},
symbol={$-$},
sort=abc,
type=formel
}
\newglossaryentry{CDD}
{%
name={$CDD$},
description={Cooling Degree Day},
symbol={$\frac{W}{kg K}$},
sort=abc,
type=formel
}

\begin{document}

\printnoidxglossary[type=formel,  style=formel_altlong4colheader]

\newpage
\begin{equation}
CDD_{Limit} = Max(CDD)
\end{equation}
with \\
\glsfull{CDDLimit}\\
\glsfull{CDD}\\

This is not quite what I want. I rather would like something that alligns itself like alignat*

%\begin{alignat*}{4}
%   \text{with}\quad    \glsfullA{CDDLimit} 
%                   \glsfullA{CDD}
%\end{alignat*}
\end{document} 

If you remove the "%" from the last four lines this however gives an error.

Do you have any suggestions as to that the problem might be?

In the end would like to have whats illustrated below as well as a complete list of Symbols in the end.

What I would like.

1 Answer 1

3

Rather than typeset each glossary item separately it is more efficient to give a list of glossary keys to a macro and let the macro take care of everything. The etoolbox contains some great tools for working with "comma separated variables", such as \docsvlist, that can be used to generate a tabular environment containing your glossary items. The \docsvlist command loops over the list that it is given an executes the \do command, so to make this work you just need to redefine \do so that it generates one row of a tabular environment.

Wrapping this into a \GlsList command, you can then put \GlsList{CDDLimit,CDD} after your equation to produce

enter image description here

Here is the full MWE:

\documentclass[12pt,twoside,booktabs,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[acronym,toc,shortcuts]{glossaries}
\usepackage{amsmath}

\newglossary[ch1]{formel}{ch2}{ch3}{Symbols}

\makenoidxglossaries
\setacronymstyle{long-short}

\newglossarystyle{formel_altlong4colheader}{%
\setglossarystyle{altlong4colheader}%
%
\renewcommand*{\glossaryheader}{%
    \bfseries Symbol
   & \bfseries Description
   & \bfseries Unit\\
   \hline
   \\\endhead}%
 \renewcommand{\glossentry}[2]{%
 \glstarget{##1}{\glossentryname{##1}}%
 & \glossentrydesc{##1}%
 & \glossentrysymbol{##1}%
 \tabularnewline % end of row
 }%
}

\setlength{\glsdescwidth}{3in}

\include{glossar}

\usepackage{etoolbox}
\newcommand\GlsList[1]{% generate list of glossary entries
  \def\gswith{with}% for inserting "with" on the first line
  \renewcommand*{\do}[1]{%
     \glsadd{##1}% add glossary entry to index
     \gswith&\glossentryname{##1}:&\glossentrydesc{##1}&[\glossentrysymbol{##1}]\\%
     \global\let\gswith\relax% reset "with" for later lines
  }
  \begin{tabular}{@{}llll}
    \docsvlist{#1}
  \end{tabular}
}

%-----Formel---
\newglossaryentry{CDDLimit}
{%
name={$CDD_{Limit}$},
description={Cooling Degree Day Limit},
symbol={$-$},
sort=abc,
type=formel
}
\newglossaryentry{CDD}
{%
name={$CDD$},
description={Cooling Degree Day},
symbol={$\frac{W}{kg K}$},
sort=abc,
type=formel
}

\begin{document}

\printnoidxglossary[type=formel,  style=formel_altlong4colheader]

\begin{equation}
  CDD_{Limit} = Max(CDD)
\end{equation}
\GlsList{CDDLimit,CDD}

\end{document}

As advertised the \do command, which is defined inside \GlsList, simply writes one line of the tabular environment. The one sneaky point is the use of \gswith that adds "with" to the first line of the environment after which it is set to \relax so that it does nothing.

You will probably want to tweak the spacing of the tabular environment, and the placement of the :, but this should be straightforward.

3
  • This is very close to what I need. However is there a way to have all Glossary entries that have been used in \GlsList{a,b} show up in the final glossary printed by \printnoidxglossary?
    – MatoBehr
    Commented Nov 3, 2016 at 21:26
  • Using \glsaddall does help, is however not exactly what I want as it would add all glossary entries, not just the used ones.
    – MatoBehr
    Commented Nov 3, 2016 at 21:37
  • @MatoBehr I haven't used glossaries. I just packaged what you were doing! This said, it looks like you just need to add a \glsadd command to the \do statement. I'll edit the post. If this does not what you want then please tell me how you would add the entry "by hand".
    – user30471
    Commented Nov 3, 2016 at 22:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .