3

Sometimes, an article is written in a language other than English, and some essential terms are followed by their English counterparts, and at the end of the article is their a "glossary." Take "Reversed-English", a fictional language, for example:

The output of the example.

Which is yielded by the following LaTeX source:

\documentclass{article}

\begin{document}

\section{Noitcudortni}
Siht elcitra si nettirw ni \textbf{desrever Hsilgne} (reversed English).
\(0\) si a \textbf{larutan rebmun} (natural number).

\section*{Yrassolg}

\noindent \textbf{desrever Hsilgne} Reversed English.

\noindent \textbf{larutan rebmun} Natural number.

\end{document}

In the glossary, I manually listed the terms, which is time-consuming, error-prone and can easily get out of date. How can I automate this process? Can I just write something like \term{desrever Hsilgne}{reversed English} in the text for \textbf{desrever Hsilgne} (English) and the word automatically appear in the glossary?

The following is ideal for me, but I need your help for the \term and \MakeGlossaryContent macros:

\documentclass{article}

\begin{document}

\section{Noitcudortni}
Siht elcitra si nettirw ni \term{desrever Hsilgne}{reversed English}.
\(0\) si a \term{larutan rebmun}{natural number}.

\MakeGlossaryContents

\end{document}

Any help is appreciated.

1 Answer 1

2

You (in this case, I) can use the glossaries package or the glossaries-extra package:

\documentclass{article}

\usepackage[automake]{glossaries-extra}

\makeglossaries

% Automate the process
\newcommand*{\newentry}[4]{%
    \newglossaryentry{#1}%
    {%
        name = {#2},%
        first = {\textbf{#2} (#3)},%
        description = {#4}%
    }%
}

\newentry{reversed-english}
    {Desrever Hsilgne}  % name
    {reversed English}  % first use description in parentheses
    {Reversed English.} % description in glossary

\newentry{natural-number}
    {larutan rebmun}
    {natural number}
    {Natural number.}

\begin{document}

\section{Noitcudortni}

Siht elcitra si nettirw ni \gls{reversed-english}.
\(0\) si a \gls{natural-number}.

\printglossary[title = {Yrassolg}]

\end{document}

resulting in:

enter image description here

You must log in to answer this question.

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