# Align the footnote markers to the right in footnotes

my footnotes are justified hanging footnotes that work well, but I would like a bit more:

since the footnote number takes a variable space, depending on whether it is a one-digit or two-digit number, I would like to have the footnote number flushed right inside its own "space", i.e. still indented 8pt, but footnote numbers will "grow" flushed right, so keeping a constant separation from the first letter of the footnote text.

Code example:

\documentclass[10pt,english]{book}
\usepackage{charter}
\usepackage{babel}
\usepackage[unicode=true] {hyperref}

\usepackage[bottom,hang]{footmisc}
\setlength\footnotemargin{8pt}
\setlength{\footnotesep}{10pt}
\setlength{\skip\footins}{7mm}
\interfootnotelinepenalty=10000

\begin{document}

Footnotes with flush align left of their footnote marks\footnote{first footnote}.
But I want them aligned right on their marks\footnote{second footnote .... OOO}
Simple sentences talking about attenuators and\footnote{Available somewhere}
bearing a lot of footnotes\footnote{yet another footnote}
bla bla bla bla bla bla\footnote{it's getting boring}
attenuator is useful\footnote{yes, right}
attenuator is beautiful\footnote{oh, yeah ...} and
bla bla bla\footnote{we are almost there} bla bla bla bla
and is also cheap\footnote{not all of them}.
But I want to save money\footnote{Who does not??}
and I will build one... or two\footnote{here we are}.
That's it\footnote{last footnote}, now we have more than 10 footontes!

\end{document}


I am not sure if this is quite what you want but perhaps it is close. You can redefine \thefootnote so that it is within its' own little box and push the number to the righthand side using:

\renewcommand\thefootnote{\hbox to 6pt{\hss\arabic{footnote}}}


This now gives footnotes like this:

Here is the full code:

\documentclass[10pt,english]{book}
\usepackage{charter}
\usepackage{babel}
\usepackage[unicode=true] {hyperref}

\usepackage[bottom,hang]{footmisc}
\setlength\footnotemargin{8pt}
\setlength{\footnotesep}{10pt}
\setlength{\skip\footins}{7mm}
\interfootnotelinepenalty=10000
\renewcommand\thefootnote{\hbox to 6pt{\hss\arabic{footnote}}}

\begin{document}

Footnotes with flush align left of their footnote marks\footnote{first footnote}.
But I want them aligned right on their marks\footnote{second footnote .... OOO}
Simple sentences talking about attenuators and\footnote{Available somewhere}
bearing a lot of footnotes\footnote{yet another footnote}
bla bla bla bla bla bla\footnote{it's getting boring}
attenuator is useful\footnote{yes, right}
attenuator is beautiful\footnote{oh, yeah ...} and
bla bla bla\footnote{we are almost there} bla bla bla bla
and is also cheap\footnote{not all of them}.
But I want to save money\footnote{Who does not??}
and I will build one... or two\footnote{here we are}.
That's it\footnote{last footnote}, now we have more than 10 footontes!

\end{document}

• -Thanks! Perfect. Now that I see the \hss it is a bit more clear, simply because I have browsed with the right hint. Just to understand: you create a \hbox of 6pt and have variable stretch/shrink, and I will see a gap of my 8pt - your 6pt = 2 pt between the mark and the footnote text, right? But how you get the flushed right alignment? it is a default or it has to do with "to"? – andrea Apr 4 '15 at 14:44
• Well, no! Also the footnote markers in text will use the same code! – egreg Apr 4 '15 at 15:03
• @egreg -Ok, I definitely need to study basic Tex grammar for some days and make some experiments! I would like to understand what I am doing and book formatting is the good occasion. Thanks – andrea Apr 4 '15 at 18:19

Change how the footnote markers are placed in the footnotes. The code does

\hbox to \footnotemargin{\@makefnmark\hss}


so it's sufficient to say

\hbox to \footnotemargin{\hss\@makefnmark\hspace{4pt}}


after enlarging a bit the \footnotemargin; I set it to 12pt. Fix the lengths to your liking.

\documentclass[10pt,english]{book}
\usepackage{charter}
\usepackage{babel}
\usepackage[bottom,hang]{footmisc}
\usepackage{etoolbox}
\usepackage[unicode=true]{hyperref}

\setlength\footnotemargin{12pt}
\setlength{\footnotesep}{10pt}
\setlength{\skip\footins}{7mm}
\interfootnotelinepenalty=10000

\makeatletter
\patchcmd{\@makefntext}
{\@makefnmark\hss}
{\hss\@makefnmark\hspace{4pt}}
{}{}
\makeatletter

% just to show all text and footnotes without a wide white space
\setlength{\textheight}{10cm}

\begin{document}

Footnotes with flush align left of their footnote marks\footnote{first footnote}.
But I want them aligned right on their marks\footnote{second footnote .... OOO}
Simple sentences talking about attenuators and\footnote{Available somewhere}
bearing a lot of footnotes\footnote{yet another footnote}
bla bla bla bla bla bla\footnote{it's getting boring}
attenuator is useful\footnote{yes, right}
attenuator is beautiful\footnote{oh, yeah ...} and
bla bla bla\footnote{we are almost there} bla bla bla bla
and is also cheap\footnote{not all of them}.
But I want to save money\footnote{Who does not??}
and I will build one... or two\footnote{here we are}.
That's it\footnote{last footnote which is very long and splits across lines,
just to see what's the effect. This should be long enough}, now we have
more than 10 footnotes!

\end{document}