Text FormattingCentering The Title of ToC

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Centering The Title of ToC

Post by s.david »

Hello,

I have the following piece of code:

Code: Select all

\documentclass[a4paper,12pt,openany,oneside]{memoir}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\begin{document}
\tableofcontents
\chapter{Test}
\end{document}
I want to center the title TABLE OF CONTENTS. How can I do that? I also want to center all other titles such as LIST OF FIGURES, LIST OF TABLES and LIST OF APPENDICES.

Thanks in advance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Centering The Title of ToC

Post by meho_r »

You may try this:

Code: Select all

\renewcommand{\printtoctitle}{\centering\Huge\bfseries}
Note that when redefining \printtoctitle you have to set other attributes too (in the example I set \Huge and \bfseries). For more infos take a look at Chapter 9. in memoir documentation.
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Centering The Title of ToC

Post by s.david »

meho_r wrote:You may try this:

Code: Select all

\renewcommand{\printtoctitle}{\centering\Huge\bfseries}
Note that when redefining \printtoctitle you have to set other attributes too (in the example I set \Huge and \bfseries). For more infos take a look at Chapter 9. in memoir documentation.
Hello,

Thank you fo replying, but it did not work. I still have the title aligned to the left. Why?

Regards
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Centering The Title of ToC

Post by meho_r »

Strange. On my system (TeXLive 2009), works fine. Here's your code with the additional line from my previous post to test:

Code: Select all

\documentclass[a4paper,12pt,openany,oneside]{memoir}
\renewcommand{\printtoctitle}{\centering\Huge\bfseries}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\begin{document}
\tableofcontents
\chapter{Test}
\end{document}
And in attachment is its output. I tested it with pdflatex and xelatex. Can anyone other test it and confirm if it's working?
Attachments
TOC_test.pdf
Output of the above code.
(19.65 KiB) Downloaded 475 times
Lucia
Posts: 36
Joined: Wed Dec 31, 2008 9:03 pm

Re: Centering The Title of ToC

Post by Lucia »

I just tested the code with that additional line and it's working on my system, too. I have TeXLive 2008.
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Centering The Title of ToC

Post by s.david »

meho_r wrote:Strange. On my system (TeXLive 2009), works fine. Here's your code with the additional line from my previous post to test:

Code: Select all

\documentclass[a4paper,12pt,openany,oneside]{memoir}
\renewcommand{\printtoctitle}{\centering\Huge\bfseries}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\begin{document}
\tableofcontents
\chapter{Test}
\end{document}
And in attachment is its output. I tested it with pdflatex and xelatex. Can anyone other test it and confirm if it's working?
Yes you are right. I am sorry for this. I tried it on my full document where it did not work. As an independent document, it is just fine. In my original document I use something like this:

Code: Select all

\documentclass[a4paper,12pt,openany,oneside]{memoir}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\begin{document}
\chapter*{\contentsname}
\chapter{Test}
\end{document}
It is a long story why I did this. I want to center this chapter title alone, not all chapters titles. How can I do this?

Thanks in advance
Post Reply