3

How can one define his/her own glossary style.

I am looking for a set of commands (for instance):

\printitem{name}{description}{...}
\printoffsetcharacter{character}

That one can redefine and thus typeset the glossary him/herself.


MWE:

Say I have a glossary:

\documentclass{article}
\usepackage{glossaries}
\newglossaryentry{computer}{
    name=computer,
    description={is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format}
}
\begin{document}
\glsaddall
\printglossaries
\end{document}

Will print something like:

Computer is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format, 1.

Say I want to modify this such that the name is in italic, there should be a command like:

\renewcommand{\printitem}[2]{\emph{#1}: #2}

When some kind of group-style is used, another command should be redefined that prints the first character:

\renewcommand{\printoffsetcharacter}[1]{\textbf{#1}}

resulting in:

C

Computer: is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format

  • 1
    I have no idea what you are asking ;). No MWE. No indication of what the commands should do. No anything. As stated, the only answer I can think of to your question would be \newcommand\printitem[3]{#1 #2 #3} \newcommand\printoffsetcharacter[1]{#1} since that gives you the commands and you are now free to redefine them and typeset whatever you wish with them yourself, even a glossary. Probably not what you had in mind but a regrettable lack of ESP makes what you had in mind sadly inaccessible to me... – cfr Apr 05 '14 at 21:04
  • Do you mean you want to define your own glossary mechanism yourself from scratch or are you asking for a package that allows you to create a glossary? – Nicola Talbot Apr 05 '14 at 21:10
  • I've provided a MWE. – willeM_ Van Onsem Apr 09 '14 at 19:27
  • Maybe this answer solve your question: http://tex.stackexchange.com/a/8951/31034 –  Apr 09 '14 at 19:39

1 Answers1

5

Changing the glossary style is described in the Defining your own glossary style section of the user manual. You can define a new style that's based on an existing style and use that. For example:

\documentclass{article}

\usepackage{glossaries}

\makeglossaries

\newglossaryentry{computer}{
    name=computer,
    description={is a programmable machine that receives input,
stores and manipulates data, and provides output in a useful format}
}

\newglossarystyle{mystyle}{%
 \setglossarystyle{treegroup}%
 \renewcommand*{\glossentry}[2]{%
   \glsentryitem{##1}\textit{\glstarget{##1}{\glossentryname{##1}}}%
   :\space \glossentrydesc{##1}\par
 }%
}

\setglossarystyle{mystyle}

\begin{document}

\glsaddall
\printglossaries

\end{document}

This produces:

Image of resulting glossary

Nicola Talbot
  • 41,153