[Tex/LaTex] Circled footnote symbols with pifont showing arrows instead of circled numbers

footnotespifont

I like the change of the footnote appearances with the pifont package

\usepackage{pifont}
\renewcommand\thefootnote{\ding{\numexpr171+\value{footnote}}}

but I have many footnotes [though never more than 20 a page] and after a while, I get the arrows 212, 213 and so on
which can be viewed below:

enter image description here

How do I make a loop to start again at 172 ?
Or better, how can I get numbers 11,12,13 circled instead of beginning from 1,2,3 each time ?

There is a fix here
http://valis.cs.illinois.edu/blog/?p=5809
but I get that my counters are too large…

Would it be simpler to use the libertine fonts since they seem to have more circled numbers:
Good way to make \textcircled numbers?

Also, I must add that I use the mathdesgin package so perhaps it is even easier to use its \figurecircled command as stated in the previous link ?

Best Answer

Counter representation command

With circled numbers of package pifont only twenty (or ten) values for the footnote counter can be used. Thus there should be a warning or error, if the footnote counter is out of this range.

For this purpose, we define a counter representation command \circnum that behaves similar to \alph:

\documentclass{article}
% smaller image for TeX.SX
\usepackage[paperwidth=20mm,paperheight=20mm,margin=1mm]{geometry}

\usepackage{pifont}
\makeatletter
\newcommand*{\circnum}[1]{%
  \expandafter\@circnum\csname c@#1\endcsname
}
\newcommand*{\@circnum}[1]{%
  \ifnum#1<1 %
    \@ctrerr
  \else
    \ifnum#1>20 %
      \@ctrerr
    \else
      \ding{\the\numexpr 171+(#1)\relax}%
    \fi
  \fi
}
\makeatother

\renewcommand*{\thefootnote}{\circnum{footnote}}

\begin{document}
\footnote{First}
\dots
\addtocounter{footnote}{18}
\footnote{Last}
% \footnote{Error}
\end{document}

Result

If the latest footnote is activated, it throws an error:

! LaTeX Error: Counter too large.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.30 \footnote{
               Error}
?

Reset counter for each page

If the footnote counter is not reset from time to time, it will likely run out of its allowed range. Then it might be helpful to reset the footnote counter for each page. There are several packages for this purpose:

  • Package footmisc with option perpage:

    \usepackage[perpage]{footmisc}
    
  • Package perpage:

    \usepackage{perpage}
    \MakePerPage[1]{footnote}
    

    Downside: The footnote is reset at the second LaTeX run, causing errors in the first run.

  • Package zref-perpage:

    \usepackage{zref-perpage}
    \zmakeperpage{footnote}
    

The following example file uses the latest method:

\documentclass{article}
% smaller image for TeX.SX
\usepackage[paperwidth=20mm,paperheight=20mm,margin=1mm]{geometry}

\usepackage{zref-perpage}
\zmakeperpage{footnote}

\usepackage{pifont}
\makeatletter
\newcommand*{\circnum}[1]{%
  \expandafter\@circnum\csname c@#1\endcsname
}
\newcommand*{\@circnum}[1]{%
  \ifnum#1<1 %
    \@ctrerr
  \else
    \ifnum#1>20 %
      \@ctrerr
    \else
      \ding{\the\numexpr 171+(#1)\relax}%
    \fi
  \fi
}
\makeatother

\renewcommand*{\thefootnote}{\circnum{footnote}}

\begin{document}
\footnote{First}
\dots
\addtocounter{footnote}{18}
\footnote{Last}
% \footnote{Error}
\newpage
\footnote{New page}
\end{document}

The second page:

Second page