[Tex/LaTex] Extra space between footnote numbers and content for high count

footnotesindentationspacing

I’m using the following commands to customize footnotes:

\usepackage[bottom,norule,hang]{footmisc}
\setlength{\footnotemargin}{2mm}
\setlength{\footnotesep}{4mm}
\addtolength{\footskip}{2mm}

The results were as I wanted but only until the 10th footnote (see image below). Is there a way to define the the footnote text margin as a function of the horizontal space that the footnote number takes?

The numbers are flushed to the left and have the same margin as the main text. The footnote text margin, however, seems to be the main text margin plus a fixed quantity.

Best Answer

footmisc with the hang option has the property that if \footnotemargin is 0 or negative, then the hanging indent is set to the width of the footnote mark. Thus:

\documentclass[a5paper]{article}
\usepackage{lipsum}
\usepackage[bottom,norule,hang]{footmisc}
\setlength{\footnotemargin}{0pt}

\begin{document}
\footnote{Long footnote text, to see whether we get
the hanging effect or not.  Just as a test.}\lipsum[4]
\footnote{Long footnote text, to see whether we get
the hanging effect or not.  Just as a test.}\lipsum[4]

\setcounter{footnote}{1010}
\footnote{Long footnote text, to see whether we get
the hanging effect or not.  Just as a test.}\lipsum[4]

\end{document}

produces the following reasonable effect with no overlapping

No space sample

What is lacking here is some spacing between the footnote mark and the text. To correct this we can patch the relevant command in footmisc so that if the hang option is given and \footnotemargin is negative, we use the length information there to provide the spacing between the mark and the text, e.g. a value of -0.5em leads to a space of 0.5em. In the original package, if \footnotemargin is <=0 then just the width of the footnotemark is used. Below, we change one line so that the width of a box containing the footnotemark plus a skip of -\footnotemargin is used in the same situation:

\documentclass[a5paper]{article}
\usepackage{lipsum}
\usepackage[bottom,norule,hang]{footmisc}
\setlength{\footnotemargin}{-0.5em}

\makeatletter
\ifFN@para
\else
  \long\def\@makefntext#1{%
    \ifFN@hangfoot
      \bgroup
      \setbox\@tempboxa\hbox{%
        \ifdim\footnotemargin>0pt
          \hb@xt@\footnotemargin{\@makefnmark\hss}%
        \else
          \@makefnmark\hskip-\footnotemargin      %%Changed here
        \fi
      }%
      \leftmargin\wd\@tempboxa
      \rightmargin\z@
      \linewidth \columnwidth
      \advance \linewidth -\leftmargin
      \parshape \@ne \leftmargin \linewidth
      \footnotesize
      \@setpar{{\@@par}}%
      \leavevmode
      \llap{\box\@tempboxa}%
      \parskip\hangfootparskip\relax
      \parindent\hangfootparindent\relax
    \else
      \parindent1em
      \noindent
      \ifdim\footnotemargin>\z@
        \hb@xt@ \footnotemargin{\hss\@makefnmark}%
      \else
        \ifdim\footnotemargin=\z@
          \llap{\@makefnmark}%
        \else
          \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}%
        \fi
      \fi
    \fi
    \footnotelayout#1%
    \ifFN@hangfoot
      \par\egroup
    \fi
  }
\fi
\makeatother

\begin{document}
\footnote{Long footnote text, to see whether we get
the hanging effect or not.  Just as a test.}\lipsum[4]
\footnote{Long footnote text, to see whether we get
the hanging effect or not.  Just as a test.}\lipsum[4]

\setcounter{footnote}{1010}
\footnote{Long footnote text, to see whether we get
the hanging effect or not.  Just as a test.}\lipsum[4]

\end{document}

Output with space

Related Question