glossaries: list of symbols, first appearence in text
1,251
This is the simplest method (given that AH
is essentially an abbreviation):
\documentclass[a4paper,10pt,twoside]{report}
\usepackage[acronym,nopostdot,toc,section=chapter,acronymlists={acronym,symbolslist}]{glossaries}
\newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create symbolslist
% Glossary settings
\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\makeglossaries
\setacronymstyle{long-short}
\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{p{2cm}p{10.92cm}p{2cm}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{% Change the table header
\bfseries Sign & \bfseries Description & \bfseries Unit \\
\hline
\endhead}
\renewcommand*{\glossentry}[2]{% Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1} \tabularnewline
}
}
\newacronym[type=symbolslist,unit={$g/m^3$}]{AH}{AH}{Absolute Humidity}
\begin{document}
In text reference of first appearance of the term \gls{AH}, second
appearence \gls{AH}.
%Print the glossary
\glsaddall
%\printglossaries % print all in default values
\printglossary[type=\acronymtype, style=list, nonumberlist] % prints just the list of acronyms
\printglossary[type=symbolslist, style=symbunitlong] % list of symbols
\printglossary[style=altlist,nonumberlist ] % if no option is supplied the default glossary is printed.
\end{document}
Related videos on Youtube
Author by
meep
Updated on August 01, 2022Comments
-
meep over 1 year
I followed this answer to add a seperate list of symbols, besides my acronym list and general glossary: glossaries: How to customize list of symbols with additional column for units?
As a first appearence in text I would like to see Absolute Humidity (AH), and the next appearences only AH, but when I add
first={Absolute Humidity (AH)}
to the code, it just ignores it. Adding text={Absolute Humidity (AH)} works, but then all my references are in this long variant. I refer to it as in the code below in my main.tex
\documentclass[a4paper,10pt,twoside]{report} \usepackage[acronym,nopostdot,toc,section=chapter]{glossaries} \newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create symbolslist % Glossary settings \glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit} \makeglossaries \loadglsentries{glossary} \newglossarystyle{symbunitlong}{% \setglossarystyle{long3col}% base this style on the list style \renewenvironment{theglossary}{% Change the table type --> 3 columns \begin{longtable}{p{2cm}p{10.92cm}p{2cm}}}% {\end{longtable}}% \renewcommand*{\glossaryheader}{% Change the table header \bfseries Sign & \bfseries Description & \bfseries Unit \\ \hline \endhead} \renewcommand*{\glossentry}[2]{% Change the displayed items \glstarget{##1}{\glossentryname{##1}} % & \glossentrydesc{##1}% Description & \glsunit{##1} \tabularnewline } } \begin{document} In text reference of first appearance of the term \gls{AH}, second appearence \gls{AH}. %Print the glossary \glsaddall %\printglossaries % print all in default values \printglossary[type=\acronymtype, style=list, nonumberlist] % prints just the list of acronyms \printglossary[type=symbolslist, style=symbunitlong] % list of symbols \printglossary[style=altlist,nonumberlist ] % if no option is supplied the default glossary is printed. \end{document}
my glossay.tex file looks like this
\newglossaryentry{AH}{type=symbolslist, name={AH}, description={Absolute Humidity.}, unit={$g/m^3$}}
How can I solve this?
-
Admin almost 7 yearsWelcome to TeX.SE. Please do not post such fragments only. Provide the compilable code that shows the issue!
-
Nicola Talbot almost 7 years
\ref
is for use with\label
. You need to use\gls
to reference glossary entries. -
meep almost 7 yearsI hope I improved my question. Fairly new to latex, so I wasn't aware of the way to ask a question here
-
meep almost 7 yearsI used \gls in text. I typed ref by mistake here, my document uses \gls and it shows the reference to the symbol list. The problem is that it always shows AH and no difference for the first appearence
-
Admin almost 7 years@meep: Your document is still a fragment only. I am not going to glue this to a working document
-
-
meep almost 7 yearsThank you! I was fixed on the \newglossaryentry since I just copied the example which worked fine until now.
-
meep almost 7 yearsOk now I have a new problem.. I added a list of figures at the start of my document, and there the acronym is also used. This causes a long term in the list of figures, while when explaining the term in the text it is in it's short version again. Redirect: tex.stackexchange.com/questions/225944/…
-
Nicola Talbot almost 7 yearsSee Why shouldn't I use commands like \gls in \section, \chapter, \caption etc?. Use
\caption[... AH ...]{... \gls{AH} ...}
or\caption{... \glsentryshort{AH} ...}