[Tex/LaTex] Formatting of heading ‘Glossary” to match chapter and index heading

glossariessectioning

Earlier I asked a question to match the heading of List of Acronyms and Symbols to that of List of table (instead of chapter heading). That was solved by Nicola via Formatting of heading List of Acronyms and list of tables glossaries package link. However, now it is kind of reverse problem that my Glossary heading has the same style as List of Symbols etc but I want it to be same as my chapter and index heading (smaller and centered) as it comes at the end. I am attaching a MWE which also reflects the code sent by Nicola to solve my earlier problem. I hope it is humanly possible to do that 🙂

\documentclass[12pt]{report}
%%%%%%%%%%%%%% For page header/footer  
\usepackage{fancyhdr}
\pagestyle{fancyplain} 
\fancyhf{}
\setlength{\headheight}{15pt}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\lhead{\bfseries{\rightmark}}
\rhead{\bfseries{\thepage}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{makeidx}
\usepackage{sectsty}
\allsectionsfont{\bfseries}
\chapterfont{\centering\Large} 
\sectionfont{\normalsize}
\subsectionfont{\normalsize}
\usepackage[subfigure]{tocloft}
\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{7em}
\newcommand*\updatechaptername{%
\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{Appendix }}
}
\makeindex
\usepackage[nogroupskip,nonumberlist,acronym]{glossaries} 
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols}
\makeglossaries  
% Code provided by Nicola Talbot to make heading of  List of Acronyms and
% List of Symbols same as heading of List of Tables. 
\renewcommand{\glossarysection}[2][\theglstoctitle]{%
  \def\theglstoctitle{#2}%
  \vspace{\cftbeforelottitleskip}%
  \par\noindent
  {\cftlottitlefont #2}{\cftafterlottitle}%
  \vskip\cftafterlottitleskip
}
% % % % % % % % % % % % Glossary Entries  % % % % % % % % % % % % 
\newacronym{sa}{SA}{sample acronym}
\newglossaryentry{Pi}{
name=$\pi$,
description={A mathematical constant whose value is the ratio of any circle's circumference to its diameter.},
sort=symbpi, type=symbolslist
}
\newglossaryentry{glos:ia}{
name=Integer Ambiguity,
description={The unknown number of whole carrier phase cycles between the user and the satellite at the start of tracking (Sometimes ambiguity for short).} 
}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\usepackage{subfigure}
\begin{document}
\tableofcontents
\clearpage
\listoftables
\clearpage
\printglossary[type=\acronymtype,style=long,title=List of Acronyms \& Initialisms]
\clearpage
\printglossary[type=symbolslist,style=long] %Print list of symbols
\include{Sample}
\chapter{Sample}
This is my \gls{sa} and I can use it again. This is a symbol \gls{Pi}. This document\index{document} also has an index\index{index}.
\begin{table}
 \caption{Sample Table}
\end{table}
\updatechaptername
\clearpage
\glsaddall
\printglossary[] % Print list of symbols
\clearpage
\printindex
\end{document}

Best Answer

You just need to redefine \glossarysection again before the final \printglossary so that it now uses \chapter*:

\documentclass[12pt]{report}

\usepackage{makeidx}
\usepackage{sectsty}

\allsectionsfont{\bfseries}
\chapterfont{\centering\Large} 
\sectionfont{\normalsize}
\subsectionfont{\normalsize}

\usepackage[subfigure]{tocloft}
\usepackage{tocloft}

\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{7em}
\newcommand*\updatechaptername{%
\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{Appendix }}
}
\makeindex
\usepackage[nogroupskip,nonumberlist,acronym]{glossaries} 
\newglossary[slg]{symbolslist}{syi}{syg}{List of Symbols}
\makeglossaries  

% section heading for glossaries in the front matter:

\renewcommand{\glossarysection}[2][\theglstoctitle]{%
  \def\theglstoctitle{#2}%
  \vspace{\cftbeforelottitleskip}%
  \par\noindent
  {\cftlottitlefont #2}{\cftafterlottitle}%
  \vskip\cftafterlottitleskip
}

% % % % % % % % % % % % Glossary Entries  % % % % % % % % % % % % 
\newacronym{sa}{SA}{sample acronym}
\newglossaryentry{Pi}{
name=$\pi$,
description={A mathematical constant whose value is the ratio of any circle's circumference to its diameter.},
sort=symbpi, type=symbolslist
}
\newglossaryentry{glos:ia}{
name=Integer Ambiguity,
description={The unknown number of whole carrier phase cycles between the user and the satellite at the start of tracking (Sometimes ambiguity for short).} 
}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\usepackage{subfigure}

\begin{document}
\tableofcontents
\clearpage
\listoftables
\clearpage
\printglossary[type=\acronymtype,style=long,title=List of Acronyms \& Initialisms]
\clearpage
\printglossary[type=symbolslist,style=long] %Print list of symbols

\chapter{Sample}
This is my \gls{sa} and I can use it again. This is a symbol \gls{Pi}. This document\index{document} also has an index\index{index}.
\begin{table}
 \caption{Sample Table}
\end{table}
\updatechaptername
\clearpage
\glsaddall

% redefine glossary section heading

\renewcommand{\glossarysection}[2][]{\chapter*{#1}}

\printglossary[] % Print list of symbols
\clearpage
\printindex
\end{document}

This produces:

Image of glossary

(You might want to use the nopostdot package option to suppress the redundant final full stop.)

If you also want to add the glossary to the table of contents you need to adjust the code to include \addcontentsline:

\renewcommand{\glossarysection}[2][\theglstoctitle]{%
 \def\theglstoctitle{#2}%
 \chapter*{#2}%
 \addcontentsline{toc}{chapter}{#1}%
}

or

\renewcommand{\glossarysection}[2][\theglstoctitle]{%
 \def\theglstoctitle{#2}%
 \chapter*{#2}%
 \addcontentsline{toc}{chapter}{\numberline{}#1}%
}

To update the page headers, you can use \markboth. For example:

\renewcommand{\glossarysection}[2][\theglstoctitle]{%
 \def\theglstoctitle{#2}%
 \chapter*{#2}%
 \addcontentsline{toc}{chapter}{\numberline{}#1}%
 \markboth{#1}{#1}%
}

or (for upper case headings):

\renewcommand{\glossarysection}[2][\theglstoctitle]{%
 \def\theglstoctitle{#2}%
 \chapter*{#2}%
 \addcontentsline{toc}{chapter}{\numberline{}#1}%
 \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
}

Edit:

Presumably at this point in the document you don't have any more numbered chapters. In which case, the easiest solution may be to just use \chapter instead of \chapter* but suppress the numbering by changing the secnumdepth counter. This will ensure the glossary behaves in the same way as your other chapters. For example:

\renewcommand{\glossarysection}[2][\theglstoctitle]{%
  \def\theglstoctitle{#2}%
  \setcounter{secnumdepth}{-1}%
  \chapter[#1]{#2}%
}
Related Question