Generalglossaries | Modifying an existing Style

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
sverd
Posts: 3
Joined: Wed Dec 21, 2011 11:17 pm

glossaries | Modifying an existing Style

Post by sverd »

I'm using glossaries to create a number of symbol lists (one for each chapter) each containing both Greek and Latin symbols. Searching through the fora it seemed to me that using sub-entries was the way to go. Everything is working but the final output could use some styling.

Currently I am using the "alttree" style, which is pretty close to what I want. Only if the symbol part would be placed after the description instead of between the name and the description (this would result in 3 columns: name, description and symbol)
Can this be done?
Last edited by sverd on Thu Dec 29, 2011 10:46 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

skanda
Posts: 28
Joined: Sat May 16, 2009 6:32 pm

glossaries | Modifying an existing Style

Post by skanda »

Are you using the gloss package?

Some examples:

Code: Select all

@GLOSSDEF{gnu,
  word="{\~n}u",
  definition="Simp\'atico animal, mascota de los programadores",
  sort-word="Nzzu"
}

@GLOSSDEF{pi,
  word="$\pi$",
  definition={Constante matem\'atica aproximadamente igual a la 
  versi\'on m\'as reciente de \TeX},
  sort-word=pisort,
  group="S"
}
@GLOSSDEF{alfa,
  word="$\alpha$",
  definition={Primera letra del alfabeto griego},
  sort-word=alphasort,
  group="S"
}
Maybe this ought to solve your problems?

Good Luck,
Skanda.
sverd
Posts: 3
Joined: Wed Dec 21, 2011 11:17 pm

Re: glossaries | Modifying an existing Style

Post by sverd »

Thanks for the response!
I am not using the gloss package but the glossaries package. In the documentation of the glossaries package it is mentioned that should be easy to take an existing glossaries style and modify only parts of it.....although not for me it seems..

I think I should use the sub-entry features of the glossaries package as this makes most sense, but many of the glossaries styles do not take these feature into account. The "alttree" style does and it comes close to what I would like. Hence I was wondering if someone knows how the alttree style can be modified to have the symbol part placed after the description (and get a 3-column tabular-like layout).

If I read the documentation I get the impression that is just one or two lines, but I cannot get it to work ...
sverd
Posts: 3
Joined: Wed Dec 21, 2011 11:17 pm

glossaries | Modifying an existing Style

Post by sverd »

I managed to solve my problem by changing the subentries of the alttree style. Assuming the a symbol is provided and a unit is given in the user1 entry the following seems to deliver what I wanted (although I am not yet sure about multi-line descriptions).........

Code: Select all

% use a modified version of the alttree code => only modify the sub-entry things
% this shows the sub-entries as: symbol    description       user1
% so use the following entries in the input:
%     user1 entry for the units
%     symbol entry for the symbol 
%     description entry for the description
% the name entry is not used at this moment but can be given anyway to act as kind of backup in case no sorting is available
\newglossarystyle{alttreesymbol}{%
\glossarystyle{alttree}% base this style on the list style
  \renewcommand{\glossarysubentryfield}[6]{%
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \ifnum\@gls@prevlevel=##1\relax
    \else
      \@ifundefined{@glswidestname\romannumeral##1}{%
        \settowidth{\gls@tmplen}{\textbf{\@glswidestname\space}}}{%
        \settowidth{\gls@tmplen}{\textbf{%
           \csname @glswidestname\romannumeral##1\endcsname\space}}}%
      \ifnum\@gls@prevlevel<##1\relax
         \setlength\glstreeindent\gls@tmplen
         \addtolength\glstreeindent\parindent
         \parindent\glstreeindent
      \else
         \@ifundefined{@glswidestname\romannumeral\@gls@prevlevel}{%
           \settowidth{\glstreeindent}{\textbf{%
              \@glswidestname\space}}}{%
           \settowidth{\glstreeindent}{\textbf{%
              \csname @glswidestname\romannumeral\@gls@prevlevel
                 \endcsname\space}}}%
         \addtolength\parindent{-\glstreeindent}%
         \setlength\glstreeindent\parindent
      \fi
    \fi
    \hangindent\glstreeindent
    \makebox[0pt][r]{\makebox[\gls@tmplen][l]{%
      \textbf{\glstarget{##2}{##5}}}}%
      \relax\relax
    ##4\glspostdescription\space \hfill{}{\glsentryuseri{##2}}\par
    \def\@gls@prevlevel{##1}%
  }%
}
Maybe this is useful for someone else as well.. :D
Post Reply