我想sidecaption
在带有回忆录的图形中使用环境,并使标题文本与文本块不对齐。但是当将图形移动到下一页时,标题在正确的一侧,但不对齐是错误的。我根据回忆录手册创建了以下 MWE,但即使这样也\strictpagecheck
不起作用,无论我运行多少次 luatex:
\documentclass[a4paper,twoside,draft]{memoir}
\usepackage{fixltx2e}
\usepackage{calc}
\usepackage{luatextra}
\usepackage{lipsum}
\usepackage{ragged2e}
\marginparmargin{outer}
\setmpjustification{\RaggedLeft}{\RaggedRight}
% margin figure and caption typeset ragged against text block
\setfloatadjustment{marginfigure}{\mpjustification}
\setmarginfloatcaptionadjustment{figure}{\captionstyle{\mpjustification}}
\sidecapmargin{outer}
\setsidecappos{t}
\setsidecaps{\marginparsep}{\marginparwidth}
\setlength{\fboxsep}{0pt}
\begin{document}
\lipsum[1]
\begin{figure}[p]
\strictpagecheck
\begin{sidecaption}{This is an example text. It should be ragged on the page
border, not on the side of the figure.}
\fbox{\parbox[t][\textheight - 4pt][c]{\linewidth - 3pt}{test}}
\end{sidecaption}
\end{figure}
\lipsum
\end{document}
答案1
比较简单,基本上我们只需要\m@mscapcheckside
在内容存入盒子之前执行
\makeatletter
\def\endsidecaption{%
\m@mscapend@fbox
\refstepcounter\@captype
\m@mscaplabel
\m@mscapcheckside %<---- added this
\begin{lrbox}{\m@mscap@capbox}%
\begin{minipage}[c]{\sidecapwidth}%
\sidecapstyle
\@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
\end{minipage}%
\end{lrbox}%
\m@mscapopboxes}
\renewcommand*{\m@mscapopboxes}{%
\m@mcalcscapraise
\usebox{\m@mscap@fbox}%\m@mscapcheckside %<--- removed here
\ifscapmargleft%
\rlap{\kern-\m@mscaplkern
\raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
\else%
\rlap{\kern\sidecapsep
\raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
\fi
\gdef\m@mscapthisside{}%
\@mem@scap@afterhook%
}
\makeatother
答案2
Lars Madsen 在 comp.text.tex 上写道:
这似乎奏效了
\def\endsidecaption{%
\m@mscapend@fbox
\refstepcounter\@captype
\m@mscaplabel
\def\mem@evil{\begin{minipage}[c]{\sidecapwidth}%
\sidecapstyle
\@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
\end{minipage}}%
\begin{lrbox}{\m@mscap@capbox}%
\mem@evil
\end{lrbox}%
\m@mscapopboxes}
\renewcommand*{\m@mscapopboxes}{%
\m@mcalcscapraise
\usebox{\m@mscap@fbox}\m@mscapcheckside
\ifscapmargleft%
\rlap{\kern-\m@mscaplkern
\raisebox{\m@mscapraise}{\mem@evil}}%
\else%
\rlap{\kern\sidecapsep
\raisebox{\m@mscapraise}{\mem@evil}}%
\fi
\gdef\m@mscapthisside{}%
\@mem@scap@afterhook%
}
基本上,我们需要两样东西,我们需要将标题放在一个框内以便进行一些测量,并且我们需要确保标题实际上是在正确的时刻排版的。