如何重置每一页的脚注计数器(最坏的情况)?

如何重置每一页的脚注计数器(最坏的情况)?

所用溶液这个问题有几个缺点。它只适用于\footnotelayout{m}\globalcounter{footnote}。如果 paracol 超过两页,计数器不会重置,直到全部列被刷新,如果一个段落跨越两页,任何脚注都会认为它们在第一页。

\documentclass{article}
\usepackage{paracol}
\usepackage[nopar]{lipsum}

\usepackage{everypage}
\AddEverypageHook{\setcounter{footnote}{0}}

\begin{document}
\sloppy
\begin{paracol}{2}
  left column\footnote{a footnote}
  \switchcolumn%  
  right column\footnote{a footnote}

  \switchcolumn*% 
  \lipsum[1-3]\footnote{2nd footnote}
  \switchcolumn%      
  \lipsum[1-3]\footnote{2nd footnote}
\end{paracol} 
\end{document}

以下屏幕截图演示了此问题:

演示

答案1

此解决方案修改了\footnote\footnotemaek由 paracol 重命名)以在页面更改时重置计数器。它使用计数器lastfootnotepage进行比较,因为 paracol 为每列维护单独的计数器。

\footnote每个段落的页码\footnotemark都会写入辅助文件,因为这是获得跨两页段落正确页码的唯一方法。但是,需要运行两次才能成功。

事实证明,paracol 已经提供了迄今为止\footnotes 和s总数的索引。\footnotemark

\documentclass{article}
\usepackage{paracol}
\usepackage[nopar]{lipsum}

\newcounter{footnotepage}
%\globalcounter{footnotepage}% only use with \footnotelayout{m}

\makeatletter
\newcommand{\checkfootnotepage}{%
  \protected@write\@auxout{}{\string\newfootnotepage{\number\pcol@nfootnotes}{\thepage}}%
\bgroup
  \@ifundefined{footnotepage\number\pcol@nfootnotes}{\count1=\value{page}}%
    {\count1=\csname footnotepage\number\pcol@nfootnotes\endcsname\relax}%
  \ifnum\value{footnotepage}<\count1\relax
    \setcounter{footnotepage}{\count1}%
    \setcounter{footnote}{0}%
  \fi
\egroup}

\newcommand{\newfootnotepage}[2]% #1 = index, #2 = page
 {\expandafter\xdef\csname footnotepage#1\endcsname{#2}}

\def\pcol@@footnote{% footnote for paracol
  \@ifnextchar[\@xfootnote{\checkfootnotepage
    \stepcounter\@mpfn
    \protected@xdef\@thefnmark{\thempfn}%
    \@footnotemark\@footnotetext}}

\def\pcol@@footnotemark{% \footnotemark for paracol
  \@ifnextchar[\@xfootnotemark
    {\checkfootnotepage% added
    \stepcounter{footnote}%
    \protected@xdef\@thefnmark{\thefootnote}%
    \@footnotemark}}
\makeatother

\begin{document}
\sloppy
\begin{paracol}{2}
  left column\footnote{a footnote}
  \switchcolumn%  
  right column\footnote{a footnote}

  \switchcolumn*% 
  \lipsum[1-3]\footnote{2nd footnote}
  \switchcolumn%      
  \lipsum[1-3]\footnote{2nd footnote}
\end{paracol} 
\end{document}

演示

相关内容