1

I'm working on typesetting a book that has lovely artwork for chapter headings plus full-page art for each part (so Part 1 gets art that incorporates the text "Part 1", etc.) I successfully suppressed the chapter heading with:

\newcommand{\mychapter}[1]{%
  \begingroup
  \let\@makechapterhead\@gobble % make \@makechapterhead do nothing
  \chapter{#1}
  \endgroup
}

(This does work, but Koma complains about the redefinition of @makechapterhead. I'm ok with that for now, but ideally I'd like a solution that doesn't annoy Koma.)

However, I'd like to do the same with \part as well as \chapter, and I can't get this to work.

Here's a MWE where the table of contents and page spreads are just right, BUT I don't want the page with "Part 1" or the blank page opposite it to print:

\documentclass[twoside,chapterprefix,headings=big]{scrbook}

\usepackage{blindtext}
\usepackage{mwe}


\makeatletter
\newcommand{\mychapter}[1]{%
  \begingroup
  \let\@makechapterhead\@gobble
  \chapter{#1}
  \endgroup
}
\makeatother

\begin{document}
\tableofcontents

\KOMAoptions{headings=openleft}
\part{It begins}
%beautiful artwork goes... around here somewhere?
\includegraphics[width=\textwidth]{example-image-golden}

\KOMAoptions{headings=openright}
\mychapter{a chapter}
 \begin{figure}[t!]
\centering
%beautiful chapter head artwork goes here
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\blindtext

\mychapter{another chapter}
 \begin{figure}[t!]
\centering
%beautiful chapter head artwork goes here
\includegraphics[width=\textwidth]{example-image-b}
\end{figure}
\blindtext

\KOMAoptions{headings=openleft}
\part{The middle bit}
%beautiful artwork goes... around here somewhere?
\includegraphics[width=\textwidth]{example-image-golden}

\KOMAoptions{headings=openright}
\mychapter{yet another chapter}
\includegraphics[width=\textwidth]{example-image-c}

\blindtext
\end{document}

(We're pretending that the "golden" image is the full-page artwork to be used in lieu of LaTeX outputting "Part N: Title".)

I want the page with "Part N: Title" and the blank page opposite it suppressed (not printed). The document should go straight from the table of contents to a two-page spread with the part artwork on the left and the chapter starting on the right.

Creating a \newcommand analogous to \mychapter doesn't appear to do anything, not even put anything interesting in the log:

\makeatletter
\newcommand{\mypart}[1]{%
  \begingroup
  \let\@makeparthead\@gobble
  \part{#1}
  \endgroup
}
\makeatother

Trying to fake a part by omitting the \part{It Begins} command and instead doping the ToC with

\addcontentsline{toc}{part}{Part \thepart: It Begins}

results in the part heading showing up in the table of contents below chapter 1, and with no part number, plus I don't see how to increment \thepart so that subsequent parts are numbered correctly. Trying to manually increment it with \stepcounter{\thepart} throws an error.

If the Koma guide in English covers this, I honestly missed it.

Thanks all!

1 Answer 1

2

I'm not sure, that I understand what you want exactly. But instead of fiddling with internals of the class, I would suggest to define a command, that does exactly what you want and nothing else. AFAIK you want:

  • start a new odd page (for chapters) or a new even page (for parts)
  • step the counter
  • optional add a TOC entry and a mark for page headers
  • print an image

I'm using an optional argument for the TOC entry and the mark. And I'm also defining a star variant without increasing the number and without TOC entry and mark similar to \part* and \chapter*. I'm using the mandatory argument for the image file:

\documentclass[chapterprefix,headings=big]{scrbook}

\usepackage{blindtext}
\usepackage{mwe}

\makeatletter
\NewDocumentCommand\ArtPart{som}{%
  \cleardoubleevenpage
  \IfBooleanTF{#1}{% star version: no TOC entry or page header
  }{%
    \refstepcounter{part}%
    \IfValueTF{#2}{% optional argument: Use for TOC entry and page header
      \addparttocentry{\thepart.}{#2}%
      \partmark{#2}%
    }{}%
  }%
  \noindent\includegraphics[width=\textwidth]{#3}%
  \par\nobreak
  \@afterindentfalse% don't indent first paragraph after the heading
  \@afterheading% don't allow page break here etc.
}

\NewDocumentCommand\ArtChapter{som}{%
  \cleardoubleoddpage
  \IfBooleanTF{#1}{% star version: no TOC entry or page header
  }{%
    \refstepcounter{chapter}%
    \IfValueTF{#2}{% optional argument: Use for TOC entry and page header
      \addchaptertocentry{\thechapter}{#2}%
      \chaptermark{#2}%
    }{}%
  }%
  \noindent\includegraphics[width=\textwidth]{#3}%
  \par\nobreak
  \@afterindentfalse% don't indent first paragraph after the heading
  \@afterheading% don't allow page break here etc.
}
\makeatother

\begin{document}
\tableofcontents

\ArtPart[It begins]{example-image-golden}


\ArtChapter[a chapter]{example-image-a}
\blindtext

\ArtChapter[another chapter]{example-image-b}
\blindtext

\ArtPart[The middle bit]{example-image-golden}

\ArtChapter[yet another chapter]{example-image-c}

\blindtext
\end{document}

enter image description here

Note also, that \thepart is not the counter but the output of the counter. The counter would be part and therefore to manipulate the counter you have to use \stepcounter{part}, \refstepcounter{part}, \addtocounter{part}{…}, and \setcounter{part}{…}, but not \stepcounter{\thepart}. Note also, that there isn't a predefined \@makeparthead in KOMA-Script.

For more information about \NewDocumentCommand see “LaTeX for authors — current version”. For more information about the KOMA-Script commands used, see the KOMA-Script manual.

If you really want to use \part and \chapter you should IMHO redefine \chapterlineswithprefixformat and \partlineswithprefixformat instead of internal commands:

\documentclass[chapterprefix,headings=big]{scrbook}

\usepackage{blindtext}
\usepackage{mwe}

\newcommand\mypart[2]{%
  \begingroup
    \KOMAoption{open}{left}%
    \renewcommand*{\partlineswithprefixformat}[3]{%
      \includegraphics[width=\textwidth]{#2}% this is the second argument of
                                % \mypart not of \partlineswithprefixformat
    }%
    \renewcommand*{\partheademptypage}{}% don't add an empty page after \part
    \part[#1]{#2}%
  \endgroup  
}

\newcommand\mychapter[2]{%
  \KOMAoption{open}{right}%
  \DeclareCommandCopy\ChapterLinesWithPrefixFormat\chapterlineswithprefixformat
  \renewcommand*{\chapterlineswithprefixformat}[3]{%
    \includegraphics[width=\textwidth]{#2}% this is the second argument of
                         % \mychapter not of \chapterlineswithprefixformat
  }%
  \chapter[#1]{#2}%
  \DeclareCommandCopy\chapterlineswithprefixformat\ChapterLinesWithPrefixFormat
}

\begin{document}
\tableofcontents

\mypart{It begins}{example-image-golden}


\mychapter{a chapter}{example-image-a}
\blindtext

\mychapter{another chapter}{example-image-b}
\blindtext

\mypart{The middle bit}{example-image-golden}

\mychapter{yet another chapter}{example-image-c}

\blindtext
\end{document}

enter image description here

With this, you still can use \RedeclareSectionCommand to, e.g., change the vertical distance before and after the heading = before and after the image.

As you can see, I've not needed any internal command for this second suggestion, but only commands that are documented in the KOMA-Script manual to be used for users or advanced users or that are documented in “LaTeX for authors — current version”.

Note: I've not used \begingroup…\endgroup in \mychapter, because this would also break the possibility to add a \label after \mychapter and also breaks the afterindent=false feature of \RedeclareSectionCommand. Instead I've stored the meaning of \chapterlineswithprefixformat before \chapter and restored it after \chapter.

For the first suggestion I've only needed \@afterindentfalse and \@afterheading from the LaTeX kernel. These are usual commands for class/package authors but not internal KOMA-Script commands.

1
  • THANK YOU! That's perfect! Thanks also for pointing me to that LaTeX for Authors document, which I hadn't been aware of.
    – Nightsky
    Jan 11 at 4:09

You must log in to answer this question.

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