在迷你页面中,我使用脚注,这些脚注应打印在迷你页面的末尾。我还使用marginnote
和重新定义\marginpar
为\marginnote
,因为我在其他浮动(主要是图形浮动)内使用它们。此外,我使用todonotes
在页边距中打印待办事项。
如果我将所有内容一起使用,迷你页面中的待办事项会“吞下”所有已经输入但尚未打印的脚注,并将脚注打印在其自己的底部,即待办事项的底部。
平均能量损失
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{marginnote} % Enhanced marginpar
\usepackage{todonotes}
%
% We need to redefine \marginpar.
% \marginpar does not work inside floats, but \marginnote does.
% Also \todo uses \marginpar internally and this way it actually uses \marginnote.
% See manual for marginnote and sec. 1.6.8 in the manual for todonotes.
%
\renewcommand{\marginpar}{\marginnote}
\begin{document}
\begin{figure}[htbp]\centering
\begin{minipage}{.5\linewidth}
This is a sentence with a footnote.\footnote{It only serves as an example.}
Now a sentence with \todo{The footnote ends up in the margin.}a \texttt{todo}-note follows.
However, the last footnote is printed at the end of the minipage\footnote{Because it is inserted after the \texttt{todo}-note.}.
\end{minipage}
\end{figure}
\end{document}
输出:
我该如何纠正此行为?注意,我确实不需要在 todonote 或任何其他边注中使用脚注。因此,如果可能的话,一个可行的解决方案可能是禁用边注的脚注。
扩展 MWE 以修复以下答案
这最初提出的答案(见下文)存在一些错误,正如以下扩展的 MWE 所指出的那样:a)如果小页面不包含任何脚注,它还会绘制一条分隔线。b)如果在小页面内使用列表环境,脚注将完全丢失。
\documentclass[american]{article}
\usepackage[TS1,T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{marginnote}
\usepackage{todonotes}
%
% We need to redefine \marginpar.
% \marginpar does not work inside floats, but \marginnote does.
% Also \todo uses \marginpar internally and this way it actually uses \marginnote.
% See manual for marginnote and sec. 1.6.8 in the manual for todonotes.
%
\renewcommand{\marginpar}{\marginnote}
\newsavebox{\mpfootsave}
\makeatletter
\newcommand{\mytodo}[1]{%
\setbox\mpfootsave=\vbox{\unvbox\@mpfootins}%
\todo[caption={}]{#1}%
\setbox\@mpfootins=\vbox{\unvbox\mpfootsave}%
}
\makeatother
\begin{document}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
This is a sentence with a footnote.\footnote{It only serves as an example.}
Now a sentence with \mytodo{The footnote ends up in the margin.}a \texttt{todo}-note follows.
However, the last footnote is printed at the end of the minipage\footnote{Because it is inserted after the \texttt{todo}-note.}.
\end{minipage}
\end{figure}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
The solution works only partially, if there is no footnote after the last \mytodo{Like this}\texttt{todo}-note.
The seperation line is printed even if there is no footnote at all.
\end{minipage}
\end{figure}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
\begin{enumerate}
\item
Even with an enumeration, the \mytodo{Another todo}solution works.
But only if the footnote comes last.\footnote{It only serves as an example.}
\end{enumerate}
\end{minipage}
\end{figure}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
\begin{enumerate}
\item
But the solution\footnote{Actually, the proposed solution.} fails in combination with an enumeration, if a \mytodo{Yet another todo}\texttt{todo}-note appears after the last footnote.
\end{enumerate}
\end{minipage}
\end{figure}
\end{document}
结果:
答案1
显然\todo
使用的是 minipage 而不是\parbox
。当使用脚注嵌套 minipage 时也会发生同样的事情。
此解决方案先保存之前的脚注\todo
,然后再恢复。
请注意,它\@mpfootins
是全局保存的,这样脚注就可以脱离组。但由于它\footsave
是本地保存的,因此可以使用这种方法来修复嵌套的迷你页面。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{marginnote} % Enhanced marginpar
\usepackage{todonotes}
%
% We need to redefine \marginpar.
% \marginpar does not work inside floats, but \marginnote does.
% Also \todo uses \marginpar internally and this way it actually uses \marginnote.
% See manual for marginnote and sec. 1.6.8 in the manual for todonotes.
%
\renewcommand{\marginpar}{\marginnote}
\newsavebox{\footsave}
\makeatletter
\newcommand{\mytodo}[2][]{% same arguments as \todo
\setbox\footsave=\box\@mpfootins
\todo[#1]{#2}%
\global\setbox\@mpfootins=\box\footsave}
\makeatother
\begin{document}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
This is a sentence with a footnote.\footnote{It only serves as an example.}
Now a sentence with \mytodo{The footnote ends up in the margin.}a \texttt{todo}-note follows.
However, the last footnote is printed at the end of the minipage\footnote{Because it is inserted after the \texttt{todo}-note.}.
\end{minipage}
\end{figure}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
The solution works only partially, if there is no footnote after the last \mytodo{Like this}\texttt{todo}-note.
The seperation line is printed even if there is no footnote at all.
\end{minipage}
\end{figure}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
\begin{enumerate}
\item
Even with an enumeration, the \mytodo{Another todo}solution works.
But only if the footnote comes last.\footnote{It only serves as an example.}
\end{enumerate}
\end{minipage}
\end{figure}
\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
\begin{enumerate}
\item
But the solution\footnote{Actually, the proposed solution.} fails in combination with an enumeration, if a \mytodo{Yet another todo}\texttt{todo}-note appears after the last footnote.
\end{enumerate}
\end{minipage}
\end{figure}
\end{document}