不寻常的图形和标题位置

不寻常的图形和标题位置

这是牛津大学出版社出版物中的一张图片,其中有两幅图,左边是一张小图,右边是一张大图。不同寻常的是,右边图片的标题也放在了左页上。

示例布局

我确信可能还有其他方法,而且我也尝试了几种,但为了实现布局,我使用左页的页眉放置了标题。

有两个问题令我担忧。

  1. 首先要确保左页上浮动的图像不超过一张图片(否则标题都会出错)。为了防止这种情况发生,我设置了\topnumber=1。不过,我希望稍后更改这个。什么时候更改它才安全?

  2. 将图像添加到图表列表中(不能使用常规技术),因为两个标题都出现在同一页面上,但图像却出现在不同的页面上。

我的目标是拥有一个完全自动化的解决方案,除了输入相关的双图像宏之外无需任何作者干预\doubletakeimage{matron}{stuartpearson}

MWE 略微简化了一点,因为我删除了宽度和高度计算以及附加的格式化命令。此外,标题目前已修复,以方便阅读,并在命令中指定ps@caption

\documentclass{book}
\makeatletter
\usepackage[showframe=true]{geometry}

\newgeometry{left=74.8mm,top=27.4mm,headsep=2\baselineskip,%
marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}
\@twosidefalse \@mparswitchfalse % one side option
\reversemarginpar
            
%% Stick the caption in the head might as well place the first picture also?
\def\asidecaption{\parbox{4.2cm}{{\bfseries Image \thefigure}\par\lorem}%
      }
\def\ps@caption{%
     \let\@oddfoot\@empty\let\@evenfoot\@empty%
    \def\@evenhead{%
        \begin{picture}(0,0)%
            \refstepcounter{figure}
           \put(-150,-80){\asidecaption\par}%
            \refstepcounter{figure}
           \put(-150,-370){\asidecaption}%
        \end{picture}%
      }%
    \let\@oddhead\@evenhead%
    \let\@mkboth\@gobbletwo%
    \let\chaptermark\@gobble%
    \let\sectionmark\@gobble%
 }
\def\doubletakeimage#1#2{%
  \renewcommand{\topfraction}{.95}  % ensure seecond image will not float away
  \begin{figure}[t]
    \thispagestyle{caption}
    \includegraphics[width=\textwidth]{#1}%
  \end{figure}
  \begin{figure}[tp]
   \hspace*{-\marginparwidth}\includegraphics[height=0.9\textheight]{#2}
 \end{figure}
}
\newcommand\lorem{Fusce adipiscing justo nec ante. Nullam in enim.
 Pellentesque felis orci, sagittis ac, malesuada et, facilisis in,
 ligula. Nunc non magna sit amet mi aliquam dictum. In mi. Curabitur
 sollicitudin justo sed quam et quadd. \par}

\usepackage{graphicx}
\usepackage{lipsum}
\graphicspath{{chapters/}}

\renewcommand{\topfraction}{.95}
\renewcommand{\bottomfraction}{.7}
\renewcommand{\textfraction}{.04}
\renewcommand{\floatpagefraction}{.92} % have a high one don't encourage it
\setcounter{topnumber}{1}
\setcounter{bottomnumber}{0}
\setcounter{totalnumber}{3}
\begin{document}

\doubletakeimage{matron}{stuartpearson}
\lipsum[1-4]
\doubletakeimage{matron}{stuartpearson}
\lipsum[1-4]
\end{document}

欢迎并感谢任何有关编码替代和改进的建议。

答案1

下面的 MWE 是一个临时解决方案,因为强制分页会阻止第一张图片的浮动,所以\doubletakeimage需要仔细调整的位置,但是解决了(我承认,很尴尬)图形列表的问题。

\documentclass[twoside]{book}

\usepackage{graphicx}
\usepackage{captdef}
\usepackage{xcolor}
\usepackage{lipsum} 

\def\doubletakeimage#1#2{%
\pagebreak[4]\marginpar{
\figcaption[little caption fig 1]{This is the first very long caption that is linked to the figure 1}
\vspace{9cm}
{Figure \ref{fig:bigger}. This is a second (fake) very long caption for the right figure in the next page}}
\renewcommand{\topfraction}{.95}  % hard float
\begin{figure}[h]% left-side figure
\framebox{
\begin{minipage}[t]{1\columnwidth}%
%   \includegraphics[height=0.9\textheight]{#1}    
Some image called #1 here 
\vspace{5cm}\\
\end{minipage}}
\end{figure}

\begin{figure}[t]% right-side figure

\vspace{2cm}\textcolor{red}{\caption[little caption
fig 2]{\label{fig:bigger}This is the true caption that will be hidden by the image}}\vspace{-2cm}
\framebox{
\begin{minipage}[t]{1\columnwidth}%
%\includegraphics[width=\textwidth]{#2}
Some other bigger image named #2 here
\vspace{7cm}
\end{minipage}}
\end{figure}
}

\begin{document}
\listoffigures
\vspace{3cm}
\section*{Odd page without figures, see next page}
\lipsum[1-2]
\doubletakeimage{matron}{stuartpearson}
\lipsum[1-10]
\end{document}

编辑

此修改可避免强制分页。由于两个图是真正的浮动,因此现在无需找到确切的位置。将其放在\doubletakeimage偶数页的第一个段落之间的某个位置就足够了(不是任何地方:如果位置太低,第一个浮动可能会跳到下一页)。第二个标题的垂直位置由宏本身的位置控制,因为它将出现在同一级别(实际上只是一个边注)。

平均能量损失

% remember to pdflatex this MWE twice ! 
\documentclass{book}
\usepackage[
asymmetric,
marginparsep=.1\textwidth,
marginpar=.3\textwidth,
tmargin=2cm,bmargin=2cm,
left=7cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{captdef}
\usepackage{xcolor}
\usepackage{lipsum} 
\usepackage[margincaption,
 outercaption,raggedright]{sidecap}
\usepackage{marginnote}
\sidecaptionvpos{figure}{t} 
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\fancyfoot[RO, LE] {\thepage}
\fancyfoot[LO, RE] {\leftmark }
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}

\def\doubletakeimage#1#2{% The macro

\begin{SCfigure}[t!] % left-side figure
\includegraphics
[width=\textwidth,height=\textheight,keepaspectratio]{#1}    
\caption[Little caption #1]{
\\ \rule{\linewidth}{0.15em} \bfseries 
Long caption of figure #1. 
\\ \rule{\linewidth}{0.15em} }
\end{SCfigure}

\begin{figure}[t!]% right-side figure
\vspace{2em} %  True  hidden caption
\caption[Little caption #2]{\label{fig:#2}} 
\vspace{-4.2em} 
\hspace{-0.4\textwidth}
\includegraphics[width=1.4\textwidth,
 height=\textheight,keepaspectratio]{#2}
\end{figure}
\marginnote{\raggedright 
 Figure \ref{fig:#2}. (next page) \\ 
\rule{\linewidth}{0.15em} \bfseries 
This is the fake long caption of figure #2.   \\ 
\rule{\linewidth}{0.15em}}
}

\begin{document}
\listoffigures
\chapter{Two figures}
\section{Searching a good place}
\lipsum[1-5] % body text page 3 
\lipsum[5] % good place for the macro 
\lipsum[6] % good place too in "Sed commodo" paragraph  
\doubletakeimage{matron}{stuartpearson}
\lipsum[7] % also can be good place 
\lipsum[8] % still there are room here 
\lipsum[9] % too late to use the macro
\lipsum[10-16] % wait to page 6 to use the macro
\end{document}

相关内容