Here's an example that uses glossaries
:
\documentclass{article}
\usepackage[colorlinks]{hyperref}% optional but if needed must come
% before glossaries.sty
\usepackage[nopostdot]{glossaries}
\makeglossaries
% syntax: \newglossaryentry{label}{options}
\newglossaryentry{CR1}{name={CR1},
description={This is a description of a requirement.}}
% Or
% syntax: \longnewglossaryentry{label}{options}{description}
\longnewglossaryentry{CR2}{name={CR2}}%
{This is a description of another requirement.
With a paragraph break.
}
\begin{document}
\printglossary[title={Requirements}]
\section{Section 1}
This is an activity aligned with CR1.\glsadd{CR1}% index only
This is an activity aligned with \gls{CR2}.% index and show name
\section{Section 2}
This is an activity aligned with \gls{CR1}.% index and show name
\end{document}
Build process (assuming file is called myDoc.tex
):
pdflatex myDoc
makeglossaries myDoc
pdflatex myDoc
makeglossaries
is a Perl script that calls makeindex
with all the required switches set.
Alternatively if you don't have Perl installed, there's a lightweight Lua script:
pdflatex myDoc
makeglossaries-lite myDoc
pdflatex myDoc
Either build process produces:

The red text indicates a hyperlink. The 1
after the description is the page number where the entry was referenced.
With the extension package glossaries-extra
you can suppress the automated indexing on an individual basis with the noindex
option.
\documentclass{article}
\usepackage[colorlinks]{hyperref}% optional but if needed must come
% before glossaries.sty
\usepackage{glossaries-extra}
\makeglossaries
% syntax: \newglossaryentry{label}{options}
\newglossaryentry{CR1}{name={CR1},
description={This is a description of a requirement.}}
% Or
% syntax: \longnewglossaryentry{label}{options}{description}
\longnewglossaryentry{CR2}{name={CR2}}%
{This is a description of another requirement.
With a paragraph break.
}
\begin{document}
\printglossary[title={Requirements}]
\section{Section 1}
This is an activity aligned with CR1.\glsadd{CR1}% index only
This is an activity aligned with \gls{CR2}.% index and show name
\newpage
\section{Section 2}
This is an activity aligned with \gls{CR1}.% index and show name
Some minor reference to \gls[noindex]{CR2} that doesn't need
indexing.
\end{document}
The build process is the same.
You can change the style. For example:
\printglossary[title={Requirements},style=index]
There are plenty of predefined styles to choose.
For future reference, there will at some point soon be another approach using bib2gls
instead of makeglossaries
/ makeglossaries-lite
. I've added it here in case someone finds this question at a later date.
Create a .bib
file called, say requirements.bib
:
@entry{CR1,
name={CR1},
description={This is a description of a requirement.}
}
@entry{CR2,
name={CR2},
description={This is a description of another requirement.
With a paragraph break.}
}
The document myDoc.tex
is now:
\documentclass{article}
\usepackage[colorlinks]{hyperref}% optional but if needed must come
% before glossaries.sty
\usepackage[record]{glossaries-extra}
\GlsXtrLoadResources[src={requirements}]% data in requirements.bib
\begin{document}
\printunsrtglossary[title={Requirements}]
\section{Section 1}
This is an activity aligned with CR1.\glsadd{CR1}% index only
This is an activity aligned with \gls{CR2}.% index and show name
\newpage
\section{Section 2}
This is an activity aligned with \gls{CR1}.% index and show name
Some minor reference to \gls[noindex]{CR2} that doesn't need
indexing.
\end{document}
The build process is:
pdflatex myDoc
bib2gls myDoc
pdflatex myDoc
There's no call to makeindex
as bib2gls
simultaneously fetches and sorts the entries from the .bib
file and collects the locations from the .aux
file.
The differences here are use of the record
option and \GlsXtrLoadResources
. The command \makeglossaries
isn't required and the glossary is now printed with \printunsrtglossary
instead of \printglossary
.
alignment
does not here meanalignment
in the TeX sense.\index
is designed to do or wrappers around index such asglossaries