我的每个章节标题都在一页上,内容在下一页上。我为每个页面添加了标准背景图像。但我想做的是能够为每个章节添加不同的背景图像。我希望做这样的事情:
\chapter{Another chapter}[background1.jpeg]
\chapter{Another chapter}[background2.jpeg]
然后能够引用background1.jpeg
并background2.jpeg
作为\titleformat
某种参数。这可能吗?
这是完整的 Latex:
\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{imakeidx}
\usepackage{lmodern}
\usepackage{titlesec}
\usepackage{eso-pic}
\usepackage{lipsum}
\titleformat{\chapter}[display]
{\vfill\filcenter}
{{%
\filcenter\fontsize{24pt}{24pt}\usefont{T1}{phv}{m}{n}{\chaptername}
\fontsize{24pt}{24pt}\selectfont\thechapter%
\AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{"background.jpeg"}}
}%
}
{5pt}
{
\fontsize{48pt}{48pt}\selectfont%
}[\vfill\clearpage]
\titlespacing*{\chapter}{0pt}{0pt}{0pt}
\titleformat{name=\chapter,numberless}[display]
{\filcenter}
{{%
}%
}
{5pt}
{\Huge\usefont{T1}{phv}{b}{n}%
}
\begin{document}
\setcounter{chapter}{21}
\chapter{Chapter Title}
\section{Section one}
\lipsum[1]
\section{Section two}
\chapter{Another chapter}
\section{Section one}
\lipsum[2]
\end{document}
环境
xelatex --version
MiKTeX-XeTeX 4.7.1 (MiKTeX 22.1)
© 1994-2008 SIL International, © 2009-2021 Jonathan Kew, © 2010-
2012 Hàn Thế Thành, © 2012-2013 Khaled Hosny
TeX is a trademark of the American Mathematical Society
using bzip2 version 1.0.8, 13-Jul-2019
compiled with curl version 7.77.0; using libcurl/7.79.1
SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.45.1
compiled with expat version 2.4.1; using expat_2.4.1
compiled with fontconfig version 2.13.1; using 2.13.1
compiled with freetype2 version 2.11.1; using 2.11.1
compiled with graphite2 version 1.3.14; using 1.3.14
compiled with harfbuzz version 2.7.2; using 2.7.2
compiled with icu version 69.1; using 69.1
compiled with jpeg version 9.5
compiled with liblzma version 50020052; using 50000052
compiled with libpng version 1.6.37; using 1.6.37
compiled with MiKTeX Application Framework version 4.3; using 4.3
compiled with MiKTeX Core version 4.11; using 4.11
compiled with MiKTeX Archive Extractor version 4.0; using 4.0
compiled with MiKTeX Package Manager version 4.6; using 4.6
compiled with openssl version OpenSSL 1.1.1m 14 Dec 2021; using
OpenSSL 1.1.1m 14 Dec 2021
compiled with pplib version v2.05 less toxic i hope
using teckit version 2.4
compiled with uriparser version 0.9.6
compiled with zlib version 1.2.11; using 1.2.11
答案1
试试这个代码:
\documentclass[10pt,a4paper]{book}
\usepackage{graphicx,lipsum,emptypage}
\usepackage[placement=center]{background}
\begin{document}
\chapter{One}
\backgroundsetup{contents=To review,color=blue!30} %in place of 'To review' you put your image
\newpage
\backgroundsetup{contents=}
% partial index of the chapter
\chapter{Two}
\backgroundsetup{contents=Confidential,color=blue!30} %in place of 'Confidential' you put your image
\newpage
\backgroundsetup{contents=}
% partial index of the chapter
\end{document}
输出: