Page LayoutTable of contents only on odd pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
dukesdj
Posts: 2
Joined: Fri Dec 11, 2020 6:03 pm

Table of contents only on odd pages

Post by dukesdj »

I have looked around for a solution to this. I would like my table of contents to be only on odd pages. I did come across one solution, however, it only works if your contents page covers 2 pages. My contents page crosses more pages than this.

The following is an example of the problem (not the contents page is the issue not the format of the actual section).

Does anyone have a way around this to make contents pages only appear on odd pages (not just start on an odd page but all pages in the table of contents are only on odd pages)?

Code: Select all

\documentclass[11pt]{book}
\usepackage[a4paper,twoside,top=2cm, bottom=2cm, outer=2cm, inner=4cm]{geometry}
\usepackage[UKenglish]{babel}

\usepackage{afterpage}
\AtBeginDocument{%
    \addtocontents{toc}{\protect\afterpage\protect\cleardoublepage}%
}

\begin{document}
    
\tableofcontents

\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}\section{1}


\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Table of contents only on odd pages

Post by Ijon Tichy »

You almost already have it:

Code: Select all

\documentclass[11pt]{book}
\usepackage[a4paper,twoside,top=2cm, bottom=2cm, outer=2cm, inner=4cm]{geometry}
\usepackage[UKenglish]{babel}
\usepackage{afterpage}
\usepackage{blindtext}

\newif\ifemptyleftpages
\newcommand*{\emptyleftpages}{%
  \ifemptyleftpages
    \ifodd\value{page}\else
      %\thispagestyle{empty}% maybe also a good idea
      \cleardoublepage
    \fi
    \afterpage{\emptyleftpages}% recursive call
  \fi
}
\renewcommand*{\emptyleftpagestrue}{%
  \let\ifemptyleftpages\iftrue
  \emptyleftpages
}

\AtBeginDocument{\addtocontents{toc}{\protect\emptyleftpagestrue}}
\AtEndDocument{\addtocontents{toc}{\protect\emptyleftpagesfalse}}

\begin{document}

\tableofcontents

\blinddocument\blinddocument\blinddocument\blinddocument\blinddocument
\blinddocument\blinddocument\blinddocument\blinddocument\blinddocument
\blinddocument\blinddocument\blinddocument\blinddocument\blinddocument

\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
dukesdj
Posts: 2
Joined: Fri Dec 11, 2020 6:03 pm

Table of contents only on odd pages

Post by dukesdj »

Thanks! That works. It is a little funky (if only 1 item would go onto the 3rd toc page it doesnt work for some reason) in my full document but I think this is probably going to be something in my preamble. I can easily work around it!

Thanks tons this has been bugging me for a while!
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Table of contents only on odd pages

Post by Ijon Tichy »

Maybe

Code: Select all

\AtEndDocument{\addtocontents{toc}{\protect\clearpage\protect\emptyleftpagesfalse}}
would be better. But I've not tested it.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply