如何重置每頁腳註計數器(最壞的情況)?

如何重置每頁腳註計數器(最壞的情況)?

使用的解決方案是這個問題有幾個缺點。它僅適用於\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都寫入 aux 檔案中,因為這是為分兩頁的段落獲取正確頁碼的唯一方法。然而,需要運行兩次才能起作用。

事實證明,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}

示範

相關內容