# Right-align one and two digit footnote marks with KOMA

Based on this answer to my question Footnote marker in text should be superscript lining figure, but footnote marker in the footnote should be full size old style figure, I have the following code for formatting the appearance of footnotes:

\documentclass{article}
\usepackage{fontspec} % Unicode
\setmainfont{Libertinus Serif}
\newfontfamily\footfont{Libertinus Serif}[% for footnote markers in the footnote
Numbers = {Monospaced, OldStyle}]
\usepackage{scrextend} % KOMA script
\newcommand*\footnotemarkspace{1em} % set distance of the footnote text from the margin
\deffootnote{\footnotemarkspace}% use distance from above
{\parindent}% paragraph indent in footnotes (footnotes should never have paragraphs!)
{\makebox[\footnotemarkspace][l]{\footfont\thefootnotemark.}} % footfont with period for footnote marks in footnote

\begin{document}
Foobar\footnote{First footnote}\footnote{Second footnote}\footnote{Third footnote}\footnote{Fourth footnote}\footnote{Fifth footnote}\footnote{Sixth footnote}\footnote{Seventh footnote}\footnote{Eighth footnote}\footnote{Ninth footnote}\footnote{Tenth footnote}\footnote{Eleventh footnote}\footnote{Twelfth footnote}
\end{document}


A problem appears when I reach the tenth footnote in my text, i.e. when the footnote mark goes from a single digit to two digits. The output from the code above is this:

The problem is that footnotemarkspace sets the distance from the left margin to the footnote text, with no parameter for setting the distance from the right edge of the footnote mark to the text.

The best solution, as it seems to me, would be to right-align the footnote marks, so that the single digits have the same right edge as the double digits, which would allow for a uniform distance from the right edge of the footnote mark to the text. Ideally, then, the left edge of the double digit footnote mark should align with the left margin of the document text area.

How can I accomplish this? The same question has been asked before, but in that case, neither the question nor the proposed answers use KOMA script, which I am using in this case.

You have to enlarge \footnotemarkspace. Then you can use option r for the \makebox command in the last argument of \deffootnote.

\documentclass{article}
\usepackage{fontspec} % Unicode
\setmainfont{Libertinus Serif}
\newfontfamily\footfont{Libertinus Serif}[% for footnote markers in the footnote
Numbers = {Monospaced, OldStyle}]

\usepackage{scrextend} % KOMA script
\KOMAoptions{footnotes=multiple}% maybe you want to use this option?
\newcommand*\footnotemarkspace{1.5em} % set distance of the footnote text from the margin
\deffootnote{\footnotemarkspace}% use distance from above
{\parindent}% paragraph indent in footnotes (footnotes should never have paragraphs!)
{\makebox[\footnotemarkspace][r]{\thefootnotemark.\ }} % footfont with period for footnote marks in footnote

\begin{document}
Foobar
\footnote{First footnote}\footnote{Second footnote}%
\footnote{Third footnote}\footnote{Fourth footnote}%
\footnote{Fifth footnote}\footnote{Sixth footnote}%
\footnote{Seventh footnote}\footnote{Eighth footnote}%
\footnote{Ninth footnote}\footnote{Tenth footnote}%
\footnote{Eleventh footnote}\footnote{Twelfth footnote}
\end{document}


Or you can use something like

\makebox[\footnotemarkspace][l]{\footfont\phantom{99}\llap{\thefootnotemark}.}


Code:

\documentclass{article}
\usepackage{fontspec} % Unicode
\setmainfont{Libertinus Serif}
\newfontfamily\footfont{Libertinus Serif}[% for footnote markers in the footnote
Numbers = {Monospaced, OldStyle}]

\usepackage{scrextend} % KOMA script
\KOMAoptions{footnotes=multiple}% maybe you want to use this option?
\newcommand*\footnotemarkspace{1.5em} % set distance of the footnote text from the margin
\deffootnote{\footnotemarkspace}% use distance from above
{\parindent}% paragraph indent in footnotes (footnotes should never have paragraphs!)
{\makebox[\footnotemarkspace][l]{\footfont\phantom{99}\llap{\thefootnotemark}.}} % footfont with period for footnote marks in footnote

\begin{document}
Foobar
\footnote{First footnote}\footnote{Second footnote}%
\footnote{Third footnote}\footnote{Fourth footnote}%
\footnote{Fifth footnote}\footnote{Sixth footnote}%
\footnote{Seventh footnote}\footnote{Eighth footnote}%
\footnote{Ninth footnote}\footnote{Tenth footnote}%
\footnote{Eleventh footnote}\footnote{Twelfth footnote}
\end{document}


EDIT by Sverre

I just want to demonstrate here that the first code sample doesn't have a way of aligning the first digit in the two-digit footnote mark to the left margin of the document text area, so this needs to be tweaked manually:

Whereas the second code sample, with \phantom and \llap does align the left edge of the two-digit numbers to the left margin:

If this left-aligning is desired, then the code with \phantom and \llap is probably the way to go.

• What does \KOMAoptions{footnotes=multiple} do? Nov 17 '16 at 10:49
• From the scrguien.pdf: "At sequences of immediately following footnote marks, consecutive marks will be separated by \multfootsep." \multfootsep is predefined as ,
– esdd
Nov 17 '16 at 11:41