1

I have to typeset quite complex footnotes:

  • On each page the footnote text starts at the same indention for all footnotes there (doesn't have to be equal on all the pages)
  • The footnote number should be flush left
  • The paragraph of a footnote text should all be indented the same (justified like in TestD)
  • There should not be huge space after the number, so I can't just reserve the space for three numbers for each footnote number.

Currently I'm using the following code, but that one is far from perfect:

\documentclass[fontsize=10pt,ngerman,paper=a4]{scrbook}

\newlength{\test}
\let\myfootnote\footnote
\renewcommand{\footnote}[1]{\myfootnote{\settowidth{\test}{\thefootnotemark}\hspace*{\test}#1}}
\deffootnote[.5em]{1.5em}{1.5em}{\makebox[.5em][l]{\thefootnotemark}}

\usepackage{blindtext}
\begin{document}
TestA
\footnote{TestfootnoteOne}
TestB
\footnote{Long Footnote: \blindtext}
TestC
\setcounter{footnote}{10}
\footnote{Two places}
TestD
\footnote{Long Footnote: \blindtext}
TestE
\setcounter{footnote}{123}
\footnote{Three places}
TestF
\footnote{Long Footnote: \blindtext}
\end{document}
  • I don't understand what you want to achieve. This: \deffootnote{1.5em}{1em}{% \makebox[1.5em][l]{\thefootnotemark}} ? – Keks Dose Nov 16 '14 at 19:59
  • Maybe adding a space (\ or ~) to the footnotemark in @KeksDose's comment and you should be more than fine. Without all this redefining of course. – Johannes_B Nov 17 '14 at 7:52
  • @KeksDose No that leaves not enough space for three digits, and almost to much space for single digits. That was (almost) what I started with, but not good enough apperantly. – Juri Robl Nov 17 '14 at 16:15
2

You have to run this twice for it to work, since the first run is used to write to the aux file.

\documentclass[fontsize=10pt,ngerman,paper=a4]{scrbook}
\usepackage{everypage}
\usepackage{blindtext}

\newlength{\tempdima}
\newlength{\tempdimb}
\newcommand{\maxfootnotemark}{}
\newcommand{\ThisFootnotemark}{\thefootnotemark}

\makeatletter
\newcommand{\writepagehook}{%
  \ifx\maxfootnotemark\empty\relax%
  \else
    \begingroup
      \immediate\write\@auxout{%
        \string\MaxFootnotemark{\maxfootnotemark}{\thepage}%
      }%
    \endgroup
    \gdef\maxfootnotemark{}%
  \fi}

\newcommand{\usepagehook}{%
  \@ifundefined{MaxFootnotemark\thepage}{}%
  {\global\edef\ThisFootnotemark{\expandafter\csname MaxFootnotemark\thepage\endcsname}}%
}
\makeatother

\AtBeginDocument{\usepagehook}
\AddEverypageHook{\writepagehook\stepcounter{page}\usepagehook\addtocounter{page}{-1}}

\newcommand{\MaxFootnotemark}[2]% #1 = largest footnote mark, #2 = page
{\expandafter\gdef\csname MaxFootnotemark#2\endcsname{#1}}

\let\myfootnote=\footnote

\renewcommand{\footnote}[1]{\myfootnote{%
\settowidth{\tempdima}{\thefootnotemark}%
\settowidth{\tempdimb}{\maxfootnotemark}%
\ifdim\tempdima>\tempdimb\global\edef\maxfootnotemark{\thefootnotemark}\fi%
\settowidth{\tempdima}{\ThisFootnotemark}%
\setlength{\tempdimb}{\textwidth}%
\addtolength{\tempdimb}{-\tempdima}%
\hspace{\tempdima}\parbox[t]{\tempdimb}{#1}}}

\deffootnote[.5em]{1.5em}{1.5em}%
  {\makebox[.5em][l]{\rlap{\thefootnotemark}}}%

\begin{document}
TestA
\footnote{TestfootnoteOne}

\newpage
TestB
\footnote{Long Footnote: \blindtext}
TestC
\setcounter{footnote}{10}
\footnote{Two places}

\newpage
TestD
\footnote{Long Footnote: \blindtext}
TestE
\setcounter{footnote}{123}
\footnote{Three places}
TestF
\footnote{Long Footnote: \blindtext}

\end{document}
  • I'm going to delete my other answer now. BTW, the main problem is that \begingroup\deffootnote{...}\endgroup doesn't work. – John Kormylo Nov 18 '14 at 17:40

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.