# Makeindex-style for list of acronyms (glossaries)

I'm a LaTeX newbie using this example provieded by Tom Brien to combine some of my acronyms with their glossaries-entries. I would like to change the style of the acronyms-list to make it looks like this:

I tried to change the style using this command:

\printglossary[type=\acronymtype,style=long3col]


Now my list looks like this:

Here is the code:

\documentclass{article}
\usepackage{hyperref}
\usepackage[acronym]{glossaries}
\makeglossaries

%%% The glossary entry the acronym links to
\newglossaryentry{apig}{name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and
make use of the services and resources provided by another particular software
program that implements that API}}

%%% define the acronym and use the see= option
\newglossaryentry{api}{type=\acronymtype, name={API}, description={Application
Programming Interface}, first={Application
\begin{document}
\noindent
First use \gls{api}\\
subsequent \gls{api}
\newpage

\printglossary[type=\acronymtype,style=long3col]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]

\end{document}


What have I to change in the code to make it looks like in picture above?

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Thruston Mar 28 '15 at 17:01
• ok I added the code above :-) – Mario90 Mar 29 '15 at 13:56

The see key always puts the cross-reference at the end of the location list, so I think it's better to move the cross-reference into the end of the description, like this:

\documentclass{article}
\usepackage[acronym]{glossaries}
\makeglossaries

\newglossarystyle{longdotted}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription\dotfill ##2\tabularnewline
}%
}

\setlength{\glsdescwidth}{0.85\hsize}

%%% The glossary entry the acronym links to
\newglossaryentry{apig}{name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and
make use of the services and resources provided by another particular software
program that implements that API}}

%%% define the acronym and use the see= option
\newglossaryentry{api}{type=\acronymtype, name={API}, description={Application
Programming Interface \emph{Glossary:} \glsname{apig}}, first={Application
\begin{document}
\noindent
First use \gls{api}\\
subsequent \gls{api}
\newpage

\printglossary[type=\acronymtype,style=longdotted]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]

\end{document}


This looks like:

You may need to change the value of \glsdescwidth.

Another possibility is to use the extension package glossaries-extra, which stores the value of the see key. (The base glossaries package doesn't do this. There the see key simply triggers \glssee.) The see value can be accessed with \glsxtrusesee{label}, so the glossary style can be adapted so that it places the cross-reference in the desired place. For example:

\newglossarystyle{longdotted}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription
\dotfill ##2\tabularnewline
}%
}


The only problem now is to prevent the automatic \glssee that occurs when the see field is detected when entries are defined. There are two ways to do this.

The first method requires glossaries-extra v1.16, which is new and so may not be available. This version provides the autoseeindex package option, which governs the automatic use of \glssee. The option autoseeindex=false has the side-effect of not switching on the indexcrossrefs option, so that needs to be done explicitly:

\usepackage[acronym,
autoseeindex=false,% store see key but don't automatically add to location list
indexcrossrefs% index the cross-referenced terms
]{glossaries-extra}


Complete example:

\documentclass{article}
\usepackage[acronym,
autoseeindex=false,% store see key but don't automatically add to location list
indexcrossrefs% index the cross-referenced terms
]{glossaries-extra}
\makeglossaries

\newglossarystyle{longdotted}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription
\dotfill ##2\tabularnewline
}%
}

\setlength{\glsdescwidth}{0.85\hsize}

%%% The glossary entry the acronym links to
\newglossaryentry{apig}{name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and
make use of the services and resources provided by another particular software
program that implements that API}}

%%% define the acronym and use the see= option
\newglossaryentry{api}{type=\acronymtype,
name={API},
see=[Glossary:]{apig},
description={Application Programming Interface},
first={Application Programming Interface (API)}}

\begin{document}
\noindent
First use \gls{api}\\
subsequent \gls{api}
\newpage

\printglossary[type=\acronymtype,style=longdotted]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]

\end{document}


The second method is to put \makeglossaries after the entry definitions. This command opens the external glossary files ready for indexing. Any indexing that occurs before that command can't be implemented as the appropriate file isn't open. Since this isn't usually desired, the glossaries package will produce an error if see is used before \makeglossaries. This error can be turned to a warning with the package option seenoindex=warn or simply ignored with seenoindex=ignore. (This option was new to glossaries v4.24):

Complete example:

\documentclass{article}
\usepackage[acronym,
seenoindex=ignore% ignore 'see' key occurring before \makeglossaries
]{glossaries-extra}

\newglossarystyle{longdotted}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1}\glspostdescription
\dotfill ##2\tabularnewline
}%
}

\setlength{\glsdescwidth}{0.85\hsize}

%%% The glossary entry the acronym links to
\newglossaryentry{apig}{name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and
make use of the services and resources provided by another particular software
program that implements that API}}

%%% define the acronym and use the see= option
\newglossaryentry{api}{type=\acronymtype,
name={API},
see=[Glossary:]{apig},
description={Application Programming Interface},
first={Application Programming Interface (API)}}

\makeglossaries % open external files for indexing

\begin{document}
\noindent
First use \gls{api}\\
subsequent \gls{api}
\newpage

\printglossary[type=\acronymtype,style=longdotted]
%%% \newpage just to demonstrate that links are correct
\newpage
\printglossary[type=main]

\end{document}


There's a further modification that can be made. At the moment, the tag Glossary: needs to be added to each instance of the see key (as in see=[Glossary:]{apig}). If this needs to be done for every entry in the acronym glossary, then it would be more convenient so set this tag in the cross-reference format. With the base glossaries package, there are two ways of doing this: redefined \seename or redefine \glsseeformat. I don't recommend the former as this will cause a problem if the document also needs an index.

\glsseeformat has an optional argument which is the tag, and is defined as:

\DeclareRobustCommand*{\glsseeformat}[3][\seename]{%
\emph{#1} \glsseelist{#2}}


It's rarely used without the optional argument and see={apig} will end up as \glsseeformat[\seename]{apig}{}, so the altered version will need the tag explicitly in the definition:

\renewrobustcmd*{\glsseeformat}[3][\seename]{%
\emph{Glossary:} \glsseelist{#2}}


(or add a test for \seename as #1).

If you have glossaries-extra v1.16, there's another alternative and that's to use the seealso key instead of the see key. The seealso key doesn't allow the optional tag part at the start of the cross-reference label list. The associated formatting is \glsxtruseseealsoformat which is defined as:

\newcommand*{\glsxtruseseealsoformat}[1]{%
\glsseeformat[\seealsoname]{#1}{}%
}


This can be redefined to use your custom tag:

\renewcommand*{\glsxtruseseealsoformat}[1]{%
\glsseeformat[Glossary:]{#1}{}%
}


Any other cross-references that shouldn't have this tag can then be performed as normal with the see key.