![回忆录章节样式 - 在章节编号前添加图片](https://linux22.com/image/300509/%E5%9B%9E%E5%BF%86%E5%BD%95%E7%AB%A0%E8%8A%82%E6%A0%B7%E5%BC%8F%20-%20%E5%9C%A8%E7%AB%A0%E8%8A%82%E7%BC%96%E5%8F%B7%E5%89%8D%E6%B7%BB%E5%8A%A0%E5%9B%BE%E7%89%87.png)
您好,我正在尝试使用回忆录类“发布”我 9 岁孩子的故事。我想使用内置的 thatcher chapterstyle,但对其进行修改以在章节标题上方包含图像(我希望每个章节都有相同的图像)。我尝试插入此
\centering\includegraphics[scale=0.25]{pic}
进入以下 chapterstyle 代码的各个部分,虽然我可以让它出现在标题内(弄乱空白)但我无法将它放在我想要的位置 - 整个标题之上(即图像是页面上最顶部的东西。)
\makechapterstyle{anna}{%
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{}
\renewcommand*{\printchaptername}{%
\centerline{\chapnumfont{\@chapapp\ \thechapter}}}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\normalfont\scshape\MakeTextLowercase}
\renewcommand*{\printchapternum}{}
\renewcommand*{\afterchapternum}{%
\par\centerline{\parbox{0.5in}{\hrulefill}}\par}
\renewcommand*{\printchapternonum}{%
\vphantom{\chapnumfont \@chapapp 1}\par
\parbox{0.5in}{}\par}
\renewcommand*{\chaptitlefont}{\normalfont\large}
\renewcommand*{\printchaptertitle}[1]{%
\centering
\chaptitlefont \MakeTextUppercase{##1}}}
%\chapterstyle{thatcher}
\chapterstyle{anna}
我已经有几年没有编程或使用过 Latex 了,我不太明白上面的代码到底是怎么回事。我已经阅读了这个论坛上我能找到的所有其他相关帖子——我认为这可以帮助我,但情况略有不同,所以我仍然陷入困境。如果有人能帮忙,我将不胜感激。
先感谢您,
*编辑:抱歉。这是我的代码的完整工作示例。
\documentclass[12pt,a4paper,openany]{memoir}
\flushbottom
\usepackage{graphicx}
\usepackage{quattrocento}
\usepackage{verse}
\usepackage[normalem]{ulem}
%% BEGIN TITLE - THIS PRINTS TITLE AND AUTHOR ON FIRST PAGE
\makeatletter
\def\maketitle{%
\null
\thispagestyle{empty}%
\vfill
\begin{center}\leavevmode
\normalfont
{\LARGE\raggedleft \@author\par}%
\hrulefill\par
{\huge\raggedright \@title\par}%
\vskip 1cm
% {\Large \@date\par}%
\end{center}%
\vfill
\null
\cleardoublepage
}
\makeatother
\author{author name}
\title{A Mouse's Tale}
\date{}
\begin{document}
\let\cleardoublepage\clearpage
\maketitle
\frontmatter
\begin{center}
all the usual publisher and copyright info
\end{center}
\let\cleardoublepage\clearpage %THIS IS NOT CALLED AGAIN
\def\@chapapp{CHAPTER}
\makechapterstyle{anna}{%
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{}
\renewcommand*{\printchaptername}{%
\centerline{\chapnumfont{\@chapapp\ \thechapter}}}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\normalfont\scshape\MakeTextLowercase}
\renewcommand*{\printchapternum}{}
\renewcommand*{\afterchapternum}{%
\par\centerline{\parbox{0.5in}{\hrulefill}}\par}
\renewcommand*{\printchapternonum}{%
\vphantom{\chapnumfont \@chapapp 1}\par
\parbox{0.5in}{}\par}
\renewcommand*{\chaptitlefont}{\normalfont\large}
\renewcommand*{\printchaptertitle}[1]{%
\centering
\chaptitlefont \MakeTextUppercase{##1}}}
%\chapterstyle{thatcher}
\chapterstyle{anna}
\mainmatter
\sloppy
\chapter{Hunt for cheese}
\textit{Pitter} \textit{patter} pitter pattered my feet. As a mouse we always had to hunt, or find food and this was my task. Under the dining table I went. \textit{Bing bong}, \textit{bing bong}, the clock struck two.
\end{document}
*第二次编辑:
\makechapterstyle{anna}{%
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{ \centering\includegraphics[scale=0.25]{pic}}
在 \chapterheadstart 之后立即添加 \includegraphics 是我找到的最接近的方法。但它会将图形移到左侧,并将“章节号”文本推到右侧(通常它位于中间)。我认为我需要一些垂直空间。
答案1
高级类(如memoir
和 KOMA 脚本类)为几乎所有可能挂接的实例定义了命令。 在您的例子中,这是\chapterheadstart
。 当然,您可以更新定义后的命令,但在\makechapterstyle
定义中使用它肯定会更干净。
\documentclass{memoir}
%
\def\@chapapp{Chapter}%
\makechapterstyle{anna}{%%
\chapterstyle{default}%
\renewcommand*{\chapterheadstart}{}%
\renewcommand{\chapterheadstart}{{\centering\rule{3em}{4em}\par\vspace*{2em}}}%<------------
\renewcommand*{\printchaptername}{%%
\centerline{\chapnumfont{\@chapapp\ \thechapter}}%
}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\scshape\MakeTextLowercase}%
\renewcommand*{\printchapternum}{}%
\renewcommand*{\afterchapternum}{%%
\par\centerline{\parbox{0.5in}{\hrulefill}}\par}%
\renewcommand*{\printchapternonum}{%%
\vphantom{\chapnumfont \@chapapp 1}\par%
\parbox{0.5in}{}\par%%
}%
\renewcommand*{\chaptitlefont}{\normalfont\large}%
\renewcommand*{\printchaptertitle}[1]{%%
\centering %
\chaptitlefont \MakeTextUppercase{##1}%
}%
} %
\chapterstyle{anna}%
%
\begin{document}
\chapter{Hunt for cheese}
\emph{Pitter} \emph{patter} pitter pattered my feet. As a mouse we always had to hunt, or find food and this was my task. Under the dining table I went. \emph{Bing bong}, \emph{bing bong}, the clock struck two.
\end{document}