Automatic parameter definitions under equations

For my bachelor thesis, I am using a lot of equations in my document. I would like to use a list of symbols, including units and also add a parameter description under equations.

I want to be consistent and efficient with achieving this. I want to define units and symbol descriptions only once, centrally in my document, using macros. These macros I will use throughout the document in a symbol list and in parameter definitions. If I can apply the macros more automatically the better, for preventing mistakes and working fast.

I know how to create the latex code for my desired output manually. However I would like, that whenever I add an equation, the parameter definitions can be added automatically. Is software available that can help me with this?

I am using Lyx as editor.

My plan is to define in my document:

1. Macros for units used with the siunitx package, as follows:

\DeclareSIUnit[]\kgpermthree{\kg\per\cubic\meter}
\DeclareSIUnit[]\mpers{\meter\per\second}
\DeclareSIUnit[]\patimess{\pascal\second}
\DeclareSIUnit[]\nodimension{-}

1. macros for symbol descriptions, as follows:

\newcommand{\DRho}{density of the fluid}
\newcommand{\Du}{velocity of the fluid with respect to the object. This is a second line}
\newcommand{\DL}{characteristic linear dimension}
\newcommand{\Dmu}{dynamic viscosity of the fluid}
% I chose D for 'definition'


Based on these two above I am planning to create new macros:

1. A set of macros used for equation parameter definitions i.e.:

\newcommand{\ERho}{\parbox[t]{6cm}{\DRho}\hspace{2cm}[\si{\kgpermthree}]}
\newcommand{\Eu}{\parbox[t]{6cm}{\Du}\hspace{2cm}[\si{\mpers}]},
\newcommand{\EL}{\parbox[t]{6cm}{\DL}\hspace{2cm}[\si{\meter}]}
\newcommand{\Emu}{\parbox[t]{6cm}{\Dmu}\hspace{2cm}[\si{\patimess}]}
% I chose E for 'Equation definition'


Which I am able to use in an array for the definitions of equation parameters (Where u = ... etcetera) as follows:

\begin{definitions}
\rho & \ERho \\
u & \Eu \\
L & \EL \\
\mu & \Emu
\end{definitions}


(Also see full code beneath (preamble))

1. A set of glossary definitions for the List of Symbols using the glossaries package i.e.:

% Load external file named glsSymbolListDefinitions.tex with symbol list definitions


The glossary definitions in the external .tex file are set up as follows:

\newglossaryentry{Rho}{name={$\rho$},description={\DRho},unit={\si{\kgpermthree}},type=symbolslist}
\newglossaryentry{u}{name=$u$,description={\Du},unit={\si{\mpers}},type=symbolslist}
\newglossaryentry{L}{name=$L$,description={\DL},unit={\si{\meter}},type=symbolslist}
\newglossaryentry{mu}{name=$\mu$,description={\Dmu},unit={\si{\patimess}},type=symbolslist}


So, to recap. I want to centrally define units and symbol descriptions. Create a Symbol list based on these definitions. And automatically generate parameter descriptions under an equations.

I think, building an excel sheet can help me, but this will be quite time consuming. Is there an out of the box solution? Some software available?

Desired output:

Latex code MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{glossaries}
\usepackage{array}
\usepackage{textgreek} %for greek alphabet symbols
\usepackage{siunitx}

\glssetnoexpandfield{unit} %necessary for using siunitx macros in the glossary

%The height of each row is set to 1.3 relative to its default height.
\renewcommand{\arraystretch}{1.3}

% create new glossarylist named symbolslist
\newglossary[slg]{symbolslist}{syi}{syg}{List of symbols}

% declare unit field for glossarylist of symbols

\makeglossaries

% Load external file named glsSymbolListDefinitions.tex with symbol list definitions

% define glossary style for the symbol list, based on the solution proposed on https://tex.stackexchange.com/questions/269565/glossaries-how-to-customize-list-of-symbols-with-additional-column-for-units
\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{ >{\raggedright}p{2cm}  >{\raggedright}p{8cm}  >{\raggedright}p{1,5cm} l }} %the third column with width=1,5 cm is for whitespace
{\end{longtable}}

