0

Continuing

https://tex.stackexchange.com/questions/241636/how-to-typeset-a-cross-referenced-encylopedia

I would like to add extra fields to a \newglossaryentry and typeset it according to my own rules. An extra field is e.g. the type of the word as it would be vt for a transitive verb in an English dictionary.

Add symbol field to \newglossaryentry in \newcommand

does not seem to answer this question. Is the set of fields fixed? What if I want to add more fields?

UPDATE:

example:

enter image description here

here,

  • vt is grammatical type
  • to load is the definition
  • charge a battery is an example of usage, which can be multiple
5
  • 1
    See the command \glsaddkey and sample-newkeys.tex which are documented in glossaries-user.pdf or in the samples directory
    – user31729
    Jul 3, 2015 at 14:23
  • 1
    I think this might be helpful tex.stackexchange.com/questions/244923/… and if you can give a usage example, I might be able to help demonstrate the typesetting of vt in context (not ConTeXt as I haven't used this before) of the definition and usage presentation.
    – EngBIRD
    Jul 4, 2015 at 4:00
  • too late and weekend, I give you an example on Monday
    – Gergely
    Jul 4, 2015 at 19:25
  • Now I see that \newglossarystyle solves my problem.
    – Gergely
    Jul 6, 2015 at 6:03
  • @EngBIRD, I added an example
    – Gergely
    Jul 6, 2015 at 6:20

1 Answer 1

1

My solution to the formatting you describe would be to add two new keys, and create a new custom style based off the existing list template style.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{siunitx,microtype,textcomp,textgreek}
\usepackage[nogroupskip,toc,indexonlyfirst]{glossaries}

%=============================================================================
%   G L O S S A R Y   S E T U P
%=============================================================================

\glsaddkey
{gramType}          % new key
{\relax}        % default value if "unit" isn't used in \newglossaryentry
{\glsentrygramType} % analogous to \glsentrytext
{\GlsentrygramType} % analogous to \Glsentrytext
{\glsgramType}      % analogous to \glstext
{\GlsgramType}      % analogous to \Glstext
{\GLSgramType}      % analogous to \GLStext

\glsaddkey
{example}     % new key
{\relax}            % default value if "dimension" isn't used in \newglossaryentry
{\glsentryexample}      % analogous to \glsentrytext
{\Glsentryexample}      % analogous to \Glsentrytext
{\glsexample}           % analogous to \glstext
{\Glsexample}           % analogous to \Glstext
{\GLSexample}           % analogous to \GLStext

\newglossary[alg]{acronym}{acr}{acn}{List of Acronyms}% if not using the acronyms package option - can declare it myself
\newglossary[dnlg]{enc}{dnt}{dntn}{Cross-Referenced Encyclopaedia}

% please note these should be accompanied by command line calls to makeindex eg (for windows):

% "%MikTexPath%makeindex.exe" -s "main.ist" -t "main.glg"  -o "main.gls"  "main.glo"
% "%MikTexPath%makeindex.exe" -s "main.ist" -t "main.alg"  -o "main.acr"  "main.acn"
% "%MikTexPath%makeindex.exe" -s "main.ist" -t "main.dnlg" -o "main.dnt"  "main.dntn"

%==================================================================================================================================================================

\newglossarystyle{custom_encentry}{%
    \setglossarystyle{list}% base this style on the list style
    \renewcommand*{\glossentry}[2]{%
        \item[\glsentryitem{##1}%
        \glstarget{##1}{\glossentryname{##1}}]
        \textit{\glsentrygramType{##1}}\space : \space \glossentrydesc{##1},\space \glsentryexample{##1} \glspostdescription\space }%
}

%==================================================================================================================================================================



\newglossaryentry{vt}{ type={acronym}, sort={vt},  name={vt}, short={vt}, first={vt}, description={transitive verb} }


\newglossaryentry{charge}{ type={enc}, name={charge}, description={to load is the definition}, example={charge a battery}, gramType={\gls{vt}} }


\makeglossaries
\begin{document}
    \noindent
    Begin document:

     In-text use of the word \gls{charge}

    \printglossary[type=acronym]
    \printglossary[type=enc,style=custom_encentry]

\end{document}

You must log in to answer this question.

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