LaTeX forum ⇒ 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).
hyb
Posts: 1
Joined: Sat Oct 24, 2020 4:58 pm

Two page chapter title + background images. Minor TOC problem

Postby hyb » Sat Oct 24, 2020 5:56 pm

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 320 times


toc.png
toc.png (14.44 KiB) Viewed 320 times


My current approach in a MWE:

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[10pt,openany,twoside,titlepage]{book}
  2.  
  3. % change openright to openleft. i.e. chapter starts on even page
  4. \makeatletter
  5. \renewcommand*\cleardoublepage{\clearpage\if@twoside
  6. \ifodd\c@page \hbox{}\newpage\if@twocolumn\hbox{}%
  7. \newpage\fi\fi\fi}
  8. \makeatother
  9.  
  10. % include some required packages
  11. \usepackage{blindtext}
  12. \usepackage{titlesec, titletoc, xcolor}
  13. \usepackage{graphicx}
  14. \usepackage{eso-pic}
  15. \usepackage{hyperref}
  16.  
  17. \usepackage{geometry}
  18. \geometry{inner=40mm}
  19.  
  20. % new command for even/odd background figures
  21. \newcommand\BackgroundPicEven
  22. { \includegraphics[height=\paperheight , width=\paperwidth]{example-image-a} }
  23.  
  24. \newcommand\BackgroundPicOdd
  25. { \includegraphics[height=\paperheight , width=\paperwidth]{example-image-b} }
  26.  
  27. % add two-page title format as chapter title-page. Uses clearpage
  28. \titleformat{\chapter}
  29. [block]
  30. { \flushright \thispagestyle{plain} }
  31. { }
  32. {40 pt}
  33. {\LARGE \bfseries \AddToShipoutPicture*{\BackgroundPicEven}
  34. \clearpage
  35. \AddToShipoutPicture*{\BackgroundPicOdd}
  36. Chapter \thechapter \\ \vspace{50mm} }
  37. [\newpage]
  38.  
  39. \titleformat{\section}[hang]{\large\bfseries}{\thesection}{1em}{}
  40.  
  41. \begin{document}
  42. \pagestyle{plain}
  43. \tableofcontents
  44.  
  45. \chapter{First very long chapter title} \label{chapters:01}
  46. \section{First section}
  47. \blindtext[6]
  48.  
  49. \chapter{Second very long chapter title} \label{chapters:02}
  50. \section{First section}
  51. \blindtext[10]
  52.  
  53. \chapter{Third very long chapter title} \label{chapters:03}
  54. \section{First section}
  55. \Blindtext[3]
  56.  
  57. \end{document}


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

Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 6 guests