Skip to content

Instantly share code, notes, and snippets.

@iverasp
Last active September 3, 2022 12:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iverasp/fd39eabc7a779672721fc3654acfd861 to your computer and use it in GitHub Desktop.
Save iverasp/fd39eabc7a779672721fc3654acfd861 to your computer and use it in GitHub Desktop.
LaTeX automatically sorted list of abbreviations
\section{List of abbreviations}
\DTLnewdb{acronyms}
\addacronym{sps}{Samples Per Second}
\addacronym{IMU}{Inertial Measurement Unit}
\addacronym{SoC}{System on Chip}
\addacronym{DMP}{Digital Motion Processor}
\addacronym{DSP}{Digital Signal Processor}
\addacronym{QFN}{Quad Flat No-leads}
\addacronym{LED}{Light-Emitting Diode}
\addacronym{GPIO}{General Purpose Input/Output}
\addacronym{MEMS}{Microelectromechanical system}
\addacronym{DoF}{Degrees of Freedom}
\addacronym{CPU}{Central Processing Unit}
\addacronym{FBX}{Filmbox (file format)}
\addacronym{IoT}{Internet of Things}
\addacronym{SDK}{Software Development Kit}
\addacronym{HAL}{Hardware Abstraction Layer}
\addacronym{UUID}{Universally Unique Identifier}
\addacronym{OS}{Operating System}
\addacronym{IDE}{Integrated Development Environment}
\addacronym{TI}{Texas Instruments}
\addacronym{HID}{Human Interface Device}
% Sort the database
\DTLsort*{Acronym}{acronyms}
% Display the contents of the database
\begin{abbreviations}
\DTLforeach*{acronyms}{\thisAcronym=Acronym,\thisDesc=Description}%
{\item[\thisAcronym] \thisDesc}%
\end{abbreviations}
% formatting taken from http://tex.stackexchange.com/questions/149708/simple-list-of-abbreviations-manually
% sorting taken from http://www.latex-community.org/forum/viewtopic.php?f=44&t=16419
\usepackage{datatool}
% Define a convenient command to add a line
% to the database
\newcommand*{\addacronym}[2]{%
\DTLnewrow{acronyms}%
\DTLnewdbentry{acronyms}{Acronym}{#1}%
\DTLnewdbentry{acronyms}{Description}{#2}%
}
% formatting
\newcommand{\tocfill}{\cleaders\hbox{$\m@th \mkern\@dotsep mu . \mkern\@dotsep mu$}\hfill}
\newcommand{\abbrlabel}[1]{\makebox[3cm][l]{\textbf{#1}\ \tocfill}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}%
\setlength{\labelwidth}{3cm}\setlength{\leftmargin}{\labelwidth+\labelsep}%
\setlength{\itemsep}{0pt}}}{\end{list}}
@Jenna-Lam
Copy link

Hi,
I am new latex but thank you for sharing. This is very useful for my thesis! Although it does compile but I do get errors with using this code. Apparently there is a missing number, treated as zero in line 29 and illegal unit of measure (pt inserted) in line 31 of abbreviations.tex. Also the '+' in line 17 of config.tex "\setlength{\labelwidth}{3cm}\setlength{\leftmargin}{\labelwidth+\labelsep}%" adds a plus to the list but removing the plus fixes the problem. Would you be able to have a look into this when you have time? Hopefully I will be able to help too but since I am new the errors are hard to understand. Thank you :)

@Marmous
Copy link

Marmous commented Jul 20, 2021

Hi,
I am new latex but thank you for sharing. This is very useful for my thesis! Although it does compile but I do get errors with using this code. Apparently there is a missing number, treated as zero in line 29 and illegal unit of measure (pt inserted) in line 31 of abbreviations.tex. Also the '+' in line 17 of config.tex "\setlength{\labelwidth}{3cm}\setlength{\leftmargin}{\labelwidth+\labelsep}%" adds a plus to the list but removing the plus fixes the problem. Would you be able to have a look into this when you have time? Hopefully I will be able to help too but since I am new the errors are hard to understand. Thank you :)

@Jenna-Lam

Some issues (such as "@" ones) can come from inserting the code directly into the tex files. Converting abbreviations.tex into a .sty file (latex package) solves them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment