2

I wanted to adjust the left indentation of footnotes depending on the number of digits of the footnote mark. Thus, footnotes with one digit are aligned a the length of single \parindent (which is set at 4mm) from the left margin: while footnotes with two or three digits (let's not assume there will be more) are aligned 8 mm from the left (= 2*\parindent). I managed to do so with the following code:

\documentclass[11pt]{article}
\setlength{\parindent}{4mm}
\usepackage{fancyvrb,footnote}
    \VerbatimFootnotes% I created the code in a file which used this command, but for some reason it doesn't work without it.
\usepackage{ifthen}
\makeatletter
    \renewcommand\@makefntext[1]{%
        \ifthenelse{\value{footnote}>9}{%
            \parindent 12mm%
            \noindent
            \@hangfrom{%
                \hb@xt@ 8mm{\@thefnmark}#1%
            }%
        }{%
            \parindent 8mm%
            \noindent
            \@hangfrom{%
                \hb@xt@ 4mm{\@thefnmark}#1%
            }%
        }%
    }
\makeatother

\usepackage{blindtext}
\begin{document}
A word, phrase, or sentence that needs to be commented on.\footnote{\blindtext}
\setcounter{footnote}{15}
\blindtext\footnote{\blindtext\par\blindtext}

\end{document}

result

Then I had a second problem: on a page that has any one- and two-digit footnotes, I do not want this difference. There, the double indentation/margin should be used for one-digit footnote marks as well. I figure that it should be enough to make the indentation dependent on whether footnote 10 appears on the page or not. Is there a way to add such a condition?

2

Update

The original answer used \thepage which is not reliable. I've updated this answer to use \oddpage@page from the ifoddpage package. See also this question.


Here's an attempt at doing this. It uses the aux file and needs to be compiled at least twice and sometimes three times (depending on page breaks) to ensure indents are correct.

I've also used the footmisc package which gives an inbuilt interface for hanging footnotes like you want.

It writes the width of the footnote indent to the aux file in a page specific skip at each footnote. Then uses the last of these on each page (which will be the maximum skip) to set the indent on the second pass.

MWE

\documentclass{article}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{ifoddpage}
\usepackage[hang]{footmisc}
\renewcommand{\hangfootparskip}{0mm}
\renewcommand{\hangfootparindent}{4mm}
\makeatletter
\patchcmd{\@makefntext}
  {\bgroup
   \setbox\@tempboxa\hbox{%
     \ifdim\footnotemargin>0pt
       \hb@xt@\footnotemargin{\@makefnmark\hss}%
     \else
       \@makefnmark
     \fi
   }}
  {\bgroup
   \checkoddpage
   \ifcslength{@\thepage @max@footnotemargin}
     {\footnotemargin \csname @\oddpage@page @max@footnotemargin\endcsname}
     {}%
   \immediate\write\@auxout{%
     \noexpand\expandafter\noexpand\newskip
       \noexpand\csname @\oddpage@page @max@footnotemargin\endcsname}%
   \ifnumgreater{\value{footnote}}{9}
     {\immediate\write\@auxout{%
        \global\noexpand\csname @\oddpage@page @max@footnotemargin\endcsname 8mm}}
     {\immediate\write\@auxout{%
        \global\noexpand\csname @\oddpage@page @max@footnotemargin\endcsname 4mm}}%
   % remove superscript footnote mark
   \setbox\@tempboxa\hbox{%
     \ifdim\footnotemargin>0pt
       \hb@xt@\footnotemargin{\hbox{\normalfont \@thefnmark}\hss}%
     \else
       \hbox{\normalfont \@thefnmark}%
     \fi
   }}
  {}
  {}
\makeatother
\begin{document}
\null\vfill
Filler text.\footnote{\lipsum*[2]}
Filler text.\footnote{\lipsum*[2]\par\lipsum*[2]}
\clearpage
\null\vfill
Filler text.\footnote{\lipsum*[2]}
\setcounter{footnote}{9}
Filler text.\footnote{\lipsum*[2]\par\lipsum*[2]}
\end{document}

Page 1 output

page 1

Page 2 output

page 2

  • Very nice indeed! – gusbrs Nov 23 '18 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.