# How to reset footnote counter in each column of a two-column document?

Footnote counters can be reset in each page by using either zref-perpage or perpage packages but how do you reset footnote counter in each column of a two column documents?

\documentclass[twocolumn]{article}
\usepackage{zref-perpage}
\zmakeperpage{footnote}
\begin{document}
This is a test\footnote{Test}
\newpage
This is a test\footnote{Test}
\end{document}

-
I doubt that this problem is solvable without an adapted output routine - which makes it hard; multicol might be a start. –  Martin Schröder Nov 5 '12 at 14:57
@MartinSchröder that, or saving some information in the .aux file and having to re-run ;) –  yo' Nov 13 '12 at 21:57

I have a solution that works in combination with

With the help of etoolbox's \preto each time \footnote is called it is checked wether it is used in the first or second column. If it is in the second column the footnote counter is reset if it hasn't been reset before. For this a new conditional is used that is set to true after the resetting and set to false again in the first column.

Although this worked nicely in my tests it might have drawbacks I'm not aware of.

\documentclass[twocolumn]{article}
\usepackage[perpage]{footmisc}
% or
% \usepackage{zref-perpage}
% \zmakeperpage{footnote}
% or
% \usepackage{perpage}
% \MakePerPage{footnote}

\usepackage{lipsum}% dummy text
\usepackage{etoolbox}
\makeatletter
\newif\iffootnoteresetted
\preto\footnote{%
\if@firstcolumn
\footnoteresettedfalse
\else
\iffootnoteresetted\else
\setcounter{\@mpfn}{0}%
\footnoteresettedtrue
\fi
\fi
}{}{}
\makeatother
\begin{document}
This is a test\footnote{Test}
This is a test\footnote{Test}
\lipsum[1-4]
This is a test\footnote{Test}
This is a test\footnote{Test}
\lipsum[1-4]
This is a test\footnote{Test}
This is a test\footnote{Test}
\newpage
This is a test\footnote{Test}
This is a test\footnote{Test}
\end{document}


-
It should work quite well, I'm just not sure about the behaviour in a paragraph that breaks over both columns, because it's first processed and only then broken into lines and pages... –  yo' Nov 2 '12 at 23:21
That's a possible failure I would think. –  clemens Nov 3 '12 at 8:18
I wonder if anyone has the insight if and how there is a way around. I was not able to understand the parts of the kernel where the splitting in two cloumns takes places well enough to find a satisfying solution. –  clemens Nov 6 '12 at 19:57
Yeah, there surely is. Remember that titlesec has the option [left], [right] and through the .aux file it remembers the real position of the sectioning command. The same thing must be possible for footnotes as well. –  yo' Nov 6 '12 at 21:40
That's what I thought and (unsuccessfully) experimented with… –  clemens Nov 7 '12 at 11:14

To show the drawback I speak about, it's too long for a comment.

\documentclass[a4paper,twocolumn]{article}
\usepackage{lipsum}
\makeatletter
\let\@ORG@makecol\@makecol
\gdef\@makecol{\setcounter{footnote}{0}\@ORG@makecol}
\makeatother

\begin{document}

\def\TEST{
This is a test. \footnote{Begin}
This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. \footnote{End} This is a test.\par
}

\TEST\TEST\TEST\TEST\TEST\TEST\TEST\TEST
\TEST\TEST\TEST\TEST\TEST\TEST\TEST\TEST

\end{document}

-

footnote counter needs to be reset at the beginning of \@makecol macro:

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\makeatletter
\let\@ORG@makecol\@makecol
\gdef\@makecol{\setcounter{footnote}{0}\@ORG@makecol}
\makeatother

\begin{document}
This is a test\footnote{Test}
This is a test\footnote{Test}
\lipsum[1-4]
This is a test\footnote{Test}
This is a test\footnote{Test}
\lipsum[1-4]
This is a test\footnote{Test}
This is a test\footnote{Test}
\newpage
This is a test\footnote{Test}
This is a test\footnote{Test}
\end{document}

-
This has the very same drawback as the solution by cgnieder: I won't work in a footnote in paragraph having a pagebreak. –  yo' Nov 4 '12 at 13:23
@tohecz: I doubt about the truth of your statement. –  Vafa Nov 4 '12 at 14:20
Try my CW answer. –  yo' Nov 4 '12 at 14:33
@Vafa just replace the first three lines of your document body with This is a test\footnote{Test}\lipsum[1-3] This is a test\footnote{Test} and you'll see that @tohecz is right. –  clemens Nov 4 '12 at 14:40
Sorry, but I had to downvote this answer. I have no problem with answers being wrong, but I do have a problem with people not willing to admit it. –  yo' Nov 5 '12 at 11:09