
ミニページ内では、ミニページの最後に印刷される脚注を使用します。また、他のフロート (主に図フロート) 内で使用するため、と を にmarginnote
再定義します。さらに、余白に todo を印刷するためにを使用します。\marginpar
\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}
結果:
答え1
明らかに、\todo
の代わりにミニページが使用されています\parbox
。脚注を含むミニページをネストする場合も同じことが起こります。
このソリューションは、前の脚注を保存し\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}