I'm using the glossaries package to generate a nomenclature for my document. The problem is that some of my entries have very long functions within the name field. How can I add a manual line break at the desired position? So e.g. after the first or second comma within the function of the second entry.
What I don't want is to change the definition of \glssetwidest
as the width fits well for most of the entries.
MWE:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath}
\usepackage{longtable}
\usepackage[acronym,toc,nopostdot]{glossaries}
\glssetwidest[0]{...................}
\newglossaryentry{first_entry}{
name = $\omega_i$ ,
description = Description
}
\newglossaryentry{second_entry}{
name = {$f(epq_{i}, tlz_{i+1}, xy)$} ,
description = Description
}
\makeglossaries
\begin{document}
\glsaddall
\printglossary[nonumberlist, style = alttree, title=Nomenclature]
\end{document}
Edit: If the description is long (e.g. three lines) and the symbol spans over two lines then there is a blank line within the description. How can I change this behaviour?
MWE of Edit:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath}
\usepackage{longtable}
\usepackage[acronym,toc,nopostdot]{glossaries}
\glssetwidest[0]{...................}
\newglossaryentry{first_entry}{
name = $\omega_i$ ,
description = Description
}
\newglossaryentry{second_entry}{
name = {$f(epq_{i}, tlz_{i+1},\newline xy)$},
text = {$f(epq_{i}, tlz_{i+1}, xy)$},
description = {Very long description lines with span several lines and gets broken by a blank line if the symbol span two line. Very long description lines with span several lines and gets broken by a blank line if the symbol span two line.}
}
\makeatletter
\newglossarystyle{alttree2}{%
\setglossarystyle{alttree}%
\renewcommand{\glossentry}[2]{%
\ifnum\@gls@prevlevel=0\relax
\else
\settowidth{\glstreeindent}{\glstreenamefmt{\@glswidestname\space}}%
\fi
\hangindent\glstreeindent
\parindent\glstreeindent
\makebox[0pt][r]{\parbox[t]{\glstreeindent}{\raggedright
\glsentryitem{##1}\glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}}}%
\ifglshassymbol{##1}{(\glossentrysymbol{##1})\space}{}%
\glossentrydesc{##1}\glspostdescription \space ##2\par
\def\@gls@prevlevel{0}%
}%
}
\makeatother
\makeglossaries
\begin{document}
\glsaddall
\printglossary[nonumberlist, style = alttree2, title=Nomenclature]
\end{document}
\begin{document}
, undefined\f
and the value of thename
key needs braces when it contains commas).