GeneralUsing a Units column in the Glossary

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Caesar
Posts: 2
Joined: Fri Jun 29, 2012 5:59 pm

Using a Units column in the Glossary

Post by Caesar »

Hi there,

I'm currently using the alttree style of the glossary package for my List of Symbols for my Master Thesis work. This basically works fine and gives me a nice list of the symbols with the associated description.

However, I want to add a column (after the symbols column) to the List of Symbols where I can display the units related to the symbols. So that would basically create 3 columns, the first for the symbol, the 2nd for the unit and the 3rd for the description.

Unfortunately I'm not able to do this for some reason. To add items to my List of Symbols I use the following commands:

\newglossaryentry{deltac1}{type=symbols,name=\ensuremath{\delta_{c1}},text={\ensuremath{\delta_{c1}}},sort=dc1,description={Thickness of the coating deposited during one stroke},parent=romanletter}

I can add in there the symbol={...} command, but that will result in the following display in my report:

Scr ([km])Area of the supersonic nozzle throat
T0 ([km])Stagnation temperature
w ([km])Velocity of the coated surface with respect to the nozzle exit

So the units are added not as a separate column, but as the start of the description column. I want it to show like:

Scr [km] Area of the supersonic nozzle throat
T0 [km] Stagnation temperature
w [km] Velocity of the coated surface with respect to the nozzle exit

