回忆录,如何让 \makechapterstyle 知道章节标题是否在前面?

回忆录,如何让 \makechapterstyle 知道章节标题是否在前面?

对于我的书,我定义了自己的章节样式,我喜欢只在文档正文中(之后\mainmatter)使用它。在前言中,我喜欢保留默认的回忆录章节样式。

背景:

我的章节样式产生以下结果:

在此处输入图片描述

在前言中,我增加了文本宽度至章节标题的右边框(参见下面的 mwe)。因此,章节标题被推出页面(在本例中是目录标题,即:“内容”)。

在此处输入图片描述

为了使其可见,我正在寻找如何使我的章节样式清晰可见以及在哪里使用。对于星星,我喜欢在前面使用memoir默认样式。

母语:

\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}

问题:

如何改变我的\makechapterstyle,它将意识到\frontmatter并使用或默认的回忆录风格或新定义的风格(与中使用的风格非常不同\mainmatter)?

答案1

\if@mainmatter...\else ...\fi里面有帮助吗\makechapterstyle

\frontmatter\@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}

相关内容