2

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
2

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.