Text FormattingCustomizing \part titles - help needed

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
herenvardo
Posts: 6
Joined: Sat May 02, 2009 2:24 pm

Customizing \part titles - help needed

Post by herenvardo »

Greetings,

I'll try to go straight to the topic: I'm writing a manual in LaTeX using the book class, and I have been struggling for a week with the code in an attempt to tweak the appearance of each part's title.

Basically, I'd like to move the title itself upwards on the page, and use the remaining space below it on the page to add an image (the image is different for each part). Everything else should stay as is (like forcing the title on an odd page, with no page heading, forcing a blank page after it, same text format, etc).

I have googled every key-phrase I could come up with, without any relevant result. Also tried to look at the code in book.cls that deals with parts but could only understand a few lines on it. I even tried to google stuff like "\def\@part" or "\newcommand\part", but didn't get anything useful.

Just for the case it matters, I'm working with MikTex 2.7 and TeXnicCenter, and outputting my work to PDF.

Thanks in advance for any help provided.

Regards,
Herenvardo

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Customizing \part titles - help needed

Post by gmedina »

Hi,

you can use the titlesec and epigraph packages. Take a look at the following simple example:

Code: Select all

\documentclass{book}
\usepackage{titlesec}
\usepackage{epigraph}

\setlength\epigraphwidth{\textwidth}
\titleformat{\part}[display]
  {\normalfont\huge\filcenter\bfseries\thispagestyle{epigraph}}{Part\ \thepart}{20pt}{\Huge}
\titlespacing*{\part} 
  {0pt}{0pt}{40pt}

\begin{document}

\epigraphhead[300]{\hfil\rule{7cm}{4cm}\hfil}
\part{Test part}

\end{document}
Remarks: 1) I used a \rule command to simulate an actual image. You can, of course use the \includegraphics command (after loading the graphicx package).
2) Feel free to modify my example according to your needs.
3) Refer to the documentation of the packages for further information.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
herenvardo
Posts: 6
Joined: Sat May 02, 2009 2:24 pm

Re: Customizing \part titles - help needed

Post by herenvardo »

Hi.

I messed a lot of things up for a while before I managed to properly install the epigraph package but, after that, your code worked like charm. I just replaced the rule with my pictures, adjusted the sizes a bit, and the part titles are now showing exactly as intended.

Thanks a lot for your help.

Regards,
Herenvardo
Post Reply