2

By running the code below I get this result:
enter image description here
but I want something like the following image. In other words I need to be able to have an extra extendeddiscription option in the \newglossaryentry command so that I can add a "Extended description" to some of my entries. How can I do that?

enter image description here

\documentclass[a4paper]{book}
\usepackage{lipsum}
\usepackage[xindy,nonumberlist,toc]{glossaries}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
%\renewcommand{\glossarymark}[1]{\markboth{#1}{#1}}
\newglossarystyle{mylist}{%
\glossarystyle{treegroup}
 \renewenvironment{theglossary}%
    {\setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt}
     }%
    {}%
  \renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{\noindent\textbf{\glsgetgrouptitle{##1}}\par\nopagebreak}
  \renewcommand{\glossaryentryfield}[5]{%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glsentryitem{##1}\glstarget{##1}{##2}%
{\dotfill}\ifx\relax##4\relax
    \else
      \space(##4)%
    \fi
    \space ##3\glspostdescription \space ##5\par}%
  \renewcommand{\glossarysubentryfield}[6]{%
%    \hangindent##1\glstreeindent\relax
  \parindent##1\glstreeindent\relax
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \glstarget{##2}{##3}%
    \ifx\relax##5\relax
    \else
      \space(##5)%
    \fi
  {\dotfill}
##4\indent\glspostdescription\space##6\par}%
  \renewcommand*{\glsgroupskip}{\indexspace}
  \renewcommand*{\glspostdescription}{}
}
\makeatother
\setlength{\glstreeindent}{20pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newglossaryentry{latinalph}
{
name={Alfabeto latino},
description={Latin Alphabet},
}

\newglossaryentry{exlatinalph}
{
name={Esteso alfabeto latino},
description={Extended Latin Alphabet},
parent={latinalph}
%extendeddescription={\lipsum[1]}
}

\newglossaryentry{set}
{
name={Impostato},
description={Set},
parent={latinalph}
}

\newglossaryentry{diamatrix}
{
name={Matrice diagonale},
description={Diagonal matrix},
%extendeddescription={\lipsum[2]}
}

\makeglossaries
\glossarystyle{mylist}
\begin{document} 

In this chapter we introduce \gls{latinalph}, \gls{exlatinalph},\gls{set}, and \gls{diamatrix}.

\printglossary[title=Glossario]
\end{document}

1 Answer 1

2

You're using some deprecated commands, so I'm guessing you have an old version of glossaries. If you update to a newer version (at least 4.16), you can use \glsaddstoragekey to add a new key. For example:

\glsaddstoragekey{extendeddescription}{}{\extendeddesc}

This defines a new key extendeddescription that can now be used in \newglossaryentry. The second argument is the default value if the key isn't present. I've just left that blank. The third argument is the name of a new command that you can use to access this value (analogous to commands like \glsentrytext). For example, I've used \extendedesc here, so I would then be able to access the extended description for the latinalph entry using \extendeddesc{latinalph}.

I recommend you also switch off the expansion for this field in case you have any fragile commands:

\glssetnoexpandfield{extendeddescription}

I've updated your glossary style to use the newer style commands and added \extendeddesc{##1} to include the extended description:

\documentclass[a4paper]{book}
\usepackage{lipsum}
\usepackage[xindy,nonumberlist,toc]{glossaries}

\makeglossaries

\glsaddstoragekey{extendeddescription}{}{\extendeddesc}
\glssetnoexpandfield{extendeddescription}

\newglossarystyle{mylist}{%
 \setglossarystyle{treegroup}
 \renewenvironment{theglossary}%
    {\setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt}
     }%
    {}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{%
    \noindent\textbf{\glsgetgrouptitle{##1}}\par\nopagebreak
  }
  \renewcommand{\glossentry}[2]{%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}%
    {\dotfill}\ifglshassymbol{##1}{\space(\glossentrysymbol{##1})}{}%
    \space \glossentrydesc{##1}\glspostdescription \space ##2\par
    \extendeddesc{##1}\par}%
  \renewcommand{\subglossentry}[3]{%
   \parindent##1\glstreeindent\relax
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \glstarget{##2}{\glossentryname{##2}}%
    \ifglshassymbol{##2}{\space(\glossentrysymbol{##2})}{}%
    {\dotfill}
    \glossentrydesc{##2}\indent\glspostdescription\space##3\par
    \extendeddesc{##2}\par}%
  \renewcommand*{\glsgroupskip}{\indexspace}
  \renewcommand*{\glspostdescription}{}
}
\setlength{\glstreeindent}{20pt}

\newglossaryentry{latinalph}
{
name={Alfabeto latino},
description={Latin Alphabet},
}

\newglossaryentry{exlatinalph}
{
name={Esteso alfabeto latino},
description={Extended Latin Alphabet},
parent={latinalph},
extendeddescription={\lipsum[1]}
}

\newglossaryentry{set}
{
name={Impostato},
description={Set},
parent={latinalph}
}

\newglossaryentry{diamatrix}
{
name={Matrice diagonale},
description={Diagonal matrix},
extendeddescription={\lipsum[2]}
}

\setglossarystyle{mylist}
\begin{document} 

In this chapter we introduce \gls{latinalph}, \gls{exlatinalph},\gls{set}, and \gls{diamatrix}.

\printglossary[title=Glossario]
\end{document}

The glossary now looks like:

image of glossary including extended descriptions

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .