3

I am using glossaries to make multiple lists of acronyms and symbols, and printing them before the main document. I would then like to print them all in an index after the main document, without the type titles and sorted together.

EXAMPLE:


**Symbols*

c Speed of light

h Planck's constant

Acronyms

FPS Frames per second

Main document

Index

Frames per second (FPS) ............ p.1

Planck's constant (h) .................. p.2

Speed of light (c) ....................... p.3


My current MWE:

\documentclass{report}
\usepackage{siunitx}
\usepackage[nomain, acronyms, nonumberlist, section=section]{glossaries}
\usepackage{glossary-mcols}
\usepackage{xparse}

\setlength{\glsdescwidth}{15cm}

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


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

\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\glssetnoexpandfield{unit}

\makeglossaries                                   % activate glossaries-package

\NewDocumentCommand{\newglossaryconstant}{o m m m m m}{\newglossaryentry{#2}{%
    name=\ensuremath{#3},
    description={#4},
    symbolvalue={#5},
    unit={#6},
    first={#4, (\ensuremath{#3})},
    text={\ensuremath{#3}},
    type=symbolslist,
    sort=\IfNoValueTF{#1}{#3}{#1}}}


\newglossaryconstant{lightspeed}{c}{speed of light}{299792432}{\si{\meter/\second}}

\newglossaryconstant[h]{planck}{h}{Planck's constant}{$6.6261\cdot10^{-34}$}{[\si{\joule\second}]}

\newacronym[longplural={Frames per Second}]{fps}{FPS}{Frame per Second}

\newglossarystyle{mylist}{%
% put the glossary in the itemize environment:
\renewenvironment{theglossary}{\setlength{\LTleft}{0pt}\begin{longtable}{l>{\raggedright}p{.4\textwidth}>{\raggedleft}p{0.3\textwidth}r}}{\end{longtable}}%
% have nothing after \begin{theglossary}:
\renewcommand*{\glossaryheader}{%  Change the table header
   Sign &  Description & Value & Unit \\
  \endhead}
% have nothing between glossary groups:
\renewcommand*{\glsgroupheading}[1]{\vspace{-.5em}\\ \textbf{\glsgetgrouptitle{##1}}\\}%
\renewcommand*{\glsgroupskip}{}%
% set how each entry should appear:
\renewcommand*{\glossentry}[2]{%  Change the displayed items
  \glstarget{##1}{\glossentryname{##1}} %
  & \glossentrydesc{##1}% Description
  & \glssymbolvalue{##1}
  & \glsunit{##1}%
  \tabularnewline
}
}

\newglossarystyle{myindex}{%
\glossarystyle{mcolindexgroup}
\renewcommand*{\glsgroupheading}[1]{}%
}


\begin{document}

\glsaddall
\printglossary[type=symbolslist,style=mylist]   % list of symbols
\printglossary[type=\acronymtype] % prints just the list of acronyms

\glsresetall
\section{first}

\Gls{planck}

\subsection{second}
\Gls{planck}

\renewcommand{\glsmcols}{3}
\setglossarystyle{myindex}

\printglossaries
\end{document}

Gives me this result:

enter image description here

  • Something like \glsmoveentry in conjunction with \forallglsentries? – user31729 Aug 26 '17 at 20:58
  • @ChristianHupfer, Thanks! I didn't realize that I was using an old version of the user manual, which doesn't include those functions. – Kajsa Aug 27 '17 at 16:52
  • @ChristianHupfer, However, \glsmoveentry doesn't work inside the document and putting it in the preamble removes the entry from the original glossary. Also, I can't seem to get the entry to move to the glossary that I want, not sure if I'm using the wrong <target glossary label> – Kajsa Aug 27 '17 at 17:52
1

You can use makeindex to merge all the entries into a single file. If you remove the nomain option, you can use the main glossary for your combined index at the end and get makeindex to create a merged file.

Modified MWE:

\documentclass{report}
\usepackage{siunitx}
\usepackage[acronyms, nonumberlist, section=section]{glossaries}% removed `nomain'
\usepackage{glossary-mcols}
\usepackage{xparse}

\setlength{\glsdescwidth}{15cm}

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


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

\glsaddkey{unit}{\glsentrytext{\glslabel}}{\glsentryunit}{\GLsentryunit}{\glsunit}{\Glsunit}{\GLSunit}
\glssetnoexpandfield{unit}

\makeglossaries                                   % activate glossaries-package

\NewDocumentCommand{\newglossaryconstant}{o m m m m m}{\newglossaryentry{#2}{%
    name=\ensuremath{#3},
    description={#4},
    symbolvalue={#5},
    unit={#6},
    first={#4, (\ensuremath{#3})},
    text={\ensuremath{#3}},
    type=symbolslist,
    sort=\IfNoValueTF{#1}{#3}{#1}}}


\newglossaryconstant{lightspeed}{c}{speed of light}{299792432}{\si{\meter/\second}}

\newglossaryconstant[h]{planck}{h}{Planck's constant}{$6.6261\cdot10^{-34}$}{[\si{\joule\second}]}

\newacronym[longplural={Frames per Second}]{fps}{FPS}{Frame per Second}

\newglossarystyle{mylist}{%
% put the glossary in the itemize environment:
\renewenvironment{theglossary}{\setlength{\LTleft}{0pt}\begin{longtable}{l>{\raggedright}p{.4\textwidth}>{\raggedleft}p{0.3\textwidth}r}}{\end{longtable}}%
% have nothing after \begin{theglossary}:
\renewcommand*{\glossaryheader}{%  Change the table header
   Sign &  Description & Value & Unit \\
  \endhead}
% have nothing between glossary groups:
\renewcommand*{\glsgroupheading}[1]{\vspace{-.5em}\\ \textbf{\glsgetgrouptitle{##1}}\\}%
\renewcommand*{\glsgroupskip}{}%
% set how each entry should appear:
\renewcommand*{\glossentry}[2]{%  Change the displayed items
  \glstarget{##1}{\glossentryname{##1}} %
  & \glossentrydesc{##1}% Description
  & \glssymbolvalue{##1}
  & \glsunit{##1}%
  \tabularnewline
}
}

\newglossarystyle{myindex}{%
\setglossarystyle{mcolindexgroup}% changed \glossarystyle to \setglossarystyle
\renewcommand*{\glsgroupheading}[1]{}%
}


\begin{document}

\glsaddall
\printglossary[type=symbolslist,style=mylist]   % list of symbols
\printglossary[type=\acronymtype] % prints just the list of acronyms

\glsresetall
\section{first}

\Gls{planck}

\subsection{second}
\Gls{planck}

\renewcommand{\glsmcols}{3}
\setglossarystyle{myindex}

\printglossary[title=Index]% main glossary
\end{document}

(Note: \glossarystyle is deprecated. I've replaced it with \setglossarystyle. If this new command isn't recognised, then I recommend you update your version of glossaries. Incidentally, you can just use mcolindex, which is functionally identical to your myindex style.)

If the file is called test.tex, then the build process is:

pdflatex test
makeindex -s test.ist -t test.slg -o test.syi test.syg
makeindex -s test.ist -t test.alg -o test.acr test.acn
makeindex -s test.ist -t test.glg -o test.gls test.acn test.syg
pdflatex test

The third makeindex call merges test.acn (acronyms) and test.syg (symbols) and saves the result to test.gls (main).

image of document

|improve this answer|||||

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.