4

I'm working in memoir class and would like to format my chapter headings like this:

The author's name and years of birth-death are at the top, then a horizontal line the length of the above details, then the title, followed by an optional subtitle.

  • Which part(s) will appear in the table of contents? which parts in the header (or, footer, though that would be odd)? Is the idea that you will simply end up writing something like \chapter{<author>}{<title>}[<subtitle>] and get that output and everything put in the ToC and header in a standard way? – jon Jan 15 '14 at 1:32
  • I want the author and title to be in the table of contents like this: AUTHOR Title Subtitle .... <page number>. Title centered in header and page number centered in footers. And I would like to use the \chapter{<author>}{<title>}[<subtitle>] command as it is. – Medulla Oblongata Jan 15 '14 at 2:10
3

One possibility would be to implement a 'chapter-like' command in order to get around the requirement that there be two mandatory and one optional argument:

\documentclass[12pt,openany]{memoir}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{xparse}
\usepackage[colorlinks]{hyperref}
\usepackage{bookmark}

% Basic header-footer
\makepagestyle{title}
\makeevenhead{title}{}{\leftmark}{}
\makeevenfoot{title}{}{\thepage}{}
\makeoddhead{title}{}{\leftmark}{}
\makeoddfoot{title}{}{\thepage}{}
\pagestyle{title}


% the \chapterhead command (partially memoir-dependent)
\makeatletter
\NewDocumentCommand {\chapterhead} {mmo}
{\IfNoValueTF{#3}%
  {\clearforchapter
    \phantomsection
    \addcontentsline{toc}{chapter}{%
      % \numberline{}% <-- required if 'chapters' are numbered...
      \texorpdfstring{\MakeUppercase{#1}}{#1}\space #2}
    \markboth{#2}{#2}%
    \thispagestyle{chapter}%
    \insertchapterspace
    \chapterheadstart
    \setauthorname{#1}%
    \printauthorname
    \settowidth{\authornamelength}{#1}%
    \afterauthorname
    \setmainchaptertitle{#2}%
    \printchapterheadtitle
    \afterchapterheadtitle
    \printsubtitle
    \finchapterhead
    \@afterindentfalse\@afterheading% <-- prevent indentation at start of paragraph
  }%
  {\clearforchapter
    \phantomsection
    \addcontentsline{toc}{chapter}{%
      % \numberline{}%
      \texorpdfstring{\MakeUppercase{#1}}{#1}\space #2\space #3}
    \markboth{#2}{#2}%
    \thispagestyle{chapter}%
    \insertchapterspace
    \chapterheadstart
    \setauthorname{#1}%
    \printauthorname
    \settowidth{\authornamelength}{#1}%
    \afterauthorname
    \setmainchaptertitle{#2}%
    \printchapterheadtitle
    \afterchapterheadtitle
    \setsubtitle{#3}%
    \printsubtitle
    \finchapterhead
    \@afterindentfalse\@afterheading% <-- prevent indentation
  }%
}
\makeatother

% Auxiliary formatting macros:
\newlength\authornamelength
\newcommand*{\authornamefont}{\normalsize\normalfont}
\newcommand*{\mainchaptertitlefont}{\normalfont\large}
\newcommand*{\subtitlefont}{\normalsize\normalfont}
\newcommand{\afterauthorname}{%
  \par\centerline{\parbox{\authornamelength}{\hrulefill}}\par}%
\newcommand{\afterchapterheadtitle}{%
  {\par\addvspace{0.75\baselineskip}\noindent}}
\newcommand{\finchapterhead}{%
  {\par\addvspace{2\baselineskip}\noindent}}


% ARG. #1: Author name
\newcommand*{\setauthorname}[1]{\csdef{authorname}{#1}}
\newcommand{\printauthorname}{{\par\centering
  \authornamefont \scshape\MakeLowercase{\csuse{authorname}}\par}}%

% ARG. #2: Title
\newcommand*{\setmainchaptertitle}[1]{\csdef{mainchaptertitle}{#1}}
\newcommand{\printchapterheadtitle}{%
  {\par\centering \mainchaptertitlefont
    \MakeUppercase{\csuse{mainchaptertitle}}\par}}

% ARG. #3 (optional): Source
\newcommand*{\setsubtitle}[1]{\csdef{subtitle}{#1}}
\newcommand{\printsubtitle}{%
  {\par\centering \subtitlefont
    \textit{from} \csuse{subtitle}\par}}


\begin{document}

\tableofcontents

\chapterhead{Geoffrey Chaucer}{Roundel}[The Parliament of Fowls]

\lipsum

\chapterhead{Marcus Tullius Cicero}{Dream of Scipio}[On the Republic]

\lipsum[2]

\chapterhead{Plato}{The Myth of Er}
%[Republic] % <-- optional argument not needed

\lipsum[3]

% regular chapter
\chapter{ROUNDEL}

\lipsum[4]

\end{document}
  • 1
    Another reason for xparse would be to make the date 'field' optional as well along the lines of \chapterhead{<author>}[<date>]{<title>}[<subtitle>]... – jon Jan 15 '14 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.