1

I'm trying to produce a list of symbols for my PhD thesis including a column with the units of the symbols. Therefore, I used the latex code provided in the following link: glossaries: add additional column for units.

Minimum Working Example (MWE):

\documentclass[11pt, pdftex]{scrreprt}

% ---- packages: ---------------
\usepackage[LGR,T1]{fontenc}                
\usepackage[utf8]{inputenc}         
\usepackage[english]{babel}
\usepackage{substitutefont}
\usepackage{newtxtext}                      
\usepackage{newtxmath}                  
\substitutefont{LGR}{\rmdefault}{Tempora}   
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage[pdftex]{hyperref}

\usepackage[            
    nogroupskip,                
    acronym,                
    nomain,                     
    nopostdot,                  
    sort=standard,
    automake,            
    xindy,      
]
{glossaries-extra}

\usepackage{glossary-longbooktabs} 
\setabbreviationstyle[acronym]{long-short}      
\setlength{\glsdescwidth}{18cm} 

% -- new style for list of symbols: ----
\newglossarystyle{symbunitlong}{
    \setglossarystyle{long3col}     % base this style on the list style

    \renewenvironment{theglossary}{ % Change the table type --> 3 columns
        \begin{longtable}{lp{0.5\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}
        {\end{longtable}}

    \renewcommand*{\glossaryheader}{%  Change the table header
        \bfseries Sign  & \bfseries Description     & \bfseries Unit    \\
        \hline 
        \addlinespace[7mm]
        \endhead}

    \renewcommand*{\glossentry}[2]{%  Change the displayed items
        \glstarget{##1}{\glossentryname{##1}} %
        & \glossentrydesc{##1}%     Description
        & \glsunit{##1}  \tabularnewline 
        \addlinespace[2mm]}
} 

% --- define symbollist: ------
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols} 

% include third column in list of symbols for units:
\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}

\makeglossaries 
\glssetcategoryattribute{acronym}{glossdesc}{firstuc}

% -------------------------------------------
% define some symbols:
\newglossaryentry{symb:lambda}{
    name={\ensuremath{\lambda}},
    sort={z_lambda},
    description={Thermal conductivity},
    unit={\si{\frac{W}{m \cdot K}}},
    type=symbolslist
}
\newglossaryentry{symb:Pc}{
    name={\ensuremath{P_{\mathrm{C}}}},
    sort={PC},
    description={Carnot power},
    unit={\si{W}},
    type=symbolslist
}           
\newglossaryentry{symb:Qjoule}{
    name={\ensuremath{\dot{Q}_\mathrm{J}}},
    sort={Qjoule},
    description={Joule heating},
    unit={\si{W}},
    type=symbolslist
}   
% -------------------------------------------
% define some abbreviations:
\newacronym{acro:FCL}{FCL}{fault current limiters}
\newacronym{acro:SS}{SS}{stainless steel}
% -------------------------------------------


\begin{document}

\textbf{First page:}    
\begin{itemize}
    \item use of symbols \gls{symb:Qjoule} and \gls{symb:Pc} 
    \item use of abbreviation: \gls{acro:SS}
\end{itemize}
\newpage

\textbf{Second page:}
\begin{itemize}
    \item use of symbol \gls{symb:lambda}
    \item use of abbreviation: \gls{acro:FCL}
\end{itemize}
\newpage

% ---- list of symbols: -------
\printglossary[type=symbolslist, style=symbunitlong]

% ---- list of abbreviations: -------
\printglossary[title={List of Abbreviations}, type=acronym, style=listdotted]

\end{document}  

It works so far (see MWE above), but now I intend to add a fourth column which indicates the first appearance/page of definition of the symbols. The final, desired state of my list of symbols should look like it is shown in the following screenshot: enter image description here


And I just want to display the page number of the page where the respective symbol occurs for the first time in the text, not every page number where it is used. But unfortunately, I don’t really know how to do that and what I have to add in my defined glossary style.


Thank you very much for your help!


Edit:

I'm wondering if the question is not clear and I wasn't able to point out my problem or if it's just not possible to realize the intended thing and to add a fourth column which indicates only the first appearance/page of definition of the symbols.

Considering the related questions to my question, I suppose that the package option "indexonlyfirst" could help, but I don't know how to integrate that in detail.


Edit: enter image description here

0

If you use the symbol key instead of providing a new key for the units then the altlongragged4col-booktabs style is very similar to your desired format, so that would be a better starting point.

I've trimmed down your example and provided the commands \glsentryunit etc that simply use the symbol field instead, in case you need them in your document.

\documentclass[11pt]{scrreprt}

\usepackage{siunitx}
\usepackage{hyperref}

\usepackage[            
    nogroupskip,                
    acronym,                
    nomain,                     
    xindy,      
    stylemods={longbooktabs},% patch styles and load glossary-longbooktabs.sty
    indexonlyfirst% only index first use
]
{glossaries-extra}

% prefix page list with "page~" or "pages~"
\GlsXtrEnablePreLocationTag{page~}{pages~}

\setabbreviationstyle[acronym]{long-short}      
\setlength{\glsdescwidth}{8cm} 
\setlength{\glspagelistwidth}{2.5cm} 

% --- define symbollist: ------
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols} 

\newcommand{\glsentryunit}{\glsentrysymbol}
\newcommand{\Glsentryunit}{\Glsentrysymbol}
\newcommand{\glsunit}{\glssymbol}
\newcommand{\Glsunit}{\Glssymbol}
\newcommand{\GLSunit}{\GLSsymbol}

\makeglossaries 
\glssetcategoryattribute{acronym}{glossdesc}{firstuc}

% -------------------------------------------
% define some symbols:
\newglossaryentry{symb:lambda}{
    name={\ensuremath{\lambda}},
    sort={z_lambda},
    description={Thermal conductivity},
    symbol={\si{\frac{W}{m \cdot K}}},
    type=symbolslist
}
\newglossaryentry{symb:Pc}{
    name={\ensuremath{P_{\mathrm{C}}}},
    sort={PC},
    description={Carnot power},
    symbol={\si{W}},
    type=symbolslist
}           
\newglossaryentry{symb:Qjoule}{
    name={\ensuremath{\dot{Q}_\mathrm{J}}},
    sort={Qjoule},
    description={Joule heating},
    symbol={\si{W}},
    type=symbolslist
}   
% -------------------------------------------
% define some abbreviations:
\newacronym{acro:FCL}{FCL}{fault current limiters}
\newacronym{acro:SS}{SS}{stainless steel}
% -------------------------------------------


\begin{document}

\textbf{First page:}    
\begin{itemize}
    \item use of symbols \gls{symb:Qjoule} and \gls{symb:Pc} 
    \item use of abbreviation: \gls{acro:SS}
\end{itemize}
\newpage

\textbf{Second page:}
\begin{itemize}
    \item use of symbol \gls{symb:lambda}
    \item use of abbreviation: \gls{acro:FCL}
\end{itemize}
\newpage

\textbf{Third page:}    
\begin{itemize}
    \item another use of symbols \gls{symb:Qjoule} and \gls{symb:Pc} 
    \item another use of abbreviation: \gls{acro:SS}
    \item another use of symbol \gls{symb:lambda}
    \item another use of abbreviation: \gls{acro:FCL}
\end{itemize}
\newpage


% ---- list of symbols: -------
\renewcommand{\entryname}{Sign}
\renewcommand{\symbolname}{Unit}
\renewcommand{\pagelistname}{First appearance\slash definition}
\printglossary[type=symbolslist, style=altlongragged4col-booktabs]

% ---- list of abbreviations: -------
\printglossary[title={List of Abbreviations}, type=acronym, style=listdotted]

\end{document}  

This produces:

image of list of symbols

which almost matches, except for the column alignment.

The altlong4col-booktabs style is defined as:

\newglossarystyle{altlong4col-booktabs}{%
  \glspatchLToutput
  \setglossarystyle{long4col-booktabs}%
  \renewenvironment{theglossary}%
    {\begin{longtable}{lp{\glsdescwidth}lp{\glspagelistwidth}}}%
    {\end{longtable}}%
}

This in turn uses long4col-booktabs which sets up the header with:

  \renewcommand*{\glossaryheader}{%
    \toprule \bfseries \entryname &
    \bfseries \descriptionname &
    \bfseries \symbolname &
    \bfseries \pagelistname
    \tabularnewline\midrule\endhead
    \bottomrule\endfoot}%

So if you don't want the top rule and bottom rule this can be redefined as well, and you may prefer to replace the commands \entryname, \symbolname and \pagelistname with your hard-coded values instead of having to redefine them.

The patch \glspatchLToutput in the altlong4col-booktabs style is superfluous as it's already applied by long4col-booktabs, so it may be omitted.

Here's the new style that combines the above:

\newglossarystyle{symbunitlong}{%
  \setglossarystyle{long4col-booktabs}%
  \renewenvironment{theglossary}%
    {\begin{longtable}{cp{\glsdescwidth}c>{\centering}p{\glspagelistwidth}}}%
    {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Sign &
    \bfseries \descriptionname &
    \bfseries Unit &
    \bfseries First appearance\slash definition
    \tabularnewline\midrule\endhead}%
}

The complete MWE is:

\documentclass[11pt]{scrreprt}

\usepackage{siunitx}
\usepackage{hyperref}

\usepackage[            
    nogroupskip,                
    acronym,                
    nomain,                     
    xindy,      
    stylemods={longbooktabs},% patch styles and load glossary-longbooktabs.sty
    indexonlyfirst% only index first use
]
{glossaries-extra}

% prefix page list with "page~" or "pages~"
\GlsXtrEnablePreLocationTag{page~}{pages~}

\setabbreviationstyle[acronym]{long-short}      
\setlength{\glsdescwidth}{8cm} 
\setlength{\glspagelistwidth}{2.5cm} 

% --- define symbollist: ------
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols} 

\newcommand{\glsentryunit}{\glsentrysymbol}
\newcommand{\Glsentryunit}{\Glsentrysymbol}
\newcommand{\glsunit}{\glssymbol}
\newcommand{\Glsunit}{\Glssymbol}
\newcommand{\GLSunit}{\GLSsymbol}

\makeglossaries 
\glssetcategoryattribute{acronym}{glossdesc}{firstuc}

\newglossarystyle{symbunitlong}{%
  \setglossarystyle{long4col-booktabs}%
  \renewenvironment{theglossary}%
    {\begin{longtable}{cp{\glsdescwidth}c>{\centering}p{\glspagelistwidth}}}%
    {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Sign &
    \bfseries \descriptionname &
    \bfseries Unit &
    \bfseries First appearance\slash definition
    \tabularnewline\midrule\endhead}%
}

% -------------------------------------------
% define some symbols:
\newglossaryentry{symb:lambda}{
    name={\ensuremath{\lambda}},
    sort={z_lambda},
    description={Thermal conductivity},
    symbol={\si{\frac{W}{m \cdot K}}},
    type=symbolslist
}
\newglossaryentry{symb:Pc}{
    name={\ensuremath{P_{\mathrm{C}}}},
    sort={PC},
    description={Carnot power},
    symbol={\si{W}},
    type=symbolslist
}           
\newglossaryentry{symb:Qjoule}{
    name={\ensuremath{\dot{Q}_\mathrm{J}}},
    sort={Qjoule},
    description={Joule heating},
    symbol={\si{W}},
    type=symbolslist
}   
% -------------------------------------------
% define some abbreviations:
\newacronym{acro:FCL}{FCL}{fault current limiters}
\newacronym{acro:SS}{SS}{stainless steel}
% -------------------------------------------


\begin{document}

\textbf{First page:}    
\begin{itemize}
    \item use of symbols \gls{symb:Qjoule} and \gls{symb:Pc} 
    \item use of abbreviation: \gls{acro:SS}
\end{itemize}
\newpage

\textbf{Second page:}
\begin{itemize}
    \item use of symbol \gls{symb:lambda}
    \item use of abbreviation: \gls{acro:FCL}
\end{itemize}
\newpage

\textbf{Third page:}    
\begin{itemize}
    \item another use of symbols \gls{symb:Qjoule} and \gls{symb:Pc} 
    \item another use of abbreviation: \gls{acro:SS}
    \item another use of symbol \gls{symb:lambda}
    \item another use of abbreviation: \gls{acro:FCL}
\end{itemize}
\newpage


% ---- list of symbols: -------
\printglossary[type=symbolslist, style=symbunitlong]

% ---- list of abbreviations: -------
\printglossary[title={List of Abbreviations}, type=acronym, style=listdotted]

\end{document} 

This produces:

image of list of symbols

The simplest way of increasing the gap between all the rows is to change \arraystretch. The default value is 1. The modification to the style below increases this to 1.5 (the change is localised so it won't affect any tables that come after the list of symbols).

\newglossarystyle{symbunitlong}{%
  \setglossarystyle{long4col-booktabs}%
  \renewenvironment{theglossary}%
    {%
     \renewcommand{\arraystretch}{1.5}%
     \begin{longtable}{cp{\glsdescwidth}c>{\centering}p{\glspagelistwidth}}}%
    {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Sign &
    \bfseries \descriptionname &
    \bfseries Unit &
    \bfseries First appearance\slash definition
    \tabularnewline\midrule\endhead}%
}

You can adjust this value as appropriate. The larger the value, the bigger the inter-row spacing.

  • Thank you very much, that is almost exactly what I intended to do. I implemented your code into my main thesis and it worked. I have just still a little problem with too small line distances between the rows. I would like to increase it a little bit to have more space for the units because they often contain some fractions (as I tried to indicate in the screenshot with the blue arrow). In my original MWE, this was done by \addlinespace[2mm], but I don’t know where to implement it here in your new code with the long4col-booktabs style? – F.Schrein Nov 17 '18 at 14:29
  • Info: I added the mentioned screenshot as an edit in my question above. – F.Schrein Nov 17 '18 at 14:35
  • @F.Schrein I've updated my answer. – Nicola Talbot Nov 19 '18 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.