# Align the glossaries' title to the center

I saw table of contents and figures titles been aligned to the center with tocloft package as follows:

\usepackage{tocloft}
\renewcommand*{\listfigurename}{\hfill\bfseries\Large LISTA DE FIGURAS}
\renewcommand{\cftafterloftitle}{\hfill}


but there isn't a command to center the glossary title.

• Please don't post such fragments only. This depends on the document class too. I think, glossaries is wrong here -- you mean the \listof... title – user31729 Jun 26 '16 at 6:16

tocloft does only hook into ToC, LoF,LoT and the \listof... types that were defined with tocloft's \newlistof command.

The glossaries package uses \printglossary[title=...] to change the optical appearance of the glossary title.

Using \protect\centering\glossaryname works for the book class.

\documentclass{book}

\usepackage{glossaries}

\newglossaryentry{Foo}{name={Foo}, description={A foobar}}

\makeglossaries

\begin{document}
\tableofcontents
\chapter{Foo}
\gls{Foo}

\printglossary[title={\protect\centering\glossaryname}]
\end{document}


Update After the hint by Nicola Talbot it's better to use a redefinition of \glossarysection

\documentclass{book}

\usepackage[toc]{glossaries}

\makeatletter
\renewcommand*{\glossarysection}[2][\@gls@title]{%
\def\@gls@title{#2}%
\ifcsundef{phantomsection}%
{%
\@glossarysection{#1}{\centering#2}%
}%
{%
\@p@glossarysection{#1}{\centering#2}%
}%
\glsglossarymark{\glossarytoctitle}%
}
\makeatother

\newglossaryentry{Foo}{name={Foo}, description={A foobar}}

\makeglossaries

\begin{document}
\tableofcontents
\chapter{Foo}
\gls{Foo}

\printglossary
\end{document}

• Thank you Christian. You're too quick lol. I was still writing a small doc. – Rinaldi Segecin Jun 26 '16 at 6:55
• @RinaldiSegecin: You can use that for the next question then ;-) – user31729 Jun 26 '16 at 6:56
• I think it would be better to redefine \glossarysection rather than putting the formatting commands in the title, otherwise the formatting can end up in the table of contents (if the glossaries toc option is on). – Nicola Talbot Jun 26 '16 at 10:42
• @NicolaTalbot: Thanks, I will update later on – user31729 Jun 26 '16 at 10:47