11

See this mwe:

\documentclass{article}


\makeatletter
\renewcommand\@makefntext[1]{%
    \parindent 1em%
    \noindent\hbox{\sf\bfseries\@thefnmark}\hspace*{.7em plus 0pt minus 0pt}#1}
\makeatother

\begin{document}
  Hello\footnote{I am a footnote!}\footnote{I am another footnote}.
\end{document}

Which results to:

enter image description here

which has the distance of 0.7 em between the number and the footnote. But when I change the font to a font that has figures with proportional width, this leads to a ragged left footnote block (see below for an mwe - this does not reflect my real document, as I could simply remove the \proportionalnums command in the mwe):

enter image description here

% mwe with proportional figures and more footnote text
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine,blindtext}


\makeatletter
\renewcommand\@makefntext[1]{%
   \parindent 1em%
    \noindent\hbox{\proportionalnums{\@thefnmark}}\hspace*{.7em plus 0pt minus 0pt}#1}
\makeatother

\begin{document}
Hello\footnote{I am a footnote!}\footnote{I am another footnote \blindtext}.
\end{document}

multiline footnotes

Question: how can I always make sure the begining of the footnote is at the same horizontal level (for each numbering with the same amount of digits, footnotes 1-9 have a different start level than 10-99 and 100 and above).

The solution would probably be a \hbox to ...{..}, the width depending on the number of digits in the footnote. I also have the situation where sometimes where I temporarily redefine \def\thefootnote{*} to have an * as a footnote symbol instead of a character. This should count as "one digit".

Edit: I have changed the second mwe to have more text to illustrate the multi-line footnotes

5
  • 1
    Can you add an example with a proportional width font so we can test? Feb 24, 2017 at 12:58
  • Maybe use a monospaced version for the footnotemarks? tex.stackexchange.com/questions/241070/… or tex.stackexchange.com/questions/114331/… Feb 24, 2017 at 13:01
  • @samcarter added a mwe for proportional font width.
    – topskip
    Feb 24, 2017 at 13:31
  • 1
    Thanks for the update. Does this work? \renewcommand\@makefntext[1]{% \parindent 1em% \noindent \ifnum\c@footnote>9 \hb@xt@ 20pt % \else \hb@xt@ 15pt % \fi {\sffamily\bfseries\@thefnmark\hss}#1} Feb 24, 2017 at 14:23
  • @ArashEsbati perfect! If you put this as an answer, I'll be happy to accept it. I have added a case > 99: \ifnum\c@footnote > 99 \hb@xt@ 20pt \else right after the > 9 . Thank you very much.
    – topskip
    Feb 24, 2017 at 15:44

2 Answers 2

8

The issue with your code is that you put a \hspace after setting the \@thefnmark. You can fix this by changing LaTeX's version which is:

\newcommand\@makefntext[1]{%
  \parindent 1em%
  \noindent
  \hb@[email protected]{\hss\@makefnmark}#1}

A more LaTeX like approach using ifthen package would be:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine,blindtext,ifthen}

\makeatletter
\renewcommand\@makefntext[1]{%
  \parindent 1em%
  \noindent
  \ifthenelse{\value{footnote}>99}{%
    \hb@xt@ 30\p@
  }{%
    \ifthenelse{\value{footnote}<9}{%
      \hb@xt@ 10\p@
    }{%
      \hb@xt@ 20\p@
    }%
  }%
  {\sffamily\bfseries\@thefnmark\hss}#1}
\makeatother

\begin{document}
Hello\footnote{I am a footnote!}\footnote{I am another footnote
  \blindtext}.
\addtocounter{footnote}{15}%
Hello\footnote{I am a footnote!}\footnote{I am another footnote
  \blindtext}.
\addtocounter{footnote}{99}%
Hello\footnote{I am a footnote!}\footnote{I am another footnote
  \blindtext}.
\end{document}

enter image description here

5

Adjust the length to suit yourself: I used 10pt as fixed distance and 0.5em for each digit.

This assumes the footnote mark expands to a positive number, of course.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}

\usepackage{expl3}

\makeatletter
\renewcommand\@makefntext[1]{%
  \proportionalnums{\bfseries
    \makebox[\getfnmarkwidth\@thefnmark][l]{%
      \proportionalnums{\@thefnmark}%
    }%
  }%
  #1%
}
\makeatother

\ExplSyntaxOn
\cs_new_protected:Nn \getfnmarkwidth:n
 {
  \dim_eval:n { 10pt + .5em * \fp_eval:n { floor(ln(#1)/ln(10),0) + 1 } }
 }
\cs_generate_variant:Nn \getfnmarkwidth:n { V }
\cs_set_eq:NN \getfnmarkwidth \getfnmarkwidth:V
\ExplSyntaxOff

\begin{document}
Hello\footnote{I am a footnote!}\footnote{I am another footnote.}

\setcounter{footnote}{9}

Hello\footnote{I am a footnote!}\footnote{I am another footnote.}
Hello\footnote{I am a footnote!}\footnote{I am another footnote.}

\setcounter{footnote}{99}
Hello\footnote{I am a footnote!}\footnote{I am another footnote.}
Hello\footnote{I am a footnote!}\footnote{I am another footnote.}

\end{document}

Explanation: floor(ln(#1)/ln(10),0)+1 is the number of digits of #1.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .