I am trying to include chapter quotes in a uniform way with scrartcl
as well as scrbook
. My final document will use scrbook
however I am compiling individual chapters with scrartcl
during the writing phase. What I want is easily achieved with \setchapterpreamble
. So I decided to customise \dictum
to get a similar output with scrartcl
. Depending on which class is loaded, I define an environment that wraps either of the two. Wrapping \dictum
works well, but compilation fails with \setchapterpreamble
. LaTeX complains \BODY
is undefined! I have tried renaming \BODY
with \environbodyname
, but that didn't help.
Here is a minimal example that fails:
\documentclass[11pt,a4paper,twoside,chapterprefix=true]{scrbook} % w/ \setchapterpreamble
% \documentclass[11pt,a4paper,twoside]{scrartcl} % w/ \dictum
\usepackage{graphicx}
\usepackage{xcolor}
\addtokomafont{chapterprefix}{\raggedleft}
\renewcommand*{\chapterformat}{%
\mbox{%
% \scalebox{1.5}{\chapappifchapterprefix{\nobreakspace}}%
\scalebox{5}{\color{gray}\thechapter\autodot}\enskip
}
}
% title page info
\author{Suvayu}
\date{\today}
\title{Some title}
% customise dictum
\renewcommand*{\dictumwidth}{0.6\textwidth}
\renewcommand*{\raggeddictum}{\centering}
\renewcommand*{\dictumrule}{\vskip 0.3em}
\renewcommand*{\dictumauthorformat}[1]{— #1\par}
% documentclass aware quote environment for KOMA-script
\usepackage{environ}
% this is what I really want to do
% \makeatletter
% \@ifclassloaded{scrartcl}{% this works
% \NewEnviron{myquote}[1]{\dictum[#1]{\BODY}}
% }{% this does not
% \NewEnviron{myquote}[1]{%
% \setchapterpreamble[ol][0.6\textwidth]{%
% \BODY
% \null\hfill — \emph{#1}
% }
% }
% }
% \makeatother
% TEST: this does not work
\NewEnviron{myquote}[1]{%
\setchapterpreamble[ol][0.6\textwidth]{%
\BODY
\null\hfill — \emph{#1}
}
}
\begin{document}
\frontmatter
\maketitle
\mainmatter
% this does not work
\begin{myquote}{Alejandro Jodorowsky, on Dune}
You want to make the most fantastic art of movie?
Try. If you fail, is not important. We need to try.
\end{myquote}
% TEST: this works
% \setchapterpreamble[ol][0.6\linewidth]{%
% You want to make the most fantastic art of movie? \\
% Try. If you fail, is not important. We need to try. \\[1.5em]
% \null\hfill --- \emph{Alejandro Jodorowsky, on Dune}
% }
\chapter{Some chapter}
Foo, bar, baz
\end{document}
Note: I'm using XeLaTeX
\BODY
beforehand. I don't understand why this is necessary though (sply. since it's not needed with\dictum
). Also I don't quite understand how\protected@xdef
works, any reference?