& \bfseries Description & & \bfseries Unit \\
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& %whitespace column
& \glsunit{##1}  \tabularnewline
}
}

\makeatletter

\sisetup{inter-unit-product=\ensuremath{{}\cdot{}}}

%declaring shorthand unit macros, for use in Symbol list, equations parameters and everywhere else.
\DeclareSIUnit[]\kgpermthree{\kg\per\cubic\meter}
\DeclareSIUnit[]\mpers{\meter\per\second}
\DeclareSIUnit[]\patimess{\pascal\second}
\DeclareSIUnit[]\nodimension{-}

%as described on https://tex.stackexchange.com/questions/166580/writing-an-equation-with-the-units-positioned-off-right
\newcommand\equationunit[1]{%
\renewcommand\tagform@[1]{%
}

%as described on https://tex.stackexchange.com/questions/95838/how-to-write-a-perfect-equation-parameters-description
\newenvironment{definitions}[1][where:]
{#1 \begin{tabular}[t]{>{$}l<{$} @{${}={}$} l}}
{\end{tabular}\\[\belowdisplayskip]}

\begin{document}

\makeatother

%macros for defining symbol descriptions, used in Symbol List and in parameter description, see below
\newcommand{\DRho}{density of the fluid}
\newcommand{\Du}{velocity of the fluid with respect to the object. This is a second line}
\newcommand{\DL}{characteristic linear dimension}
\newcommand{\Dmu}{dynamic viscosity of the fluid}

%macros for parameter descriptions under equation
\newcommand{\ERho}{\parbox[t]{6cm}{\DRho}\hspace{2cm}[\si{\kgpermthree}]}
\newcommand{\Eu}{\parbox[t]{6cm}{\Du}\hspace{2cm}[\si{\mpers}]},
\newcommand{\EL}{\parbox[t]{6cm}{\DL}\hspace{2cm}[\si{\meter}]}
\newcommand{\Emu}{\parbox[t]{6cm}{\Dmu}\hspace{2cm}[\si{\patimess}]}

\printglossary[type=symbolslist,style=symbunitlong,title=List of symbols]   % list of symbols

\printglossary[type=main]  % main glossary, if available, the symbol list seems to be only printed if the main glossary is added as well. It's outside of the scope of this example to check this.

\section{An example of an equation}
An example of an equation, Reynold's number:

$$\text{Re}=\frac{\rho uL}{\mu}\equationunit{[\si{\nodimension}]}$$

\begin{definitions}
\rho & \ERho \\
u & \Eu \\
L & \EL \\
\mu & \Emu
\end{definitions}
\end{document}

• It's not directly related to your problem, but maybe you should have a look at the siunitx package. unitsdef does not seem to be in active development (last update 2005 on CTAN). – BambOo Apr 30 '18 at 13:21
• You are really asking multiple questions under the guise of a single question: 1) list of symbols, 2) symbol units, 3) format of i. equations and ii. informal symbol list. – Steven B. Segletes Apr 30 '18 at 13:24
• Are you looking for something like List of symbols after equation – Nicola Talbot Apr 30 '18 at 13:29
• @StevenB.Segletes No, I know how to make the latex code, however I am looking for a solution that automatically generates parameter description, when I enter an equation. Should I change my message? – JohnShape Apr 30 '18 at 14:33
• Another possibility is something like this mini-glossary example. – Nicola Talbot Dec 1 '18 at 19:08

Because I had some spare time lately, I decided to build an Excel file that can help me and possibly others with the above question.

I made a github project for this: https://github.com/johanf85/Symbollist-maintain-Excel

I made an Excel file where you can enter:

• unit declarations (using siunitx package)
• Symbols and regarding descriptions and units
• Equations that are used in the documents. Put every symbol in {} parenthesis

Once every input cell is filled, it's possible to enter the equation number in the box on the 'Equations' tab. Code for that equation and underlaying parameter definitions is shown.

Copy the macros to the preamble and copy the equation and definitions code to the document.

Note: Always double check the result. I tried to make the Excel workbook with care, however I haven't tested it extensively in a working situation. Would love to hear if there are situations which I have overlooked and are not working in practice.

Please let me know any comments on this project. Would love to hear possible improvements.