使用邊註的待辦事項註釋之前的小頁內的腳註最終位於待辦事項註釋的底部

使用邊註的待辦事項註釋之前的小頁內的腳註最終位於待辦事項註釋的底部

在小型頁內,我使用應列印在小型頁末尾的腳註。我還使用marginnote並重新定義\marginpar為 be \marginnote,因為我在其他浮點數(主要是數字浮點數)中使用它們。此外,我常常todonotes在頁邊空白處列印待辦事項。

如果我將所有內容一起使用,則小型頁面中的 todonote 會「吞噬」所有已鍵入但尚未列印的腳註,並將腳註印在其自己的底部,即在 todonote 的底部。

微量元素

\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}

結果:

擴充的MWE

答案1

顯然\todo使用小型頁面而不是\parbox.當使用腳註嵌套小型頁面時,也會發生相同的情況。

此解決方案會保存先前的腳註\todo並在之後恢復。

請注意,它\@mpfootins是全局保存的,這允許腳註在組之外工作。但是 snce\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}

相關內容