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:
- Macros for units used with the
siunitxpackage, as follows:
\DeclareSIUnit[]\kgpermthree{\kg\per\cubic\meter}
\DeclareSIUnit[]\mpers{\meter\per\second}
\DeclareSIUnit[]\patimess{\pascal\second}
\DeclareSIUnit[]\nodimension{-}
- 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:
- 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))
- A set of glossary definitions for the List of Symbols using the
glossariespackage i.e.:
% Load external file named glsSymbolListDefinitions.tex with symbol list definitions
\loadglsentries{glsSymbolListDefinitions}
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
\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\makeglossaries
% Load external file named glsSymbolListDefinitions.tex with symbol list definitions
\loadglsentries{glsSymbolListDefinitions}
% 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}}
\renewcommand*{\glossaryheader}{% Change the table header
& \bfseries Description & & \bfseries Unit \\
\endhead}
\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
\providecommand\add@text{}
\newcommand\equationunit[1]{%
\gdef\add@text{#1\gdef\add@text{}}}%
\renewcommand\tagform@[1]{%
\maketag@@@{\llap{\add@text\quad}(\ignorespaces#1\unskip\@@italiccorr)}%
}
%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}
\glsaddall
\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:
\begin{equation}
\text{Re}=\frac{\rho uL}{\mu}\equationunit{[\si{\nodimension}]}
\end{equation}
\begin{definitions}
\rho & \ERho \\
u & \Eu \\
L & \EL \\
\mu & \Emu
\end{definitions}
\end{document}

\usepackage{acronym}? Related: Add third column to acronym or Formal looking Symbols, Operators and Abbreviations section for thesis? – Bobyandbob Apr 30 '18 at 13:17siunitxpackage.unitsdefdoes not seem to be in active development (last update 2005 on CTAN). – BambOo Apr 30 '18 at 13:21siunitxhas quite a straightforward syntax, but I can uderstand your relunctance – BambOo Apr 30 '18 at 17:28\gls, but does provide an outcome as desired. I have created an Excel based solution as well. I am still kind of new to LaTeX but came up with this, see the answer below. I also like to use this Excel sheet as a tool to maintain the list of symbols in an efficient way within the Excel interface. – JohnShape Dec 03 '18 at 11:06