Does anyone know how I can do this? (I've seen ways of just using excel or a tabular form, which is indeed probably easier and faster right now, but I would like this to work as it was mend to be ;))

Thanks in advance for you help!

Erik

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Using a Units column in the Glossary

Post by cgnieder »

Hi Erik,

could you please be so kind and add a Infominimal working example, i.e., a complete document that is as short as possible, which we could just copy and paste? This helps to see if ideas are working before answering. There is also a bonus for you: if helpers need to build one of their own they most likely won't help.

Best regards
site moderator & package author
Caesar
Posts: 2
Joined: Fri Jun 29, 2012 5:59 pm

Using a Units column in the Glossary

Post by Caesar »

Hi Clemens,

Thanks for your quick response. I'm not that familiar with LateX, so I didn't really know what information you would need. I hope the following post makes stuff more clear.

As I said, I use the alttree part of the glossaries package found in the glossary-tree style.

Code: Select all

\newglossarystyle{alttree}{%
  \renewenvironment{theglossary}%
    {\def\@gls@prevlevel{-1}%
     \mbox{}\par}%
    {\par}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossaryentryfield}[5]{%
    \ifnum\@gls@prevlevel=0\relax
    \else
       \settowidth{\glstreeindent}{\textbf{\@glswidestname\space}}%
      \hangindent\glstreeindent
      \parindent\glstreeindent
    \fi
    \makebox[0pt][r]{\makebox[\glstreeindent][l]{%
       \textbf{\glstarget{##1}{##2}}}}%
    \ifx\relax##4\relax
    \else
      (##4)\space
    \fi
    ##3\glspostdescription \space ##5\par
    \def\@gls@prevlevel{0}%
  }%
  \renewcommand{\glossarysubentryfield}[6]{%
    \ifnum\@gls@prevlevel=##1\relax
    \else
      \@ifundefined{@glswidestname\romannumeral##1}{%
        \settowidth{\gls@tmplen}{\textbf{\@glswidestname\space}}}{%
        \settowidth{\gls@tmplen}{\textbf{%
           \csname @glswidestname\romannumeral##1\endcsname\space}}}%
      \ifnum\@gls@prevlevel<##1\relax
         \setlength\glstreeindent\gls@tmplen
         \addtolength\glstreeindent\parindent
         \parindent\glstreeindent
      \else
         \@ifundefined{@glswidestname\romannumeral\@gls@prevlevel}{%
           \settowidth{\glstreeindent}{\textbf{%
              \@glswidestname\space}}}{%
           \settowidth{\glstreeindent}{\textbf{%
              \csname @glswidestname\romannumeral\@gls@prevlevel
                 \endcsname\space}}}%
         \addtolength\parindent{-\glstreeindent}%
         \setlength\glstreeindent\parindent
      \fi
    \fi
    \hangindent\glstreeindent
    \makebox[0pt][r]{\makebox[\gls@tmplen][l]{%
      \textbf{\glstarget{##2}{##3}}}}%
    \ifx##5\relax\relax
    \else
      (##5)\space
    \fi
    ##4\glspostdescription\space ##6\par
    \def\@gls@prevlevel{##1}%
  }%
  \renewcommand*{\glsgroupskip}{\indexspace}%
Now the class that I'm using says the following about the glossaries:

Code: Select all

\newglossarystyle{listos}{%
\glossarystyle{alttree}
\renewcommand{\glsgroupskip}{}% make nothing happen between groups
}
and in my main.tex file I use

Code: Select all

\printglossary[style=listos,type=symbols]
.

My list of symbols are made in a different .tex file that I load in the main file containing the following:

Code: Select all

\newglossaryentry{cl}{type=symbols,name=\ensuremath{C_L},text={\ensuremath{C_L}},sort=cl,description={Lift Coefficient},parent=romanletter}

\newglossaryentry{Gpmax}{type=symbols,name=\ensuremath{G_{pmax}},text={\ensuremath{G_{pmax}}},sort=gpmax,description={Maximum possible flow rate of powder through the nozzle},parent=romanletter}

\newglossaryentry{G}{type=symbols,name=\ensuremath{G},text=\ensuremath{G}
,sort=G,description={Total flow rate through nozzle},parent=romanletter}

\newglossaryentry{p0}{type=symbols,name=\ensuremath{p_0},text={\ensuremath{p_0}},sort=p0,description={Stagnation pressure},parent=romanletter}

\newglossaryentry{Scr}{type=symbols,name=\ensuremath{S_{cr}},text={\ensuremath{S_{cr}}},sort=Scr,description={Area of the supersonic nozzle throat},parent=romanletter, symbol=[km]}

\newglossaryentry{T0}{type=symbols,name=\ensuremath{T_0},text={\ensuremath{T_0}},sort=t0,description={Stagnation temperature},parent=romanletter, symbol=[km]}
So hopefully this is a bit more clear.

Thanks in advance!

Erik
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Using a Units column in the Glossary

Post by cgnieder »

That's better but still no Infominimal working example (MWE). The point of a MWE is that besides being minimal it can be copied and compiled as is. Maybe the code below can be a starting point for creating a real MWE? As it is it's not compilable but I'm sure you can fill in the missing bits so we can start looking?

Code: Select all

% example MWE, incomplete
\documentclass{scrartcl}
\usepackage{glossaries}
\newglossarystyle{listos}{%
  \glossarystyle{alttree}
  \renewcommand{\glsgroupskip}{}% make nothing happen between groups
}
\newglossaryentry{cl}{
  type=symbols,
  name=\ensuremath{C_L},
  text={\ensuremath{C_L}},
  sort=cl,
  description={Lift Coefficient},
  parent=romanletter}
\newglossaryentry{Gpmax}{
  type=symbols,
  name=\ensuremath{G_{pmax}},
  text={\ensuremath{G_{pmax}}},
  sort=gpmax,
  description={Maximum possible flow rate of powder through the nozzle},
  parent=romanletter}
\begin{document}

\printglossary[style=listos,type=symbols]

\end{document}
Best regards
site moderator & package author
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Using a Units column in the Glossary

Post by nlct »

Caesar wrote: I'm currently using the alttree style of the glossary package for my List of Symbols for my Master Thesis work. This basically works fine and gives me a nice list of the symbols with the associated description.

However, I want to add a column (after the symbols column) to the List of Symbols where I can display the units related to the symbols. So that would basically create 3 columns, the first for the symbol, the 2nd for the unit and the 3rd for the description.
All the tree styles just indent each level. There are no columns in those styles, so you can't add a new one. The 4col styles, such as long4col, have four columns: name, description, symbol and location list. This would correspond to your symbol, description, units and location list, so you'd just need to modify one of the 4col styles and swap the second and third columns around. Example:

Code: Select all

\documentclass{scrartcl}
\usepackage{glossaries}

\newglossary{symbols}{sym}{slo}{Symbols}

\makeglossaries

\newglossarystyle{listos}{%
  \glossarystyle{long4col}
  % allow line wrap in the description column
  \renewenvironment{theglossary}%
    {\begin{longtable}{llp{\glsdescwidth}p{\glspagelistwidth}}}%
    {\end{longtable}}%
  \renewcommand{\glsgroupskip}{}% make nothing happen between groups
  % swap second and third columns
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##4 & ##3 & ##5\\}
  % sub-entries
  \renewcommand*{\glossarysubentryfield}[6]{%
     \glssubentryitem{##2}%
     \glstarget{##2}{##3} & ##5 & ##4 & ##6\\}%
}

\newglossaryentry{romanletter}{name={Roman},description={\nopostdesc}}

\newglossaryentry{cl}{
  type=symbols,
  name=\ensuremath{C_L},
  text={\ensuremath{C_L}},
  sort=cl,
  description={Lift Coefficient},
  parent=romanletter}

\newglossaryentry{Gpmax}{
  type=symbols,
  name=\ensuremath{G_{pmax}},
  text={\ensuremath{G_{pmax}}},
  sort=gpmax,
  description={Maximum possible flow rate of powder through the
nozzle},
  parent=romanletter}

\newglossaryentry{Scr}{type=symbols,name=\ensuremath{S_{cr}},text={\ensuremath{S_{cr}}},sort=Scr,description={Area
of the supersonic nozzle throat},parent=romanletter, symbol=[km]}

\begin{document}
\glsaddall

\printglossary[style=listos,type=symbols]

\end{document}
Regards
Nicola Talbot
Post Reply