페이지마다 각주 카운터를 재설정하는 방법(최악의 경우)

페이지마다 각주 카운터를 재설정하는 방법(최악의 경우)

에 사용된 솔루션이 질문여러 가지 단점이 있습니다. \footnotelayout{m}또는 에서만 작동합니다 \globalcounter{footnote}. 파라콜이 두 페이지 이상 끊어지면 카운터는 다음까지 재설정되지 않습니다.모두열이 플러시됩니다. 단락이 두 페이지에 걸쳐 나누어지면 모든 각주는 첫 페이지에 있다고 생각합니다.

\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하고 (paracol로 이름 변경) paracol은 각 열에 대해 별도의 카운터를 유지하므로 비교를 위해 \footnotemaek카운터를 사용합니다 .lastfootnotepage

각각의 페이지 번호는 \footnoteaux \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}

데모

관련 정보