4

I am using the acronympackage for acronyms, symbols and constants in my report. I would like the list of constants to be slightly different than the other two lists. I want to use the \acroextra{} macro to add the value of the constants and to print them in a third column.

At the moment I have something like this:

\documentclass[10pt]{report}

\usepackage[utf8]{inputenc}
\usepackage[]{acronym}

\begin{document}
\large \textbf{Symbols}
\begin{acronym}[longest]
\acro{lam}[$\lambda$]{wavelength}
\acro{temp}[$T$]{Temperature}
\end{acronym}

\large \textbf{Constants}
\begin{acronym}[longest]
\acro{c}[$c$]{speed of light \acroextra{299 792 458 m/s}}
\acro{sig}[$\sigma$]{Stefan–Boltzmann constant \acroextra{$5.670367 10^{-8}$ W/(m$^2$K$^4$)}}
\end{acronym}

\vspace{1in}

Some text and acro calls
\end{document}

This gives:

Original

I would like it result in something like this:

Wanted

Can I make this work with a second width in the environment (\begin{acronym}[longest short][longest long]) or something? The values could also be right aligned if that is simpler.

  • This would be quite easy with glossaries ... – user31729 Jun 15 '17 at 12:54
  • The difficulty here is that acronym uses a description environment with the short form as the optional argument to \item. You'd need to rewrite this in a tabular. – Chris H Jun 15 '17 at 12:55
  • @ChristianHupfer I thought it might be, and was just looking. If so that would certainly be less work than rewriting a chunk of acronym – Chris H Jun 15 '17 at 12:56
  • 1
    @ChrisH: Here's a list of symbols with unit specification with glossaries: The adaption to use values is quite straightforward, I would say. tex.stackexchange.com/questions/269565/… – user31729 Jun 15 '17 at 13:01
  • 1
    Right aligned symbols can easily achived with \hfill before \acroextra{, but from my point of view thats not an optimal solution. – Bobyandbob Jun 15 '17 at 13:02
2

You can use the \makebox[width][position]{text} command. The box contains your constants names. The width of the box is specified by the optional width argument. With position you can specify the position of text within the box with l (flushleft), r(flushright),... . The values can be placed after the box. For easier handling i put the box inside a newcommand like this:

\newcommand{\acrosecondcolumn}[1]{
      \acroextra{\makebox[55mm][l]{#1}}
    }

Example entry:

\acro{c}[A]{\acrosecondcolumn{B}C}

1.column: A ---whitespace--- 2.column: B ---whitespace--- 3.column: C

Solution:

enter image description here

MWE:

\documentclass[10pt]{report}

\usepackage[utf8]{inputenc}
\usepackage[]{acronym}

\newcommand{\acrosecondcolumn}[1]{
  \acroextra{\makebox[55mm][l]{#1}}
}

\begin{document}
\large \textbf{Symbols}
\begin{acronym}[longest]
\acro{lam}[$\lambda$]{wavelength}
\acro{temp}[$T$]{Temperature}
\end{acronym}

\large \textbf{Constants}
\begin{acronym}[longest]
\acro{c}[A]{\acrosecondcolumn{B}C}
\acro{c}[$c$]{\acrosecondcolumn{speed of light}299 792 458 m/s}
\acro{sig}[$\sigma$]{\acrosecondcolumn{Stefan–Boltzmann constant}$5.670367 10^{-8}$ W/(m$^2$K$^4$)}
\end{acronym}
\vspace{1in}
Some text and acro calls
\end{document}
2

A solution with glossaries package, which is a little bit more powerful than acronym considering its configurability and features.

Here, a new glossary with a special symbolvalue key is defined, it is a variation of my answer here to a similar question.

Make sure to run in this order (assuming the document is called foo.tex)

  1. pdflatex foo
  2. makeglossaries foo
  3. pdflatex foo

\documentclass{book}
\usepackage{siunitx}
\usepackage[nomain]{glossaries}              % use glossaries-package


\setlength{\glsdescwidth}{15cm}

\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist


\glsaddkey{symbolvalue}{\glsentrytext{\glslabel}}{\glsentrysymbolvalue}{\GLsentrysymbolvalue}{\glssymbolvalue}{\Glssymbolvalue}{\GLSsymbolvalue}
\glssetnoexpandfield{symbolvalue}

\makeglossaries                                   % activate glossaries-package


% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
\newglossaryentry{symb:Pi}{name=\ensuremath{\pi},
  description={Geometrical symbol},
  symbolvalue={},
  type=symbolslist
}

\newglossaryentry{planck}{
  name=\ensuremath{h},
  description={Planck's constant},
  symbolvalue={\SI{6,6d-34}{\joule\second}},
  type=symbolslist
}

\newglossaryentry{lightspeed}{
  name=\ensuremath{c},
  description={Speed of light},
  symbolvalue={\SI{299792432}{\meter/\second}},
  type=symbolslist
}





\newglossarystyle{symbsymbolvaluelong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
  \begin{longtable}{lp{0.6\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
  {\end{longtable}}%
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Sign & \bfseries Description & \bfseries Value \\
  \hline
  \endhead}
\renewcommand*{\glossentry}[2]{%  Change the displayed items
  \glstarget{##1}{\glossentryname{##1}} %
  & \glossentrydesc{##1}% Description
  & \glssymbolvalue{##1}  \tabularnewline
}
}


\begin{document}
\glsaddall
\printglossary[type=symbolslist,style=symbsymbolvaluelong]   % list of symbols
\end{document}

enter image description here

  • How would I make multiple lists of glossaries, as this is a vital function to my application? – Kajsa Jun 19 '17 at 11:18
  • When I run the example you gave I just get a blank page. What am I doing wrong? – Kajsa Aug 10 '17 at 16:47
  • @Kajsa: I don't know what you have done so your question is difficult to answer – user31729 Aug 13 '17 at 16:17

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.