这个问题导致了一个新的方案的出现:
parnotes
如何才能使脚注或尾注文本立即出现在提及它的段落之后?
更新:
由于我的问题缺乏足够的细节,我会尽力澄清。
- 目标是使注释更接近读者并使得文档从头到尾流畅,而不是被脚注不断打断。
- 我所说的“脚注”或“尾注”是指带有交叉引用标记(例如“1”)并指向页面上另一位置(段落末尾)的任何内容。
更新:
提供的答案很好地解决了初始问题。但是,它与附加软件包提供的许多其他选项不兼容,例如footmisc
及其包含的选项,例如para
和stable
。赏金将用于扩展解决方案,该解决方案:
mark
提供在不同位置定义和的功能text
,以便将脚注标记放置在章节标题内(请参阅footnotemark
和footnotetext
和stable
选项中的示例footmisc
)。例如:\begin{footnotepar} \section{This is a section title\footnotemark} \footnotetext{This is the text for a footnote which has a mark in the section title.} This is text in the paragraph. \end{footnotepar}
将脚注文本视为与标准段落中的文本无异,并允许文本以类似的方式运行(例如流入段落、在页面末尾断开)。例如:
1 这是第一个脚注的文本。 2 这是
第二个脚注。3 这是第三个脚注的正文。
4 这是第四个脚注的文本。 5 这是
第五个脚注部分出现在
第二页。6这是第六个脚注的正文。
- 留下点来统一控制脚注标记(出现在脚注附近的标记)、脚注文本本身的大小、字体和位置以及每个脚注后的空格(例如,放置
\newline
到新行,或者\hspace
添加一些空格)。 - 留下点来均匀地包围每组脚注的环境,例如,使脚注文本组能够被和
\begin{multicols}{2}
(\end{multicols}
或其他环境)包围。
答案1
您可以将每个段落放入一个小页面中,因为小页面有自己的脚注:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\newenvironment{mpar}{\par\noindent\minipage{\linewidth}%
\setlength{\parindent}{1em}%
}{\endminipage\par\medskip}
\begin{document}
\section{Test}
\blindtext
\begin{mpar}First example.\footnote{A note at the foot of the minipage}
\blindtext\end{mpar}
\begin{mpar}Second example.\footnote{A note at the foot of the minipage}
\blindtext\end{mpar}
\blindtext
\end{document}
或者您可以定义一个环境,该环境仅复制脚注功能minipage
:
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\newenvironment{footnotepar}{%
\par
\def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
\let\@footnotetext\@mpfootnotetext
}{%
\ifvoid\@mpfootins\else
\vskip\skip\@mpfootins
\normalcolor
\footnoterule
\unvbox\@mpfootins
\fi
\par\smallskip
}
\makeatother
\begin{document}
\lipsum[1-3]
\begin{footnotepar}Lipsum test:\footnote{lipsum is a
package}\lipsum[2]\end{footnotepar}
\begin{footnotepar}Another\footnote{Not really another one}
test:\footnote{This is a lipsum test}\lipsum[3]\end{footnotepar}
\lipsum[4]
\end{document}
答案2
这是
parnotes
包裹。笔记对于任何想要“做X每段之后”:对 进行长期修改的正确方法
\par
是通过\@setpar
,或通过\@par
与 一起修改\par
。许多 LaTeX 环境会\par
在\@par
末尾重置为;请参阅来源2e章节ltpar.dtx
。
这里有一个技巧,用于\g@addto@macro
收集笔记,然后将它们放在主文本流中。使用\parnote{TEXT}
放置标记,然后调用 手动\parnotes
将笔记放在您想要的任何位置。对于自定义标记,请使用\parnote[MARK]{TEXT}
。
还有一个环境,通过重新定义和,autopn
在每个段落末尾自动设置 parnotes 。如果您在其中进入另一个环境并且仍然想要注释,则需要在其中嵌套。(感谢 Ahmed Musa)\par
\@par
autopn
autopn
\documentclass{article}
\usepackage{multicol}
\makeatletter
% Format for parnotes - \PN@notes@shape is blank (\relax) by default
\providecommand{\parnotefmt}[1]{\footnotesize%
\PN@notes@shape\PN@narrower@optional\noindent #1}
% Format for parnote marks
\providecommand{\parnotemark}[1]{\textsuperscript{#1}}
% Minimum vertical space before and after parnotes
\providecommand{\parnotevskip}{\medskipamount}
% Full command used between parnotes
\providecommand{\parnoteintercmd}{\hspace{1em plus 0.3em minus 0.2em}}
\global\def\PN@text{}
\global\newcount\c@parnotemark
\def\@PN@autopn{autopn}
\newif\ifPN@inparnotes
\def\PN@disable@indent{\@afterindentfalse\@afterheading}
\let\PN@reset@optional\relax
\let\PN@mark@set\@arabic
\let\PN@narrower@optional\relax
\let\PN@notes@shape\relax
\newcommand\parnote{%
\ifx\protect\@typeset@protect
\@ifnextchar [
{\expandafter\PN@parnote@twoargs}%
{\expandafter\PN@parnote@onearg}%
\else
\expandafter\PN@gobble@opt
\fi
}
\DeclareRobustCommand\PN@gobble@opt{%
\@ifnextchar [
\PN@gobble@opt@@
\@gobble
}
\def\PN@parnote@twoargs[#1]#2{\PN@parnote@real{#1}{#2}}
\def\PN@parnote@onearg#1{%
\global\advance\c@parnotemark\@ne
\begingroup\edef\@x{\endgroup\noexpand\PN@parnote@real%
{\PN@mark@set{\c@parnotemark}}}\@x{#1}%
}
\def\PN@gobble@opt@@[#1]#2{}
\long\def\PN@parnote@real#1#2{%
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
\parnotemark{#1}%
\ifhmode\spacefactor\@x@sf\fi\relax
\unless\ifx\PN@text\@empty\g@addto@macro\PN@text{\parnoteintercmd}\fi
\g@addto@macro\PN@text{\parnotemark{#1}\nolinebreak\thinspace#2}%
}
\newcommand\parnotes{%
\unless\ifx\PN@text\@empty
\expandafter\PN@parnotes@real
\fi
}
\def\PN@parnotes@real{%
\PN@inparnotestrue
\unless\ifvmode\par\fi
\nopagebreak\addvspace{\parnotevskip}%
{\parnotefmt{\PN@text}\par}%
\global\def\PN@text{}%
\addvspace{\parnotevskip}%
\PN@disable@indent
\PN@reset@optional
\PN@inparnotesfalse
}
\newenvironment{autopn}{%
\let\PN@par\par
\def\par{\PN@parnotes@auto\PN@par}%
\def\@par{\PN@parnotes@auto\@@par}%
}
{\PN@parnotes@auto}
\def\PN@parnotes@auto{%
\ifx\@currenvir\@PN@autopn
\unless\ifPN@inparnotes
\unless\ifx\PN@text\@empty
\expandafter\PN@parnotes@real
\fi
\fi
\fi
}
\makeatother
\begin{document}
\tableofcontents
\vspace{0.3in}
\begin{autopn}
\noindent%
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\section{On parnotes\parnote{Section note.}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
Ut vel ante eros, in lobortis risus.
Lorem ipsum dolor.
\vspace{0.1in}
\noindent Notes inside \texttt{multicols}:
\begin{multicols}{2}
\begin{autopn} % CHANGED: YOU MUST NEST autopn WITHIN ENVIRONMENTS
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Integer aliquet quam\parnote{Vitae mauris tempus!} consequat.
New paragraph vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{autopn}
\end{multicols}
\end{autopn}
\noindent Notes outside \texttt{multicols}:
\begin{multicols}{2}
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Integer aliquet quam\parnote{Vitae mauris tempus!} consequat.
New paragraph vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{multicols}
\parnotes
\vspace{0.1in}
\noindent Notes break pages:\\[0.08in]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus consequat. In nec neque vitae magna
pulvinar pretium. Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae. In aliquet tortor sed tellus
Porta et elementum diam sagittis. Lorem ipsum dolor sit amet,
pulvinar pretium. Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae. In aliquet tortor sed tellus
Porta et elementum diam sagittis. Lorem ipsum dolor sit amet,
consectetur adipiscing elit.} In nec neque vitae magna pulvinar
pretium.
\parnotes
\end{document}
答案3
\begin{filecontents*}{parnotes.sty}
\ProvidesPackage{parnotes}[2011/12/10 v0.0.1 Paragraph notes (Ahmed Musa)]
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\RequirePackage{combokeys}
\let\parnotesnosep\medbreak
\declarecombokeys[keyprefix=KVA,keyfamily=parnotes,macroprefix=pnt@]{%
cmd/notecolor/black;
cmd/noteformat/\@firstofone;
cmd/notefont/\footnotesize;
cmd/markformat/\@firstofone;
cmd/vskip/\medskipamount;
cmd/interskip/.5em;
}
\protected\def\declareparnotesformat#1{%
\setkeys[KVA]{parnotes}{#1}%
}
\newcommand*\pnt@hook{}
\newcount\pnt@cnta
\@ifdefinable\parnote\relax
\protected\def\parnote#1{%
\dkyifx\protect\@typeset@protect{%
\global\advance\pnt@cnta\@ne
\xdef\pnt@hook{%
\dkyexpandonce\pnt@hook
\begingroup
\noindent
\dkyexpandonce\pnt@notefont
\noexpand\color{\pnt@notecolor}%
\dkyexpandonce\pnt@markformat{%
\noexpand\textsuperscript{\number\pnt@cnta}%
}%
\dkyexpandonce\pnt@noteformat{\unexpanded{~#1}}%
\noexpand\hspace{\pnt@interskip}%
\endgroup
}%
\ifvmode\else\unskip\fi
\pnt@markformat{\textsuperscript{\number\pnt@cnta}}%
}{}%
}
\protected\def\pnt@print{%
\pnt@hook
\global\pnt@cnta\z@
\gdef\pnt@hook{}%
\@saved@par
\vspace{\pnt@vskip}%
\@afterindentfalse\@afterheading
}
\newenvironment{parnotes}{%
\let\@saved@par\par
\def\par{%
\@saved@par
\dkyifx\pnt@hook\@empty{}{%
\vspace{\pnt@vskip}%
\parskip\z@
\pnt@print
}%
}%
}{%
\dkyifx\pnt@hook\@empty{}{%
\@saved@par
\vspace{\pnt@vskip}%
\parskip\z@
\pnt@print
}%
\let\par\@saved@par
\let\@saved@par\@undefined
\par
}
\endinput
\end{filecontents*}
\documentclass{article}
\usepackage{multicol}
\usepackage{parnotes}
\usepackage[table,dvipsnames,hyperref]{xcolor}
\declareparnotesformat{%
noteformat=\textsf,markformat=\textsf,notecolor=ForestGreen,
notefont=\footnotesize,vskip=\medskipamount,
interskip=.5em
}
\begin{document}
\begin{parnotes}
\section{Let us start with a multicolumn}
\begin{multicols}{2}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam \parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium. \parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{multicols}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\section{On parnotes\parnote{Section note.}}
\parnotesnosep
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
Ut vel ante eros, in lobortis risus. Nullam pretium, ipsum sit amet
pharetra faucibus, felis diam aliquet sem, bibendum eleifend turpis metus
in ligula.
\vspace{2ex}
\noindent
Notes outside \texttt{multicols}:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\parnotesnosep
\noindent Notes inside \texttt{multicols}:
\begin{multicols}{2}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{multicols}
\noindent Notes break pages:\\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{parnotes}
\end{document}
答案4
为了避免重复输入\parnotes
,可以进行类似以下的操作,但我现在没有时间查看这种情况下多列的行为。
\def\beginparnotes{%
\let\@saved@par\par
\def\par{%
\@saved@par
\vspace{\parnotevskip}%
\parskip\z@
\ifx\PN@text\@empty\else
\expandafter\parnotes
\fi
}%
}
\def\endparnotes{%
\ifx\PN@text\@empty\else
\@saved@par
\vspace{\parnotevskip}%
\parskip\z@
\expandafter\parnotes
\fi
\let\par\@saved@par
}
\def\parnotes{%
\parnotefmt{\PN@text}%
\global\def\PN@text{}%
\global\c@PN@t=\c@PN@n
\vspace{\parnotevskip}%
\@afterindentfalse\@afterheading
}
另请注意\unskip
以下几点:
\long\def\PN@parnote@real#1{%
\global\advance\c@PN@t\@ne
\g@addto@macro\PN@text{%
\global\advance\c@PN@n\@ne
\parnotemarkfmt{PN@n}~#1\hspace{\parnoteinterspace}%
}%
\unskip\parnotemarkfmt{PN@t}%
}
\begin{document}
\beginparnotes
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam \parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium. \parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat. Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\endparnotes
\end{document}