2

for my book i define own chapter style which i like to use only in body of document (after \mainmatter). in front matter i like to preserve default memoir chapter style.

background:

my chapter style gives the following result:

enter image description here

in the front matter i increase text width to the right border of chapter title (see mwe below). consequently chapter title is pushed out of page (in this case title of table of content, i.e.: "Content").

enter image description here

to make it visible, i looking for how to make my chapter style aware, where is used. for star i like to have in front matter memoir default style.

mwe:

\documentclass{memoir}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning, shadows}
%---------------------------------------------------------------%
    \newlength{\marginwidth}
    \setlength{\marginwidth}{\dimexpr\marginparsep+\marginparwidth\relax}
    \newsavebox{\bookbox}
    \newcommand{\zfcbookname}[1]{\sbox{\bookbox}{\textsc{#1}}}
    \zfcbookname{<book title>}
%---------------------------------------------------------------%
\makechapterstyle{zfcBook}{%
\setlength\beforechapskip{9\baselineskip}
\setlength\afterchapskip{7\baselineskip}
\setlength\midchapskip{1\baselineskip}
    \renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries}
    \renewcommand*{\chapnamefont}{\chaptitlefont}
    \renewcommand*{\chapnumfont}{\bfseries\fontsize{77}{84}\selectfont}
        \renewcommand*{\printchaptername}{}
    \renewcommand*{\chapternamenum}{}
    \renewcommand*{\printchapternum}{%
        \begin{adjustwidth}{\marginwidth}{-\marginwidth}
    \begin{tikzpicture}
%-------
\node[name=chapter,
      rectangle,fill=white,minimum width=\textwidth,minimum height=22mm,
      copy shadow={shadow xshift=6pt,shadow yshift=-2pt,fill=black}] {~};
\node[above left] at (chapter.south east) {
            \ifanappendix\chaptitlefont\@chapapp\fi
            \chapnumfont\thechapter};
\node[below right=1mm and 0mm] at (chapter.south west) {\usebox{\bookbox}};
%-------
    \end{tikzpicture}
        \end{adjustwidth}
                                   }%end od print chapter num
    \renewcommand*{\printchaptertitle}[1]{
        \begin{adjustwidth}{\marginwidth}{-\marginwidth}
    \raggedleft{\chaptitlefont ##1}\par\nobreak%
        \end{adjustwidth}
                                        }% end of print chapter title
                            }%end of zfcBook
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
    \chapterstyle{zfcBook}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frontmatter
\changetext{0pt}{\marginwidth}{-\marginwidth}{0pt}{0pt}
\tableofcontents                                % kazalo
\changetext{0pt}{-\marginwidth}{\marginwidth}{0pt}{0pt}
\mainmatter

\chapter{ena}
\lipsum[11]
    \section{ena ena}
    \section{ena dva}
    \section{ena tri}
\chapter{dva}
    \section{dva ena}
    \section{dva dva}
    \section{dva tri}
\end{document}

question:

how to change my \makechapterstyle that it will be aware of \frontmatter and there use or default memoir style or new defined style (very different from one used in \mainmatter)?

2
  • i just "discover" a simple solution: move \chapterstyle{zfcBook} after \mainmatter ... it seems that i should delete my question :-(
    – Zarko
    Jan 1, 2018 at 17:38
  • 1
    Inside \frontmatter the numbered version is not used, so you can add stuff to \printchapternonum, which will be executed under \chapter* and within frontmatter. I sometimes add a switch in \printchapternonum when I have all the typesetting (name and number) inside \printchaptertitle, then I can distinguish between the two cases.
    – daleif
    Feb 1, 2018 at 10:04

1 Answer 1

2

Does \if@mainmatter...\else ...\fi inside \makechapterstyle help?

\frontmatter sets \@mainmatterfalse.

\documentclass{memoir}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning, shadows}
%---------------------------------------------------------------%
    \newlength{\marginwidth}
    \setlength{\marginwidth}{\dimexpr\marginparsep+\marginparwidth\relax}
    \newsavebox{\bookbox}
    \newcommand{\zfcbookname}[1]{\sbox{\bookbox}{\textsc{#1}}}
    \zfcbookname{<book title>}
%---------------------------------------------------------------%

\makeatletter
\makechapterstyle{zfcBook}{%
  \if@mainmatter
  \setlength\beforechapskip{9\baselineskip}
  \setlength\afterchapskip{7\baselineskip}
  \setlength\midchapskip{1\baselineskip}
  \renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries}
  \renewcommand*{\chapnamefont}{\chaptitlefont}
  \renewcommand*{\chapnumfont}{\bfseries\fontsize{77}{84}\selectfont}
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\chapternamenum}{}
  \renewcommand*{\printchapternum}{%
    \begin{adjustwidth}{\marginwidth}{-\marginwidth}
      \begin{tikzpicture}
%-------
        \node[name=chapter,
        rectangle,fill=white,minimum width=\textwidth,minimum height=22mm,
        copy shadow={shadow xshift=6pt,shadow yshift=-2pt,fill=black}] {~};
        \node[above left] at (chapter.south east) {
          \ifanappendix\chaptitlefont\@chapapp\fi
          \chapnumfont\thechapter};
        \node[below right=1mm and 0mm] at (chapter.south west) {\usebox{\bookbox}};
        % -------
      \end{tikzpicture}
    \end{adjustwidth}
  }%end od print chapter num
  \renewcommand*{\printchaptertitle}[1]{
    \begin{adjustwidth}{\marginwidth}{-\marginwidth}
      \raggedleft{\chaptitlefont ##1}\par\nobreak%
    \end{adjustwidth}
  }% end of print chapter title
  \else
  \chapterstyle{default}% Is done anyway...
  \fi
}%end of zfcBook
\makeatother
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
    \chapterstyle{zfcBook}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frontmatter
\changetext{0pt}{\marginwidth}{-\marginwidth}{0pt}{0pt}
\tableofcontents                                % kazalo
\changetext{0pt}{-\marginwidth}{\marginwidth}{0pt}{0pt}
\mainmatter

\chapter{ena}
\lipsum[11]
    \section{ena ena}
    \section{ena dva}
    \section{ena tri}
\chapter{dva}
    \section{dva ena}
    \section{dva dva}
    \section{dva tri}
\end{document}
1
  • 1
    yes, on first i looking exactly for this, so i will accept your answer. but meanwhile i found simple solution (see my comment below question). it seems that due to holidays my brain is not full operational :-).
    – Zarko
    Jan 1, 2018 at 17:43

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.