Contents
B Glossary
C Acronyms


Below is a short example of what I am doing.

\documentclass[twoside,12pt]{article}
\usepackage[acronym]{glossaries}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{titletoc}

\makeglossaries
\newacronym{cd}{CD}{compact disk}
\newglossaryentry{api}
{
name={API},
plural={APIs},
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},
first={Application Programming Interface (API)},
long={Application Programming Interface}
}

\title{TOC Example}

\begin{document}
\tableofcontents

\startcontents[mainsection]
\lipsum[1]
\gls{cd}
\gls{api}
\stopcontents[mainsection]

\appendix
\startcontents[appendices]
\section*{Appendices}
\lipsum[1]
\printglossaries

\end{document}

• You need to use the toc package option to add the glossaries to the table of contents: \usepackage[acronym,toc]{glossaries} – Nicola Talbot Apr 20 '18 at 12:01
• – Nicola Talbot Apr 20 '18 at 12:02
• I think @NicolaTalbot has a better idea of how to solve this, so I will defer to him on this. – AML Apr 20 '18 at 12:25
• If adding the toc package option provides a solution then this question can be closed as a duplicate of the one I linked to above. (I've got a gold glossaries badge which means if I vote to close this as a duplicate it will instantly be closed, so I'd rather get confirmation before doing that.) – Nicola Talbot Apr 20 '18 at 13:23
• @NicolaTalbot I did try that and whilst you are correct in that it does add the glossaries to the table of contents it doesn't add them with a number which was what I was after. – AeroMaxx Apr 25 '18 at 6:08

As far as I can tell, you are simply labeling the \section{}s incorrectly. If you label them with what you want, then you get the TOC that you desire.

    \documentclass[twoside,12pt]{article}
\usepackage[acronym]{glossaries}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{titletoc}

% Make glossaries
\makeglossaries
\newacronym{cd}{CD}{compact disk}
\newglossaryentry{api}
{
name={API},
plural={APIs},
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},
first={Application Programming Interface (API)},
long={Application Programming Interface}
}

\title{TOC Example}

\begin{document}

\tableofcontents

\startcontents[mainsection]
%\printcontents[mainsection]{l}{1}{\section*{Main Sections}\setcounter{tocdepth}{3}}

\lipsum[1]

\stopcontents[mainsection]

\clearpage

\appendix

\startcontents[appendices]
\section*{Appendices}

\lipsum[1]

\section{Glossary}
\lipsum[1]

\section{Acronyms}
\lipsum[1]

\printglossaries

%----------------------------------------------------------------------------------------

\end{document}


• Could you add some explanation why this is a solution, please? – user31729 Apr 19 '18 at 18:20
• Thanks for replying, but I don't think you understood my question, the \printglossaries prints out the headers for the Acronyms and the Glossaries so with your code I get duplicate headers, one from your section, and then another from the \printglossaries. So the example output you gave is what appears on the table of contents, but the headers are duplicated in the appendix itself. – AeroMaxx Apr 19 '18 at 20:21
• @AeroMaxx You're right, I thought it was just a TOC issue, based on your initial figure. Will work on the other part. – AML Apr 20 '18 at 11:38

I've since worked out what I was wanting to do and the example code below works.

The command \renewcommand*{\glossarysection}[2][]{\section{#1}} rewrites the headings so that they are sections, which then get added to the table of contents and with a number, hope this helps someone!

    \documentclass[twoside,12pt]{article}
\usepackage[acronym]{glossaries}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{titletoc}

% Make glossaries
\makeglossaries
\renewcommand*{\glossarysection}[2][]{\section{#1}}

\newacronym{cd}{CD}{compact disk}
\newglossaryentry{api}
{
name={API},
plural={APIs},
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},
first={Application Programming Interface (API)},
long={Application Programming Interface}
}

\title{TOC Example}

\begin{document}

\tableofcontents

\startcontents[mainsection]

\gls{api}

\stopcontents[mainsection]

\clearpage

\appendix

\startcontents[appendices]
\section*{Appendices}

\lipsum[1]

\printglossaries

\end{document}

• If you want numbered sections, it's simpler just to use the numberedsection package option. Your definition of \glossarysection uses the toctitle setting for both the header and table of contents. This may be okay for your particular use, but it's not a general purpose solution. – Nicola Talbot Apr 25 '18 at 8:14
• @NicolaTalbot I just tried that and I can't seem to tell the difference between them, so I am using your simpler suggestion. – AeroMaxx Apr 25 '18 at 10:37