I am looking for a way to automatically create the legend for an equation
(let's say embedded in the align
environment).
What I'm currently using is a semi automated to fully manual way. Let me explain: The result should look like this:
.
What I am doing to accomplish this requires 3 steps to generate the output shown above:
1) Placing equation:
\begin{align}
\dot{D} = \frac{1-\eta_{Deg,r}}{\tau} \label{eq:deg}
\end{align}
2) Defining the corresponding entries in the symbol glossary:
\newglossaryentry{sym:deg}{
type=symbols,
name={$\dot{D}$},
description={Prozentuale jährliche Abnahme des Wirkungsgrades},
user1={\%/a},
sort=deg
}
\newglossaryentry{sym:etadegr}{
type=symbols,
name={$\eta_{Deg,r}$},
description={Verbleibender Wirkungsgrad bezogen auf den ursprünglichen Wirkungsgrad},
user1=\%,
sort=eta deg rest
}
\newglossaryentry{sym:tau}{
type=symbols,
name={$\tau$},
description={Lebenszyklus / Einsatzdauer des betrachteten Systems},
user1=a,
sort=tau
}
3) Custom command to fill table with glossaries reference:
%Command
\newcommand{\items}[1]{\glstext*{#1} & \glsdesc*{#1} [\glsuseri*{#1}] \\}
%Legend Environment
\begin{tabular}{@{} p{1cm} p{0.9 \textwidth}}
\items{sym:deg}
\items{sym:etadegr}
\items{sym:tau}
\end{tabular}
Question
I'd like to create a command which searches the previous align
environment for elements of my symbol glossary
and puts them into a legend (in this case tabular) environment. Does this already exist (didn't find anything)? And how would i realize this?
Not expecting a perfect solution but I have no clue how to do this.
An MWE to tinker with can be found here –> Gist
€:
-Additional Information: Using miktex 2.9 and TechniXCenter 2 on Windows.
-Matches for the search could be done with the name key of the glossary entry
Best Answer
Here's a possible solution. It requires
xindy
rather thanmakeindex
. If you really don't want to usexindy
, it's possible to adjust the code, but it's more complicated.Edit:
Here's the code for use with
makeindex
instead ofxindy
:Result for either method:
This will also work if you want to use
equation
instead ofalign
. The code is adapted from Glossary per chapter or section. You just need to wrap your equations inside thealignglos
environment.Notes:
\ensuremath
instead of$
so it doesn't matter if you are in or out of math mode when you use the glossary entryDeg
should probably be\operatorname{Deg}
or\mathrm{Deg}
(assuming it's not justD
timese
timesg
).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 themakeglossaries
script to callmakeindex
orxindy
, which will skip any empty glossaries. If you have Perl and Java installed, you can just runarara
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.