我想要设置章节标题如下:
||
|| Chapter 1
|| The City Begins
|| to Decay
两个垂直条代表在 xfig 中绘制的一系列垂直条。我尝试过这个:
\titleformat{\chapter}
[display]
{\normalfont\Large\bfseries}{
\includegraphics{chapter-graphic}
\chaptertitlename\ \thechapter
}
{-10pt}
{\titlefont}
但我得到的是:
应用下面 Bernard 的建议并调整第一个参数后,我得到了这个:
请注意,这会导致“第 X 章”缩进,但章节名称不会缩进。输入\indent
任何参数都\titleformat
无济于事。现在看看图像的底部如何没有锚定到文本的底部:
编辑:添加图形代码
#FIG 3.2 Produced by xfig version 3.2.6a
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
0 0 45 0 45 1125 0 1125 0 0
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
90 1125 135 1125 135 -90 90 -90 90 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
180 1125 225 1125 225 -180 180 -180 180 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
270 1125 315 1125 315 -270 270 -270 270 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
360 1125 405 1125 405 -360 360 -360 360 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
450 1125 495 1125 495 -450 450 -450 450 1125
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
540 1125 585 1125 585 -540 540 -540 540 1125
答案1
此解决方案将普通章节放入 中\parbox
,并将图形插入前面(间隙为\columnsep
)。
\chapter
它使用固定宽度的图形,但调整高度以匹配标题。它使用书籍类的定义(上方 50pt,下方 40pt)。
\documentclass{book}
%\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{showframe}% debugging tool
\usepackage{lipsum}% MWE only
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \parskip \z@
\sbox0{\parbox[b]{\dimexpr\textwidth-2cm-\columnsep}{% width is preset
\raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1}}%
\raisebox{-\dp0}[\ht0][\dp0]{% [\ht0][\dp0] redundant in this case
\includegraphics[height={\dimexpr\ht0+\dp0},width=2cm]{example-image-duck}}%
\hspace{\columnsep}\usebox0
\par\nobreak}%
\vskip 40\p@
}
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter[pipes]{Someone finds the old pipes leading downward}
\lipsum[1-6]
\end{document}
此解决方案适用于回忆录类。
\documentclass{memoir}
%\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{showframe}% debugging tool
\usepackage{lipsum}% MWE only
\makeatletter
\def\@makechapterhead#1{%
\chapterheadstart%
{\parskip \z@
\parindent \z@
\sbox0{\parbox[b]{\dimexpr\textwidth-2cm-\columnsep}{% graphic width 2cm
\memRTLraggedright \normalfont
\ifm@m@And
\printchaptername \chapternamenum \printchapternum
\afterchapternum % \par\nobreak \vskip 20\p@
\else
\printchapternonum
\fi
\interlinepenalty\@M
\printchaptertitle{#1}}}% \Huge \bfseries #1
\raisebox{-\dp0}[\ht0][\dp0]{% [\ht0][\dp0] redundant in this case
\includegraphics[height={\dimexpr\ht0+\dp0},width=2cm]{example-image-duck}}%
\hspace{\columnsep}\usebox0%
\afterchaptertitle%
}}
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter[pipes]{Someone finds the old pipes leading downward}
\lipsum[1-6]
\end{document}