主题行几乎说明了一切:一些边注(第二页的开头)没有出现在正确的一侧。(问题是:我如何自动修复这个问题?)下面是我从代码中获得的 MWE,我删除了尽可能多的文本(并用垂直空格替换缺失的文本)。我尝试删除一些方程式和 itemize 环境以进一步简化事情,但无法获得正确的值来\vspace
说明问题。
这是我的问题的部分答案...如果我\strictpagecheck
在每个\marginpar
和如果我明确地书写\marginparmargin{outer}
(这应该是默认设置),第二页上的注释都会放在正确的一侧。问题是,之前放在错误一侧的注释现在与其他注释部分重叠。
对作者删除的答案进行评论:我不想要这个oneside
选项,因为这将作为一本书印刷。此外,我试过了,sidepar
但肯定行不通:第一页上的注释在错误的一侧,第二页上的一些注释重叠。最终,我想在页边空白处添加图片和文本。
\documentclass[11pt,openany]{memoir}
\setstocksize{11in}{8.5in}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settypeblocksize{9.0in}{30pc}{*}
\setlrmargins{0.7in}{*}{*}
\setulmargins{1.0in}{*}{*}
\setheadfoot{30pt}{26pt}
\setheaderspaces{*}{30pt}{*}
\setmarginnotes{0.2in}{1.5in}{0.2in}
\checkandfixthelayout
%
\begin{document}
Some text to get things started.
\vspace*{17cm} % to minimize the amount of text on the page.
Some text\marginpar{First note} with some notes in the margin.
Some text\marginpar{Second note} with some notes in the margin.
Some text\marginpar{Third note} with some notes in the margin.
\begin{itemize}
\item First item.
$$A=B$$
\item Second item.
$$A=B$$
\end{itemize}
Yet more text with a note\marginpar{Fourth note} followed by an equation.
$$
A = B
$$
Now we can see the problem.\marginpar{This note is on the wrong side.}.
With some more text\marginpar{And another note on the wrong side.}
so we can perhaps start seeing what is going on.
Some text added with other notes and a reasonably long sentence to keep
the notes somewhat separate\marginpar{Note 1 on the correct side}.
Some text added with other notes and a reasonably long sentence to keep
the notes somewhat separate\marginpar{Note 2 also}.
\end{document}
答案1
这个问题是 LaTeX 的 marginpar 实现所固有的。一个可能的解决方案如下。这使用了 pdftex 的\pdfsavepos
扩展,我认为其他较新的引擎也有类似的扩展。此外,它需要打包并变得更通用(并在多个输入文件上进行测试)。但基本上这个想法是\marginpar
只是将其文本保存在一个框中(实际上是两个框,一个左手版和一个右手版),然后在下一个运行时,LaTeX 使用来自的信息 \pdfsavepos
将边注对齐到辅助文件中保存的标注的垂直位置。如果它与前一个重叠,则会向下移动,定位是通过可收缩胶水完成的,因此如果边注列太满,胶水会收缩(因此注释会向上移动以允许后面的注释适合)。
\documentclass[11pt,twoside]{article}
% Adjust paperheight for more useful image
\makeatletter
\newbox\@mpbox
\global\setbox\@mpbox\vbox{}
\def\savedpos#1#2#3#4{%
\begingroup
\let\@positions\relax
\expandafter\xdef\csname sp@#1-#2\endcsname{%
\expandafter\ifx\csname sp@#1-#2\endcsname\relax
\else
\csname sp@#1-#2\endcsname
\fi
\@positions{#3}{#4}}%
\endgroup}
\def\marginpar#1{%
\saveposition{mpar}%
\global\setbox\@mpbox\vbox{\unvbox\@mpbox\hbox{%
\hbox{\parbox{\marginparwidth}{\@marginparreset\raggedright#1}}%
\hbox{\parbox{\marginparwidth}{\@marginparreset\raggedleft#1}}%
}\break}}
\def\saveposition#1{%
\pdfsavepos\write\@auxout{%
\noexpand\savedpos
{#1}{\the\c@page}{\the\pdflastxpos}{\the\pdflastypos}}}
\def\@oddfoot{%
\hss\thepage\hss\rlap{\hskip\marginparsep\mcolumn}}
\def\@evenfoot{%
\llap{\mcolumn\hskip\marginparsep}\hss\thepage\hss\saveposition{foot}}
\def\mcolumn{%
\saveposition{foot}%
\expandafter\ifx\csname sp@foot-\the\c@page\endcsname\relax
\else
\let\@positions\origin@positions
\csname sp@foot-\the\c@page\endcsname
\smash{\raise\footskip\vbox to \textheight{\hsize\marginparwidth
\hrule\@height\z@
\let\@positions\mp@positions
\csname sp@mpar-\the\c@page\endcsname
\vskip\z@\@plus\textheight
\hrule\@height\z@}}%
\fi}
\def\origin@positions#1#2{%
\@tempdima\z@
\dimen@\textheight
\advance\dimen@\headsep
\advance\dimen@ #2sp
}
\def\mp@positions#1#2{%
\setbox\tw@=\vsplit\@mpbox to \maxdimen
\setbox\tw@\vbox{%
\unvbox\tw@
\setbox\tw@\lastbox
\setbox\tw@\hbox{%
\unhbox\tw@
\ifodd\c@page
\global\setbox1\lastbox
\fi
\global\setbox1\lastbox
}}%
\@tempdimb\dimen@
\advance\@tempdimb-#2sp
\ifdim\@tempdimb<2\p@
\@tempdimb2\p@
\fi
\vskip\@tempdimb\@minus\@tempdimb
\advance\dimen@-\@tempdimb
\advance\dimen@-\ht\@ne
\advance\dimen@-\dp\@ne
\hrule\@height\z@
\box\@ne
\hrule\@height\z@
}
\showboxdepth=2
\showboxbreadth=50
\begin{document}
Some text to get things started.
\vspace*{14cm} % to minimize the amount of text on the page.
\begin{itemize}
\item First item.
$$A=B$$
\item Second item.
$$A=B$$
\end{itemize}
Yet more text with a noteZZ\marginpar{zeroth note} followed by an equation.
\[
A = B
\]
Now we can see the problem.AA\marginpar{This is the first note. I'm making it quite long to see some overlapping with mparhack.}.
With some more textBB\marginpar{Second note}
so we can perhaps start seeing what is going on.
Some text added with other notes and a reasonably long sentence to keep
the notes somewhat separateCC\marginpar{Third note}.
Some text added with other notes and a reasonably long sentence to keep
the notes somewhat separateDD\marginpar{Fourth note}.
\end{document}
答案2
这是一个有趣的问题,但事实证明,它并不局限于memoir
,memoir
只是更适合让它在右边距结束。请看此示例:
\documentclass[11pt]{article}
\usepackage{geometry}
\begin{document}
Some text to get hings started.
\vspace*{14.5cm} % to minimize the amount of text on the page.
\begin{itemize}
\item First item.
$$A=B$$
\item Second item.
$$A=B$$
\end{itemize}
Yet more text with a note\marginpar{Fourth note} followed by an equation.
\[
A = B
\]
Now we can see the problem.AA\marginpar{This is the first note}.
With some more textBB\marginpar{Second note}
so we can perhaps start seeing what is going on.
Some text added with other notes and a reasonably long sentence to keep
the notes somewhat separateCC\marginpar{Third note}.
Some text added with other notes and a reasonably long sentence to keep
the notes somewhat separateDD\marginpar{Forth note}.
\end{document}
我会把它发到别处