如何将图片放入 \part 页面

如何将图片放入 \part 页面

我试图将图像放入与\part页眉相同的页面中,类似于子封面。

我尝试了一些类似的事情:

\documentclass[10pt,ebook,italian,onecolumn,oneside,titlepage,extrafontsizes]{memoir}
\usepackage[italian]{babel}
\usepackage{graphicx}
...
\title{Book Title}
\begin{document}
\frontmatter
\maketitle
\mainmatter
\chapterstyle{companion}
\tableofcontents
\part{Part I Title}
\includegraphics[width=\linewidth]{PartIcover.jpg}
\chapter{First Chapter TItle}

这种方法不太有效,原因有二:

  • 图像并不位于“第一部分标题”之后,而是位于下一页。
  • \part在图像页面中,我得到了一个虚假的“INDEX #”标题(当然,它并不存在于页面中)

是否可以达到预期的效果?(页面顶部为“第一部分标题”,其下方为图片)。

如果是,那么怎么办?

注意:我对 LaTeX 还只是个新手,请大家多多包涵。

更新:根据评论中的建议,我做了以下工作;虽然有效,但至少可以说很脆弱:

\documentclass[...]{memoir}
\usepackage[italian]{babel}
\usepackage{graphicx}
...
\def\@partimage{}
\newcommand{\partimage}[2][]{\gdef\@partimage{\includegraphics[#1]{#2}}}
\renewcommand{\printparttitle}[1]{\parttitlefont #1\vfil\@partimage\vfil\gdef\@partimage{}}
\makeatother
...
\title{Book Title}
\begin{document}
\frontmatter
\maketitle
\mainmatter
\chapterstyle{companion}
\tableofcontents
\partimage[width=210pt]{PartIcover.jpg}
\part{Part I Title}
\includegraphics[width=\linewidth]{PartIcover.jpg}
\chapter{First Chapter Title}

这非常脆弱,因为我需要手动计算\part标题后的剩余高度。

我看见这个答案,但我不确定如何在上面的代码中使用它。

答案1

感谢您使用我发布到 SE 的有关 40602 和 452089 的代码。

我不清楚您是否会为每个部分使用相同或不同的图形,\part以及您希望如何将它们放置在页面上 --- 填充\textwidth或占据部分标题文本下方的所有空间(您可能无法同时拥有两者)。但是,这可能会有所帮助(减少任何拼写错误)

\documentclass{memoir}
\usepackage{graphicx}
\makeatletter
\def\@partimage{}
\newcommand{\partimage}[2][]{\gdef\@partimage{\includegraphics[#1]{#2}}}
\renewcommand{\printparttitle}[1]{\parttitlefont #1\vfil\@partimage\vfil\gdef  \@partimage{}}
\makeatother
\begin{document}
\partimage[height=0.5\textheight,width =\textwidth,keepaspectratio]{example-image-duck-portrait.pdf}
\part{A Part}
\partimage[height=0.5\textheight,width=\textwidth,keepaspectratio]{example-image-duck.pdf}
\part{Another Part}
\partimage[height=0.5\textheight,width=\textwidth,keepaspectratio]{example-image-duck-portrait.pdf}
\part{Another Part}
\partimage[height=0.5\textheight,width=\textwidth,keepaspectratio]{example-image-duck-portrait.pdf}
\part{The Third}
\end{document}

上述示例将在同一页上放置一个与\part标题相同的插图,限制在一半\textheigt和的尺寸内\textwidth,同时保持插图的纵横比。该示例说明了如何将不同的插图应用于每个\part

戈美

相关内容