Page LayoutTwo page chapter title + background images. Minor TOC problem

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
hyb
Posts: 1
Joined: Sat Oct 24, 2020 4:58 pm

Two page chapter title + background images. Minor TOC problem

Post by hyb »

Hi all,

I am working on a book-type document in which I would like to start each chapter in an open-right manner with the title on the right-hand page (odd). However, I would also like to add a background image to both the left (even) and right page (odd) that contains the chapter number and title.

My current approach is to force open-left, and add the background figures with a combination of titlesec and eso-pic with \titleformat.

This approach works well, however an unwanted side-effect is that the TOC now always refers to the left (even) page. I would however like the TOC to point to the right (odd) page that contains the chapter number and title. See below two figures to clarify this issue.
chapterpage.png
chapterpage.png (57.38 KiB) Viewed 3165 times
toc.png
toc.png (14.44 KiB) Viewed 3165 times
My current approach in a MWE:

Code: Select all

Code, edit and compile here:
\documentclass[10pt,openany,twoside,titlepage]{book}
% change openright to openleft. i.e. chapter starts on even page
\makeatletter
\renewcommand*\cleardoublepage{\clearpage\if@twoside
\ifodd\c@page \hbox{}\newpage\if@twocolumn\hbox{}%
\newpage\fi\fi\fi}
\makeatother
% include some required packages
\usepackage{blindtext}
\usepackage{titlesec, titletoc, xcolor}
\usepackage{graphicx}
\usepackage{eso-pic}
\usepackage{hyperref}
\usepackage{geometry}
\geometry{inner=40mm}
% new command for even/odd background figures
\newcommand\BackgroundPicEven
{ \includegraphics[height=\paperheight , width=\paperwidth]{example-image-a} }
\newcommand\BackgroundPicOdd
{ \includegraphics[height=\paperheight , width=\paperwidth]{example-image-b} }
% add two-page title format as chapter title-page. Uses clearpage
\titleformat{\chapter}
[block]
{ \flushright \thispagestyle{plain} }
{ }
{40 pt}
{\LARGE \bfseries \AddToShipoutPicture*{\BackgroundPicEven}
\clearpage
\AddToShipoutPicture*{\BackgroundPicOdd}
Chapter \thechapter \\ \vspace{50mm} }
[\newpage]
\titleformat{\section}[hang]{\large\bfseries}{\thesection}{1em}{}
\begin{document}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I have tried to find a solution for this, but so far without success. Does anyone have any suggestions? In my actual document I am using scrbook class, so I am open to alternatives that use scrbook as well.

Cheers,
Hyb

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply