![标题上方的标题图像](https://linux22.com/image/440053/%E6%A0%87%E9%A2%98%E4%B8%8A%E6%96%B9%E7%9A%84%E6%A0%87%E9%A2%98%E5%9B%BE%E5%83%8F.png)
我正在使用 koma 类 srcbook,为其定义了自定义章节样式:
\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{xcolor}
\definecolor{myblue}{RGB}{26,33,137}
\addtokomafont{disposition}{\usefont{T1}{cmbr}{b}{n}\selectfont\color{myblue}}
\addtokomafont{chapter}{\fontsize{25pt}{25pt}\selectfont}
\newkomafont{chapternumber}{\fontsize{40}{100}\selectfont\color{white}}
\newkomafont{chaptername}{\footnotesize\color{white}}
\renewcommand\chapterformat{%
\raisebox{-6pt}{\colorbox{myblue}{%
\parbox[b][50pt]{40pt}{\centering%
\vspace{2pt}
{\usekomafont{chaptername}{\chaptername}}%
\vfill{\usekomafont{chapternumber}{\thechapter\autodot}}%
\vspace{6pt}%
}}}\enskip}
\begin{document}
\chapter{My chapter}
\blindtext
\end{document}
我想在实际章节标题上方放置一个标题,显示一些与章节主题相关的图形(即,每个章节的标题都不同并且只是可选的)。
它可能非常简单,就像\includegraphics[width=\textwidth]{myheader.pdf}
,但我找不到任何方法将图像放在章节标题上方。
感谢您的任何建议!
答案1
我不知道scrbook
,所以也许还有其他解决方案。
但是使用epigraph
包装就很简单了,您只需根据实际图像调整尺寸和位置即可。
\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{epigraph}
\setlength{\epigraphwidth}{\textwidth}
\usepackage{graphicx}
\definecolor{myblue}{RGB}{26,33,137}
\addtokomafont{disposition}{\usefont{T1}{cmbr}{b}{n}\selectfont\color{myblue}}
\addtokomafont{chapter}{\fontsize{25pt}{25pt}\selectfont}
\newkomafont{chapternumber}{\fontsize{40}{100}\selectfont\color{white}}
\newkomafont{chaptername}{\footnotesize\color{white}}
\renewcommand\chapterformat{%
\raisebox{-6pt}{\colorbox{myblue}{%
\parbox[b][50pt]{40pt}{\centering%
\vspace{2pt}
{\usekomafont{chaptername}{\chaptername}}%
\vfill{\usekomafont{chapternumber}{\thechapter\autodot}}%
\vspace{6pt}%
}}}\enskip}
\renewcommand\chapterheadstartvskip{%
\vspace*{4cm}}
\begin{document}
\chapter{My chapter}\epigraphhead[1cm]{\includegraphics[width=\textwidth, height=5cm]{example-image-duck}}
\blindtext
\chapter{Another chapter}\epigraphhead[1cm]{\includegraphics[width=\textwidth, height=5cm]{example-image}}
\blindtext
\end{document}