# modifying code for sorting ABBREVIATIONS in Thesis.cls

I am using Easy Thesis template from Sharelatex. This template uses Thesis.cls which contains code for ABBREVIATIONS. The code is shown below:

%VJ START (ABBREVIATIONS)
\newcommand\listabbrename{List Of Abbreviations}    % title "List Of Abbreviations" printed in "LIST OF ABBREVIATIONS"
\usepackage{longtable}
\newcommand\listofabbre [2]{
\btypeout{\listabbrename}
\chapter*{\listabbrename
\@mkboth{
\MakeUppercase\listabbrename}{\MakeUppercase\listabbrename}   }
\begin{longtable}[l]{#1}#2\end{longtable}\par
\cleardoublepage
}
%VJ END (ABBREVIATIONS)


I get some idea from a post by Ivan at (Modifying existing code to sort a list of abbreviations) using glossaries package to get the abbreviations to sort in order. I feel his way is much easier. So I tried to modified the existing code in Thesis.cls incorporating Ivan's code. I tried to generate compilable code for testing purpose and the code is below:

\documentclass[a4paper, 12pt]{../Thesis}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

%start section in Thesis.cls%
\usepackage{longtable}
\usepackage[acronym,nonumberlist,shortcuts]{glossaries}
\glossarystyle{long}
\renewcommand*{\acronymname}{List of Abbreviations} % rename title
\renewcommand*{\glspostdescription}{}                    % remove dot at the end of description
\makeglossaries

%\newcommand\setacronymdb[1]{\loadglsentries{#1}}         % the name of the acronym database

\newcommand\listofnomenclature[2]{

\btypeout{\acronymname}
\chapter*{\acronymname
\@mkboth{
\MakeUppercase\acronymname}{\MakeUppercase\acronymname}   }
\begin{longtable}[l]{#1}#2\end{longtable}\par

\printglossaries
\par
\cleardoublepage
}
%end section in Thesis.cls%

%\setacronymdb{Abbrev}

\begin{document}

%\listofnomenclature
\input{../Frontpages/Abbrev.tex}

\section{Introduction}
This is how I refer to the samples of acronym in the database named Abbrev: \acs{CO2}.

\end{document}


The Abbrev.tex file contains:

%\clearpage
\pagestyle{fancy} % The page style headers have been "empty" all this time,
% now use the "fancy" headers as defined before
\setstretch{1.3} % Set the line spacing to 1.5,
% this makes the following tables easier to read

%\listofabbrenamesvj{l l}

\listofnomenclature{l r}
{

\newacronym{CO2}{CO$_{2}$}{Carbon diOxide}
\newacronym{GSM}{GSM}{Global System for Mobile Communications}

}


This time I can compile this code using my "Thesis.cls" but the output format of TOC and title is not as I wanted.

I hope to get some help here. Many thanks in advance.

• unrelated advice from my side: Delete the whole thing and start from scratch. The template is bad. – Johannes_B Jan 8 '15 at 8:22
• Can you extend the code into a compilable test case? – Johannes_B Jan 8 '15 at 8:25
• Dear Johannes_B, I have added the compilable test case for clarity. – Vijay Jan 9 '15 at 4:20

As i already pointed out in the comments, Thesis.cls is a very very bad template. Unfortunately, it is not the only one provided by the website.

Just as Ivan mentioned in the other question, you need to use a package that automates sorting and everything related. glossaries can do the job wonderfully. Thesis declares an environment you have to sort and fill yourself. glossaries gives you some useful commands to use in your text as well. One thing you have to remeber is running the helper script makeglossaries as described in the documentation.

\documentclass[a4paper, 12pt]{Thesis}
\usepackage{chemformula}
\usepackage[acronym,nonumberlist,shortcuts]{glossaries}
\glossarystyle{long}
\renewcommand*{\acronymname}{List of Abbreviations}
\renewcommand*{\glspostdescription}{}
\makeglossaries

\newacronym{hdd}{HDD}{Hard-disk drive}
\newacronym{CO2}{\ch{CO2}}{Carbon diOxide}
\newacronym{GSM}{GSM}{Global System for Mobile Communications}
\begin{document}
\printacronyms

\section{Introduction}
This is how I refer to the samples of
acronym in the database named Abbrev:
\acs{CO2}. The \acs{GSM} is not the same as a \acs{hdd}

\end{document}


Please note that i used package chemformula to typeset chemical structures. It has a very nice and clean interface and is easy to use. Another package to print acronyms is package acro. It has an interface just as easy to as as that of chemformula, which isn't much of a surprise as the author is the same guy. Advantage: You don't need an extra helper program.

The default appearance differs from that of glossaries. You can change the appearance using options or define some helper commands.

\documentclass[a4paper, 12pt]{book}%Thesis is based on book
\usepackage{chemformula}
\usepackage{acro}
\DeclareAcronym{hdd}{short=HDD,long=Hard-disc drive}
\DeclareAcronym{co2}{short=\ch{CO2},long=carbon dioxide}
\DeclareAcronym{tug}{short=TUG,long=\TeX{} User Group}
\begin{document}
\printacronyms

\section{Introduction}
This is how I refer to the samples of
acronym in the database named Abbrev:
\ac{co2}. The \ac{tug} is not the same as a \ac{hdd}

\end{document}


To sum it up: When starting up a project, you need to decide for either glossaries or acro (there are a few more, but really, does are the two yo can safely work with).
acro handles acronyms, glossaries can do a whole bunch of other things as well. If you are consistently using the interface commands within your text, you will get a nice, clean and failsafe result.

If however, your document is finished and you decide to add some terms in a list to form a list of Acronyms you should use a simple LaTeX environment. Use a list or a table. If you have 20 entries you can sort them by hand; 50 sort them by hand. If there are a lot of entries, consider using the solution provided in Modifying existing code to sort a list of abbreviations by cgnieder, who (surprise) is the author of chemformula (and other great chemistry related package) and acro.

• Thank you so much for your help. I choose {glossaries} as per your example given above. By the way, appreciate if can align the list left-sided. At the moment the list is looks like being in the middle of the page. Regards. – Vijay Jan 9 '15 at 18:58
• @Vijay I briefly looked at this but couldn't see an obvious fix. I suggest to ask a new question. There can't be enough questions ;-) – Johannes_B Jan 14 '15 at 18:46