Closely Related:
- Create Separate Footer and Header for Chapter Title and Content Pages?
1. Use Case - Decoupling Layout from Content:
Content Authors will provide TeX content via a web portal, which will likely include \chapter{Chapter Title}
and most probably footnote, math, image, and other TeX syntax.
However - it is often the case that the default chapter title page
and chapter content page
styles could be wrongfully specified by these authors, or get corrupted through other imports (\input
, \include
, \usepackage
, etc.)
Clarification: A Chapter Title Page
is the first page of a chapter. Chapter Content Pages
are the remaining content pages of the chapter. This has nothing to do with a Table of Contents, but should not effect the ToC.
2. Question:
With the Memoir, Book, or other document classes, is it possible to do what the related question is doing with the \xpatchcmd
?
Is it possible to define and apply custom classes, only once, to affect all Chapter Title Pages
and Chapter Content Pages
, throughout an entire document, without all of the code repetition as seen in similar questions?
Goals:
- To be able to define headers and footers for Chapter Title Pages and Chapter Content Pages separately, (which the current answer is limited from doing).
- To eventually have separate custom styles for each Part in a book, (without worrying about default styles being corrupted.
- Less code repetition.
- Could override unwelcome customizations in imported documents.
- To blacklist
\xpatchcmd
and any other patch commands from being used.
3. Code Example:
\documentclass{memoir}
\usepackage{lipsum}
\makepagestyle{chapter}
\makeheadrule{chapter}{\textwidth}{\normalrulethickness}
\makefootrule{chapter}{\textwidth}{\normalrulethickness}{\footruleskip}
\makeoddhead {chapter}{left header}{odd header}{right header}
\makeoddfoot {chapter}{left footer}{odd footer}{right footer}
% ***** Added in Even Page Headers and Footers to show on Chapter Content Pages
\makeevenhead {chapter}{left header}{even header}{right header}
\makeevenfoot {chapter}{left footer}{even footer}{right footer}
\makepagestyle{alternate}
\makeheadrule{alternate}{\textwidth}{\normalrulethickness}
\makefootrule{alternate}{\textwidth}{\normalrulethickness}{\footruleskip}
\makeoddhead {alternate}{left header}{alternate odd header}{right header}
\makeoddfoot {alternate}{left footer}{alternate odd footer}{right footer}
\makeevenhead {alternate}{left header}{alternate even header}{right header}
\makeevenfoot {alternate}{left footer}{alternate even footer}{right footer}
\begin{document}
% ***** What Memoir Code could go here, to override all
% ***** chapter title and content pagestyles?
% ***** How to specify all chapter Title and Content Pages
% ***** ... without having to provide an actual chapter.
% ***** ... \xpatch can do this, but does Memoir have a way?
\chapter{Non-Styled Chapter}
\chapterprecis{Ideally the only code would be the \\ include command. Authors will only have TeX code specific to their own content - with no knowledge of current styles, etc. There would be no "\\ pagestyle" commands in these \\ include -ed files. Here, chapter content pages have no custom headers and footers. }
% \include("./Content/MyContent.text")
\sloppy\lipsum
\chapter{Test Chapter With required \\ pagestyle command}
\chapterprecis{Required to use inner Styling to get Headers and Footers.}
% **** Chapter Content Pages Need this \pagestyle command?
\pagestyle{chapter}
\sloppy\lipsum
% ***** Every \chapter tag would reqire \chapterstyle, etc.
% ***** Chapter Content will actually be pulled in via \include.
\chapterstyle{bianchi}
\chapter{Testing Bianchi Chapter Style}
\chapterprecis{Built in Chapter Styles have no impact on headers and footers.%
Have to resort to including \\ pagestyle in order to override possible%
corruption of default \\ pagestyle\{chapter\} }
\pagestyle{alternate}
\sloppy\lipsum
% ***** Bianchi Chapter Test 2, Without Style Tags
\chapter{Non-Styled Chapter}
\chapterprecis{Chapter Without Any Style Commands. Inherits globally altered changes. This is what I am hoping to avoid.}
\sloppy\lipsum
\end{document}
xpatch
is not replacing anything in the whole body. It changes the definition of a macro. The macro can be used multiple times.\chapterstyle{bianchi}
if so\renewcommand\chapterstyle[1]{}
would disable this command, but I can not really guess. Ultimately it is a social issue that you need to control by author guidelines not by technology, any latex input can redefine any part of latex.