Use \newacronym
to define abbreviations with the glossaries
package. The glossary.tex
file should look like:
\newacronym{dht}{DHT}{Distributed Hash Table}
\newacronym{mdpi}{MDPI}{Multidisciplinary Digital Publishing Institute}
\newacronym[longplural={Directories of open access journals}]
{doaj}{DOAJ}{Directory of open access journals}
\newacronym{tla}{TLA}{Three letter acronym}
\newacronym{ld}{LD}{linear dichroism}
The document should input this file using just \input
or \loadglsentries
. Fancier inclusion commands, such as \subimport
or \include
, should be avoided.
The document:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[nopostdot,style=super,nonumberlist,toc]{glossaries}
\makeglossaries
\setacronymstyle{long-short}
\input{glossary}% input definitions
\begin{document}
First use: \gls{dht}. Next use: \gls{dht}.
Reset.\glsreset{dht}
First use plural \glspl{dht}. Next use plural: \glspl{dht}.
\printglossary[type=\acronymtype,title={List of Acronyms}]
\end{document}
The document build process (assuming the file is called myDoc.tex
):
pdflatex myDoc
makeglossaries myDoc
pdflatex MyDoc
Or (if you don't have Perl):
pdflatex myDoc
makeglossaries-lite myDoc
pdflatex myDoc
Result:

If you want all defined entries included, even if they haven't been used in the document, add \glsaddallunused
at the end of the document:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[nopostdot,style=super,nonumberlist,toc]{glossaries}
\makeglossaries
\setacronymstyle{long-short}
\input{glossary}% input definitions
\begin{document}
First use: \gls{dht}. Next use: \gls{dht}.
Reset.\glsreset{dht}
First use plural \glspl{dht}. Next use plural: \glspl{dht}.
\printglossary[type=\acronymtype,title={List of Acronyms}]
\glsaddallunused
\end{document}
This produces:

The vertical gaps are caused by a change in letter group. Use nogroupskip
to omit them:
\usepackage[nopostdot,style=super,nonumberlist,toc,nogroupskip]{glossaries}
If you want the entries listed in order of definition, use sort=def
:
\usepackage[nopostdot,style=super,nonumberlist,toc,nogroupskip,sort=def]{glossaries}
If you want to use the glossaries-extra
extension package, you need to replace \setacronymstyle
with \setabbreviationstyle[acronym]
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[style=super,nonumberlist,nogroupskip,sort=def]{glossaries-extra}
\makeglossaries
\setabbreviationstyle[acronym]{long-short}
\input{glossary}% input definitions
\begin{document}
First use: \gls{dht}. Next use: \gls{dht}.
Reset.\glsreset{dht}
First use plural \glspl{dht}. Next use plural: \glspl{dht}.
\printglossary[type=\acronymtype,title={List of Acronyms}]
\glsaddallunused
\end{document}
In this case (all defined entries and in order of definition and nonumberlist
) you can simplify the build process:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[style=super,nogroupskip,sort=none]{glossaries-extra}
\setabbreviationstyle[acronym]{long-short}
\input{glossary}% input definitions
\begin{document}
First use: \gls{dht}. Next use: \gls{dht}.
Reset.\glsreset{dht}
First use plural \glspl{dht}. Next use plural: \glspl{dht}.
\printunsrtglossary[type=\acronymtype,title={List of Acronyms}]
\end{document}
The build process is now just:
pdflatex myDoc
Result:

With glossaries-extra
, you can change \newacronym
to \newabbreviation
, in which case you also need to change \acronymtype
to \glsxtrabbrvtype
and just use \setabbreviationstyle{long-short}
(without the optional argument).
If you have a mixture of some abbreviations with descriptions and some without, the best method is to use glossaries-extra
, which allows multiple abbreviation styles.
For example, use \newacronym
for terms without a description:
\newacronym{dht}{DHT}{Distributed Hash Table}
with the acronym
style set to long-short
:
\setabbreviationstyle[acronym]{long-short}
and use \newabbreviation
for terms with a description:
\newabbreviation[description={description text here}]{tla}{TLA}{Three letter acronym}
and use the long-short-desc
style:
\setabbreviationstyle{long-short-desc}
You might need a different glossary style or split the entries into two glossaries, depending on how they need to be displayed.