2

So, I'm trying to format the heading for a Part of a book. This heading is to include a quote and an author. As this is likely code that I'll want to reuse (and in the main body of the text as well), I decided to create a new command for it.

Ideally, I want the quote itself to be centred and italic, and the author to be preceded by an em dash, normal font, and aligned right.

Additionally, I would like the entire quote to be cased in horizontal lines.

This is what I have come up with so far:

\documentclass[10pt]{book}

\newcommand{\jquote}[2]{\normalsize{\textnormal{\centering{\textit{#1}}\linebreak\raggedleft{---#2}}}}
\begin{document}

\tableofcontents

\part*{PART TITLE\linebreak\hrule\jquote{This is a quote\linebreak this is some more text}{A. N. Author}\linebreak\hrule}
\addcontentsline{toc}{part}{PART TITLE}
\end{document}

Strangely, the title does not appear in my TOC, but it does in my full work. Not sure what I did there.

In this example, the quote is italic, but both the quote and the author are centred, and I cannot for the life of me get the author to move anywhere; left, right, it just stays where it is.

Edit:

I have added in some code a user suggested, but I think something in here is affecting other things. Here is my full preamble:

\documentclass[10pt]{book}

% Packages
\usepackage[paperwidth=5.5in, paperheight=8.5in, inner=0.25in, outer=0.5in, top=1in, bottom=1in, bindingoffset=0.25in]{geometry} % Sets the size and margins
\usepackage{endnotes}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage[onehalfspacing]{setspace}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{tocloft}
\usepackage{bookmark}
\usepackage{nopageno}
\usepackage{parskip}

% TOC Variables
\cftpagenumbersoff{part}
\cftsetindents{part}{0em}{6em}
\cftsetindents{chapter}{1em}{6em}

% Headers
\fancyhf{}
\pagestyle{fancy}
\fancyhead[CE]{\nouppercase{Allison's Defeat}}
\fancyhead[CO]{\nouppercase\leftmark}
\fancyfoot[RO,LE]{\thepage}

% Misc
\let\footnote=\endnote
\frenchspacing
\setromanfont{DejaVu Serif}

% Gets rid of page numbers on blank pages
\let\origdoublepage\cleardoublepage
\newcommand{\clearemptydoublepage}{\clearpage{\pagestyle{empty}\origdoublepage}}
\let\cleardoublepage\clearemptydoublepage

% Renew Commands
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftpartpagefont}{\bfseries\large}
\renewcommand{\cftbeforepartskip}{\setlength{20pt}}
\renewcommand{\cftbeforechapskip}{\setlength{0pt}}
\renewcommand{\cftpartfont}{\bfseries\large}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchapdotsep}{\cftdotsep}
\renewcommand{\cftpartpresnum}{Part }
\renewcommand{\cftchappresnum}{Chapter }

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{#1}}

\newcommand{\jquote}[2]{%
  \par
  \vspace{2\baselineskip}% adjust to suit
  \hrule
  \vspace{3pt}
  \centering
  \normalsize\normalfont\itshape
  #1\par
  \raggedleft---#2\par
  \vspace{3pt}
  \hrule
}
\newcommand{\PART}[3]{%
  \cleardoublepage
  \addcontentsline{toc}{part}{#1}%
  \part*{#1\jquote{#2}{#3}}%
}

% Resets chapter numbering
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
1
  • If I were going to do it something like your way I might put \newcommand{\jquote}[2]{\normalsize\normalfont\textit{#1}\\\hfill---#2} and then \part*{PART TITLE\\[0ex]\hrulefill\\[1ex]\jquote{This is a quote\\this is some more text}{A. N. Author}\\\hrulefill}. But I'm not sure sticking extra stuff inside the \part command is really the way to go. Have you considered something like the epigraph package?
    – frabjous
    Commented Sep 19, 2022 at 5:19

1 Answer 1

1

You possibly mean something like as follows:

\documentclass[10pt]{book}

\newcommand{\jquote}[2]{%
  \par
  \vspace{2\baselineskip}% adjust to suit
  \hrule
  \vspace{3pt}
  \centering
  \normalsize\normalfont\itshape
  #1\par
  \raggedleft---#2\par
  \vspace{3pt}
  \hrule
}
\newcommand{\PART}[3]{%
  \cleardoublepage
  \addcontentsline{toc}{part}{#1}%
  \part*{#1\jquote{#2}{#3}}%
}

\begin{document}

\tableofcontents

\PART{PART TITLE}{This is a quote \\ this is some more text}{A. N. Author}

\end{document}

enter image description here

Use \\ rather than \linebreak. Note that \addcontentsline should be before \part* so the page number will be the correct one, but \cleardoublepage has to be issued.

3
  • So this works. Kind of. However, it breaks some other functionality of the document. I want each chapter to restart numbering after a new part begins. I also want each part to be preceded by "Part #" in both the TOC and on the Part heading page. This worked previously, but after adding this, neither functionality works. I take this formatting away, and the functionality returns. I have added my entire preamble to my original question. Is there anything here that might be affecting this?
    – JRCSalter
    Commented Sep 20, 2022 at 12:11
  • @JRCSalter Add \setcounter{chapter}{0} at the end of the definition of \PART
    – egreg
    Commented Sep 20, 2022 at 17:07
  • That works, but then messes with hyperref, meaning the TOC entry for chapter 1 of part 2 links to chapter 1 of part 1.
    – JRCSalter
    Commented Sep 20, 2022 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .