Text FormattingA quotation at the beginning of a chapter

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
TheKingsRaven
Posts: 3
Joined: Sat Nov 21, 2009 12:32 pm

A quotation at the beginning of a chapter

Post by TheKingsRaven »

I'm using the multicol package for my document like so:

\documentclass[twocolumn,a4paper,10pt]{book}

and that's working fine, I've also used the fontspec and sectsty packages to redefine my Section, Subsection and Chapter:

\chapterfont{\centering \Huge \fontspec{Mad's Scrawl (BRK)}}

and that's working fine too :) The chapter title appears at the centre of the page rather than in the columns just as I want, the problem is that for some chapters I'd like a quotation directly beneath the chapter title - minimal vertical whitespace between the two and the quote shouldn't be split into two columns like the rest of the document. How can I do this?

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

A quotation at the beginning of a chapter

Post by gmedina »

Hi,

the following code could be used as a starting point. Using the titlesec package, I defined the \chapquot command with two mandatory arguments; its syntax is

Code: Select all

\chapquot{<chapter name>}{<quotation text>}
.

Usage: for a chapter with quotation, use the \chapterquot command right before the corresponding \chapter command and group these two commands (using braces, for example).

The example:

Code: Select all

\documentclass[twocolumn,a4paper,10pt]{book}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}% just to generate some text

\newcommand\chapquote[2]{%
  \titleformat{\chapter}[display]
    {\normalfont\Huge\bfseries\filcenter}{\chaptertitlename\ \thechapter\vskip10pt#1}{0pt}
    {\normalsize\parbox[t]{10cm}{\normalfont\itshape#2}}}
\titleformat{\chapter}[display]
    {\normalfont\Huge\bfseries\filcenter}{\chaptertitlename\ \thechapter\vskip10pt#1}{0pt}
    {\Huge}

\begin{document}

% a chapter with quotation
{\chapquote{Test chapter one}{\lipsum[1]}
\chapter{Test chapter one}}
\lipsum[1-2]

% a chapter without quotation
\chapter{Test chapter two}
\lipsum[1-3]

\end{document}
Of course, feel free to modify my example according to your needs. In particular, the modifications thst you made using sectsty should be made now inside the \titleformat command, without using commands from sectsty.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
TheKingsRaven
Posts: 3
Joined: Sat Nov 21, 2009 12:32 pm

Re: A quotation at the beginning of a chapter

Post by TheKingsRaven »

Thanks, it took a bit of trial and error (and a newer version of titlesec*) but I've got it working like I want now (including the format Chapter <number>: <Chapter Name> all on one line)


* Is there a way to set the path with \usepackage or am I stuck carrying titlesec in all my document folders
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: A quotation at the beginning of a chapter

Post by localghost »

Install the package with the package manager of your LaTeX distribution.


Best regards
Thorsten
TheKingsRaven
Posts: 3
Joined: Sat Nov 21, 2009 12:32 pm

Re: A quotation at the beginning of a chapter

Post by TheKingsRaven »

I'd rather not go into Debian Experimental to be honest.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

A quotation at the beginning of a chapter

Post by localghost »

I did not talk about the package manager of your Linux distribution but the one of your LaTeX distribution. If there is not such a package manager, you have to the additions or replacements manually. Pay attention to the conventions of the TeX Directory Structure (TDS). But perhaps you have the epigraph package installed already. Check that on the terminal.

Code: Select all

kpsewhich epigraph.sty
Post Reply