3

Suppose I want to write a report that discusses some topic from the viewpoint of two subject areas. Those subject areas both use certain field-specific terminologies which might use different terms for analogous concepts, the same term for different concepts, and the like. I would like to compile some "shared" glossary or ontology which collects those terms and their explanations.

As an example, we could talk about trains and planes and generate a list like the following:

Trains           | Explanation                                  | Planes
------------------------------------------------------------------------
Train            | A means of mass transportation that is       | Plane
                 | steered by a train driver/pilot              |
------------------------------------------------------------------------
Train driver     | The person who steers a train/plane          | Pilot
------------------------------------------------------------------------
Passenger        | A person travelling in a train/plane without | Passenger
                 | steering it themselves                       |
------------------------------------------------------------------------
Platform         | The place where a train/plane stops to let   | Gate
                 | passengers enter and exit                    |
------------------------------------------------------------------------
...

I would like to be able to reference the terms from both fields within my report, i.e. if I write something like \term{Plane} or \term{Train}, it should point link to the same row in my table. By that it differs from solutions for bilingual glossaries, where you typically use only one term and have the term in another language just for reference in the glossary and possibly when mentioning the term for the first time.

Also, the allocation should work both ways, i.e. no matter whether the reader looks up "Plane" or "Train", they should see how respective term in the other field. The use case of that is, that a reader who is familiar with only one field of expertise will typically only have to look up terms from their unfamiliar field. They can should then immediately be able to see how this term relates to their own field or that there is no analogous concept. Since the report shall be worked on and read by experts from both fields, this allocation should also work in both directions. The alias example from here is an example of how it should not work, since there is only a reference in one direction, for example from Latin "Hercules" to Greek "Herakles" but not back again.

And of course, I would prefer to not be forced to do the selection and sorting of the relevant items myself.

My intution says that this could be a case for the glossaries package. However, I don't have a clue how to tackle it or whether there might be another or better package for that. So any hint would be very welcome!

  • Do you mean something like this alias example? – Nicola Talbot Jul 13 '17 at 13:57
  • @NicolaTalbot Well, not really. The alias example is a bit of a one-way street, i.e. if I look up Hercules in the example, I am pointed to the greek Herakles. If I however look up Herakles, I do not get the information, that there is a Latin adaption of the name. I will edit this into my question. – Benedikt Bauer Jul 14 '17 at 7:30
  • Okay. Sorry I misunderstood. I think perhaps it might be best to just have one entry with user defined keys. I'll see if I can sort out an example. – Nicola Talbot Jul 14 '17 at 10:03
2

I think the simplest thing to do is to have a plane key for the term relating to planes. The train term is stored in the name field:

\documentclass{article}

\usepackage{array}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries

\glsaddkey
 {plane}% new key name
 {}% default value if key not provided
 {\entryplane}% no link command
 {\Entryplane}% no link command with first letter changed to upper case
 {\plane}% link command
 {\Plane}% link command with first letter changed to uppercase
 {\PLANE}% link command with all caps

\newglossaryentry
{vehicle}% label
{name={train},% train
 plane={plane},% plane
 description={A means of mass transportation that is
  steered by a train driver/pilot}
}

\newglossaryentry
{driver}% label
{name={train driver},% train
 plane={pilot},% plane
 description={The person who steers a train/plane}
}

\newglossaryentry
{passenger}% label
{name={passenger},% train
 plane={passenger},% plane
 description={A person travelling in a train/plane without
  steering it themselves}
}

\newglossaryentry
{embark}% label
{name={platform},% train
 plane={gate},% plane
 description={The place where a train/plane stops to let
  passengers enter and exit}
}

\newglossarystyle{shared}%
{%
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{0.5\linewidth}l}}%
    {\end{longtable}}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\Glossentryname{##1}} &
    \glossentrydesc{##1} & \Entryplane{##1}\tabularnewline
  }%
  \renewcommand{\subglossentry}[1]{\glossentry}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Trains&\bfseries Explanation&
    \bfseries Planes\tabularnewline\endhead}%
}

\begin{document}
Trains: \gls{vehicle}, \gls{driver}, \gls{passenger}, \gls{embark}.

Planes: \plane{vehicle}, \plane{driver}, \plane{passenger}, \plane{embark}.

\printglossary[style=shared]
\end{document}

The build process is latex (or pdflatex or xelatex or lualatex as appropriate) makeglossaries (or makeglossaries-lite) latex.

This sorts according to the name field since the sort field is missing.

image of document

Here's a version that has a generic term in the name field with an extra key for the train term:

\documentclass{article}

\usepackage{array}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries

\glsaddkey
 {plane}% new key name
 {}% default value if key not provided
 {\entryplane}% no link command
 {\Entryplane}% no link command with first letter changed to upper case
 {\plane}% link command
 {\Plane}% link command with first letter changed to uppercase
 {\PLANE}% link command with all caps

\glsaddkey
 {train}% new key name
 {}% default value if key not provided
 {\entrytrain}% no link command
 {\Entrytrain}% no link command with first letter changed to upper case
 {\train}% link command
 {\Train}% link command with first letter changed to uppercase
 {\TRAIN}% link command with all caps

\newglossaryentry
{vehicle}% label
{name={vehicle},% generic
 train={train},% train
 plane={plane},% plane
 description={A means of mass transportation that is
  steered by a train driver/pilot}
}

\newglossaryentry
{driver}% label
{name={driver},% generic
 train={train driver},% train
 plane={pilot},% plane
 description={The person who steers a train/plane}
}

\newglossaryentry
{passenger}% label
{name={passenger},% generic
 train={passenger},% train
 plane={passenger},% plane
 description={A person travelling in a train/plane without
  steering it themselves}
}

\newglossaryentry
{embark}% label
{name={embarkation point},% generic
 train={platform},% train
 plane={gate},% plane
 description={The place where a train/plane stops to let
  passengers enter and exit}
}

\newglossarystyle{shared}%
{%
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{0.5\linewidth}ll}}%
    {\end{longtable}}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\Glossentryname{##1}} &
    \glossentrydesc{##1} & \Entrytrain{##1} & \Entryplane{##1}\tabularnewline
  }%
  \renewcommand{\subglossentry}[1]{\glossentry}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Generic&\bfseries Explanation&\bfseries Trains&
    \bfseries Planes\tabularnewline\endhead}%
}

\begin{document}
Generic: \gls{vehicle}, \gls{driver}, \gls{passenger}, \gls{embark}.

Trains: \train{vehicle}, \train{driver}, \train{passenger}, \train{embark}.

Planes: \plane{vehicle}, \plane{driver}, \plane{passenger}, \plane{embark}.

\printglossary[style=shared]
\end{document}

This is now sorted by the generic term:

image of document

You can extend this with other keys as well, for example if you want to add a maritime version. Just make sure that the name key is used for the term that governs the sorting otherwise you'll need to set the sort key as well.

  • Thanks a lot! Just one more question: would it be possible to add an abbreviation to both the train and the plane terms? – Benedikt Bauer Jul 17 '17 at 9:52
  • @BenediktBauer It should be possible. Could you give some example abbreviations. Do you want them to expand on first use? Do they need to appear in the glossary? Is the abbreviation the same for train and plane or are there separate train and plane abbreviations? – Nicola Talbot Jul 22 '17 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.