在撰写一本长篇书籍(300 到 1000 多页)时,经常需要包含大图片,并且希望将它们显示在两页上,左半部分显示在左页,右半部分显示在右页。如果将图片切成两半并分别包含,则很有可能它们不会分别显示在各自的页面上(即彼此相邻)。
如果需要添加很多图片(每本书 50 到 200 张图片),手动将每张图片分成两半是不可接受的,尤其是如果字体大小的微小变化会改变整个文档,导致图片混乱:左侧部分现在出现在右侧页面,反之亦然。
问题:我如何创建命令
\twopagepicture{position = t or b}{width = l or p}{mypicture.jpg}
具有以下属性:
- t ... 页面顶部
- b ... 页面底部
- l ... 线宽
- p ... 页面宽度
这图片的左半部分显示在左侧页面上(最接近调用命令的地点/文本)和下一页(右)的右半部分。
例如\twopagepicture{t}{l}{mypicture.jpg}
应该这样做:
并且\twopagepicture{t}{p}{mypicture.jpg}
应该这样做:
顺便说一句,我正在使用带有许多软件包的回忆录:
\documentclass[a4paper,twoside, openodd, final]{memoir}
\usepackage[english]{babel}
\usepackage[top=2.4cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{bookman}
\usepackage[pdfpagelayout=TwoPageRight]{hyperref}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{verbatim}
\usepackage{color}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{fancybox}
\usepackage{framed}
\usepackage{lettrine}
\usepackage{tocloft}
\usepackage{pdfpages}
\usepackage{watermark}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makechapterstyle{LOTRchapter}{ \renewcommand{\chapterheadstart}{\vspace*{\beforechapskip}\hrule\medskip} %%
\renewcommand{\chapnamefont}{ \fontsize{10mm}{15mm}\selectfont \bfseries} %%
\renewcommand{\chapnumfont}{ \fontsize{10mm}{15mm}\selectfont \bfseries} %%
\renewcommand{\chaptitlefont}{ \fontsize{10mm}{15mm}\selectfont \bfseries} %%
\renewcommand{\printchaptername}{\fontsize{10mm}{15mm}\selectfont \bfseries Chapter}%%
\renewcommand{\chapternamenum}{ } %%
\renewcommand{\printchapternum}{\chapnumfont \thechapter} %%
\renewcommand{\afterchapternum}{. \\} %%
\renewcommand{\afterchaptertitle}{\par\nobreak\medskip\hrule\vskip \afterchapskip} %%
} %definiramo izgled chapterjev (deluje samo v memoir class-u) %%
\chapterstyle{LOTRchapter} %uporabimo pravkar definirani stil chapterjev %%
%%------------------------------------------------------------------------------------------------------------------%%
\setlength{\parindent}{0.75cm} %zacetni zamik paragrafov %%
\setlength{\parskip}{0ex} %vertikalni razmik med paragrafi (stevilo vrstic) %%
%\par ... nov paragraf %%
\def\thechapter{\arabic{chapter}} %stevilcenje chapterjev z arabskimi stevilkami %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\includepdf[pages={-}]{Cover.pdf}
\leftwatermark{ \put(-56.1,-795){\includegraphics[width=\paperwidth, height=\paperheight]{Background-22.jpg}}}
\rightwatermark{\put(-56.1,-795){\includegraphics[width=\paperwidth, height=\paperheight]{Background-11.jpg}}}
答案1
下面就可以做到。至少需要两次编译器运行才能稳定。由于浮点数很多,可能需要多次编译运行才能使文档稳定。
更新:
现在适用于twoside
模式;现在具有标题支持;添加浮动设置并!
从浮动位置移除以支持较小的图像;将p
图像移动到页面角落。
\documentclass[twoside]{book}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{afterpage}
\usepackage{placeins}
\usepackage{xcolor}
% For the `memoir` class remove the following two packages.
% This class already provide the functionality of both
\usepackage{caption}
\usepackage[strict]{changepage}
%%%
\setcounter{totalnumber}{1}
\setcounter{topnumber}{1}
\setcounter{bottomnumber}{1}
\renewcommand{\topfraction}{.99}
\renewcommand{\bottomfraction}{.99}
\renewcommand{\textfraction}{.01}
\makeatletter
\newcommand*{\twopagepicture}[4]{%
\checkoddpage
\ifoddpage
\expandafter\@firstofone
\else
\expandafter\afterpage
\fi
{\afterpage{%
\if #1t%
\if #2p%
\thispagestyle{empty}%
\afterpage{\thispagestyle{empty}}%
\fi
\fi
\begin{figure}[#1]
\if #2p%
\if #1t%
\vspace*{-\dimexpr1in+\voffset+\topmargin+\headheight+\headsep\relax}%
\fi
\fi
\if #1b%
\caption{#4}%
\fi
\makebox[\textwidth][l]{%
\if #2p\relax
\let\mywidth\paperwidth
\hskip-\dimexpr1in+\hoffset+\evensidemargin\relax
\else
\let\mywidth\linewidth
\fi
\adjustbox{trim=0 0 {.5\width} 0,clip}{\includegraphics[width=2\mywidth]{#3}}}%
\if #1b\else
\caption{#4}%
\fi
\if #2p%
\if #1b%
\vspace*{-\dimexpr\paperheight-\textheight-1in-\voffset-\topmargin-\headheight-\headsep\relax}%
\fi
\fi
\end{figure}%
\begin{figure}[#1]
\if #2p%
\if #1t%
\vspace*{-\dimexpr1in+\voffset+\topmargin+\headheight+\headsep\relax}%
\fi
\fi
\makebox[\textwidth][l]{%
\if #2p%
\let\mywidth\paperwidth
\hskip-\dimexpr1in+\hoffset+\oddsidemargin\relax
\else
\let\mywidth\linewidth
\fi
\adjustbox{trim={.5\width} 0 0 0,clip}{\includegraphics[width=2\mywidth]{#3}}}%
\if #2p%
\if #1b%
\vspace*{-\dimexpr\paperheight-\textheight-1in-\voffset-\topmargin-\headheight-\headsep\relax}%
\fi
\fi
\end{figure}%
}}%
}
\makeatother
\usepackage{lipsum}
\begin{document}
\lipsum
\lipsum
\twopagepicture{b}{l}{image}{Test}
\lipsum
\twopagepicture{t}{l}{image}{Test}
\lipsum
\twopagepicture{b}{p}{image}{Other test}
\lipsum
\twopagepicture{t}{p}{image}{Other test with
very very very very very very very very very very very
very very very very very very very very very very very
very very very very very very very very very very very
long caption
}
\lipsum
\lipsum
\end{document}
(显示的图片是我从顶部拍摄的全景照片布道台山(挪威)
答案2
截至 2021 年中,hvfloat
由 Herbert Voß 开发的该软件包的新版本已在 CTAN 上推出。
除了可以将宽图片分割到两张相对的页面上之外,该软件包还可以旋转图像和标题,并处理带有普通浮点数和表格的单列和双列页面*
。
一篇图文并茂的文章出现在拖船 42:3;在第 43 卷第一期于 2022 年春季出版之前,只有 TUG 会员才能访问。