MakeIndex, Nomenclature, Glossaries and AcronymsTrouble changing glossaries style

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
LeonardLopes
Posts: 11
Joined: Mon Nov 16, 2015 7:27 pm

Trouble changing glossaries style

Post by LeonardLopes »

I am having trouble removing an extra period from the altlist glossary style in the glossaries package. Basically, the glossaries package places a period at the end of the description. This is problematic if the description contains a reference (which has to go after the period). Here is a MWE:

Code: Select all

\documentclass{report}

\usepackage[nonumberlist,description]{glossaries}

\newglossaryentry{gls:Acoustic}
{
  name=acoustic,
  description=
    {Associated with sound, or more generally with mechanical wave propagation in a
     medium.\cite{Morfey2000}},
}

\setglossarystyle{altlist}

\makeglossaries

\begin{document}

\glsaddall

\printglossaries

\bibliographystyle{abbrv}
\bibliography{references}
  
\end{document}
and the reference.bib file

Code: Select all

@book{Morfey2000,
  author={C. L. Morfey},
  title={Dictionary of Acoustics},
  year=2000,
  address={Harcourt Place, 32 Jamestown Road, London NW1 7BY, UK},
  publisher = {Academic Press}
}
After running pdflatex, bibtex, makeglossaries,pdflatex,pdflatex, you get the attached, MWE.pdf. Notice the double period at the end of the glossary description. I have skimmed the glossaries documentation where they have an example of redefining the list glossary style (http://mirrors.rit.edu/CTAN/macros/late ... s-user.pdf), but to be honest this might as well be written in Chinese (which I don't understand). It seems that it would be trivial to find that dot and delete it, any help would be greatly appreciated.
Attachments
MWE.pdf
Minimum working example of extra period in altlist glossary style.
(48.29 KiB) Downloaded 410 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Trouble changing glossaries style

Post by Johannes_B »

Once you know how LaTeX works, solving this isue is a matter of three minutes. Locate the glossaries package code, find the style file that contains the style, take a look at the specific style and notice: There is a macro \glspostdescription. Renewing this to be empty solves your issue. I haven't checked, though, if there might be other things that now work unexpected.

Code: Select all

\documentclass{report}

\usepackage[nonumberlist,description]{glossaries}

\newglossaryentry{gls:Acoustic}
{
	name=acoustic,
	description=
	{Associated with sound, or more generally with mechanical wave propagation in a
		medium.~\cite{doody}
	},
}

\setglossarystyle{altlist}
\renewcommand{\glspostdescription}{}

\makeglossaries

\begin{document}
\glsaddall

\printglossaries

\bibliographystyle{abbrv}
\bibliography{biblatex-examples}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LeonardLopes
Posts: 11
Joined: Mon Nov 16, 2015 7:27 pm

Trouble changing glossaries style

Post by LeonardLopes »

Thank you. I was reluctant to modify the glossary distribution, but in my document, I placed:

Code: Select all

\setglossarystyle{altlist}

\renewcommand*{\glspostdescription}{%
  \spacefactor\sfcode`\. 
}
This is taken from the following in glossaries.sty:

Code: Select all

\newcommand*{\glspostdescription}{%
  \ifglsnopostdot\else.\spacefactor\sfcode`\. \fi
}
Now, the only problem I have is the acronyms are in the abbreviated form in the glossaries....
LeonardLopes
Posts: 11
Joined: Mon Nov 16, 2015 7:27 pm

Re: Trouble changing glossaries style

Post by LeonardLopes »

I assume that I could set \glsnopostdot, but I couldn't figure out how to do that.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Trouble changing glossaries style

Post by Johannes_B »

Don't fiddle with space factors.

You can also add this instead of renewing any macros: \glsnopostdottrue.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LeonardLopes
Posts: 11
Joined: Mon Nov 16, 2015 7:27 pm

Re: Trouble changing glossaries style

Post by LeonardLopes »

That was it! Thanks a lot, you've ended about a day of banging my head on a wall... now for the next wall...
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Trouble changing glossaries style

Post by nlct »

The simplest method, which no one has mentioned so far, is to use the nopostdot package option:

Code: Select all

\usepackage[nopostdot]{glossaries}
This setting can also be used on a per-glossary basis:

Code: Select all

\printglossary[nopostdot]
Post Reply