Here's a possible solution. It requires xindy
rather than makeindex
. If you really don't want to use xindy
, it's possible to adjust the code, but it's more complicated.
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[counter=alignglos,xindy]{glossaries}
\newglossary[slg]{symbols}{slm}{sbl}{List of Symbols}
\GlsSetXdyMinRangeLength{0}
\makeglossaries
\newglossaryentry{sym:deg}{
type=symbols,
name={\ensuremath{\dot{D}}},
description={Prozentuale jährliche Abnahme des Wirkungsgrades},
user1={\%/a},
sort=deg
}
\newglossaryentry{sym:etadegr}{
type=symbols,
name={\ensuremath{\eta_{Deg,r}}},
description={Verbleibender Wirkungsgrad bezogen auf den
ursprünglichen Wirkungsgrad},
user1=\%,
sort=eta deg rest
}
\newglossaryentry{sym:tau}{
type=symbols,
name={\ensuremath{\tau}},
description={Lebenszyklus / Einsatzdauer des betrachteten Systems},
user1=a,
sort=tau
}
\newcommand{\items}[2]{\glstext*{#1} & #2 [\glsuseri*{#1}] \\}
\newglossarystyle{alignglos}%
{%
\renewcommand{\glsgroupskip}{}%
\renewcommand{\glossaryheader}{}%
\renewcommand{\glsgroupheading}[1]{}%
\renewenvironment{theglossary}%
{\begin{tabular}{@{}p{1cm}p{0.9\textwidth}}}%
{\end{tabular}}%
\renewcommand*{\glossaryentrynumbers}[1]{##1}%
\renewcommand*{\glsXalignglosXglsnumberformat}[2]{##2}%
\renewcommand*{\delimN}{,}%
\renewcommand*{\glossaryentryfield}[5]{%
\edef\doifinlocation{\noexpand\ifinlocation{\thealignglos}{\expandafter\striprelax##5\endstriprelax}}%
\doifinlocation
{%
\items{##1}{##3}%
}%
}%
}
\newcommand{\ifinlocation}[3]{%
\DTLifinlist{#1}{#2}{#3}{}%
}
\def\striprelax\relax#1\endstriprelax{#1}
\newcounter{alignglos}
\newenvironment{alignglos}%
{\stepcounter{alignglos}}%
{%
\printglossary[type=symbols,style=alignglos,title={}]
}
\begin{document}
\begin{alignglos}
\begin{align}
\gls{sym:deg} &= \frac{1-\gls{sym:etadegr}}{\gls{sym:tau}}
\end{align}
\end{alignglos}
\begin{alignglos}
\begin{align}
\gls{sym:tau} &= \ldots
\end{align}
\end{alignglos}
\end{document}
Edit:
Here's the code for use with makeindex
instead of xindy
:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{etoolbox}
\usepackage[counter=alignglos]{glossaries}
\newglossary[slg]{symbols}{slm}{sbl}{List of Symbols}
\makeglossaries
\newglossaryentry{sym:deg}{
type=symbols,
name={\ensuremath{\dot{D}}},
description={Prozentuale jährliche Abnahme des Wirkungsgrades},
user1={\%/a},
sort=deg
}
\newglossaryentry{sym:etadegr}{
type=symbols,
name={\ensuremath{\eta_{Deg,r}}},
description={Verbleibender Wirkungsgrad bezogen auf den
ursprünglichen Wirkungsgrad},
user1=\%,
sort=eta deg rest
}
\newglossaryentry{sym:tau}{
type=symbols,
name={\ensuremath{\tau}},
description={Lebenszyklus / Einsatzdauer des betrachteten Systems},
user1=a,
sort=tau
}
\newcommand{\items}[2]{\glstext*{#1} & #2 [\glsuseri*{#1}] \\}
% clean up the format of the location list
\newcommand{\stripentrynumbers}[1]{%
\striprelax#1\endstriprelax
}
\newglossarystyle{alignglos}%
{%
\renewcommand{\glsgroupskip}{}%
\renewcommand{\glossaryheader}{}%
\renewcommand{\glsgroupheading}[1]{}%
\renewenvironment{theglossary}%
{\begin{tabular}{@{}p{1cm}p{0.9\textwidth}}}%
{\end{tabular}}%
\renewcommand*{\glsnumberformat}[1]{##1}%
\renewcommand*{\delimR}{-}%
\renewcommand*{\delimN}{,}%
\renewcommand*{\glossaryentryfield}[5]{%
\let\glossaryentrynumbers\stripentrynumbers
\edef\doifinloclist{\noexpand\ifinloclist{\thealignglos}{##5}}%
\doifinloclist
{%
\items{##1}{##3}%
}%
}%
\renewcommand*{\glossarysubentryfield}[1]{\glossaryentryfield}%
}
\newcommand{\ifinloclist}[3]{%
\renewcommand*{\do}[1]{%
\let\dolistbreak\relax
\doifinloc{#1}{#3}##1-\relax\endrange
\dolistbreak
}%
\docsvlist{#2}%
}
\def\doifinloc#1#2#3-#4\endrange{%
\ifx\relax#4\relax
% just a number
\ifnum#1=#3\relax
#2%
\let\dolistbreak\listbreak
\fi
\else
\doifinrange{#1}{#2}#3-#4%
\fi
}
\def\doifinrange#1#2#3-#4-\relax{%
\ifnum#1=#3\relax
#2%
\let\dolistbreak\listbreak
\else
\ifnum#1=#4\relax
#2%
\let\dolistbreak\listbreak
\else
\ifnum#1>#3\relax
\ifnum#1<#4\relax
#2%
\let\dolistbreak\listbreak
\fi
\fi
\fi
\fi
}
\def\striprelax\relax\setentrycounter[]#1#2\endstriprelax{#2}
\newcounter{alignglos}
\newenvironment{alignglos}%
{\stepcounter{alignglos}}%
{%
\printglossary[type=symbols,style=alignglos,title={}]
}
\begin{document}
\begin{alignglos}
\begin{align}
\gls{sym:deg} &= \frac{1-\gls{sym:etadegr}}{\gls{sym:tau}}
\end{align}
\end{alignglos}
\begin{alignglos}
\begin{align}
\gls{sym:tau} &= \ldots
\end{align}
\end{alignglos}
\end{document}
Result for either method:

This will also work if you want to use equation
instead of align
. The code is adapted from Glossary per chapter or section. You just need to wrap your equations inside the alignglos
environment.
Notes:
- I've used
\ensuremath
instead of $
so it doesn't matter if you are in or out of math mode when you use the glossary entry
- I think
Deg
should probably be \operatorname{Deg}
or \mathrm{Deg}
(assuming it's not just D
times e
times g
).
Edit 2:
I've modified the alignglos
style so that it suppresses the group skip. I've also deferred \listbreak
to the end of \do
. If you have Perl installed, you can use the makeglossaries
script to call makeindex
or xindy
, which will skip any empty glossaries. If you have Perl and Java installed, you can just run arara
on the document and it will run all the commands listed in the % arara:
directives. When you switch to linux, you should have Perl preinstalled and probably also the Java runtime environment.
Best Answer
You can use
pgf
package for this. Instead TeX primitive\def
one need use\pgfmathsetmacro