2

The \footnote{text goes in here} command takes an optional argument for numbering, so if I want to skip straight to footnote #5 or override the default numbering, I can do that:

\documentclass{article}
\begin{document}
    Polaris\footnote[5]{i.e. the North Star}.
\end{document}

However, what I am trying to do is use the relevant line number (with the lineno package) for the footnote argument.

Also, because my footnotes will be extremely long and unwieldy in-context, I am using \footnotetext with the line number itself as that optional argument. I do not want a \footnotemark in the text itself. Simply to have a footnote appearing at the bottom of the relevant page, itself labeled with the number of the line it refers to on that page, is exactly what I want.

The problem is, LaTeX seems not to like it when I feed it the line reference as the argument. It wants a numeral instead. In other words, the following does not work:

\documentclass{article}
\usepackage{lineno}
\linenumbers
\begin{document}
    Polaris\linelabel{label1}.
    \footnotetext[\lineref{label1}]{i.e. the North Star}
\end{document}

I realize why this doesn't work, but I don't know enough about LaTeX to get around it. Most of my programming has been in Java where you can just plug in anything for anything and the compiler figures out what you mean.

Does anybody have suggestions? Thanks very much.

2

footnotetext is

\def\footnotetext{%
     \@ifnextchar [\@xfootnotenext
       {\protected@xdef\@thefnmark{\thempfn}%
    \@footnotetext}}
\def\@xfootnotenext[#1]{%
  \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
  \endgroup
  \@footnotetext}

so it only transiently uses a number to define \@thefnmark so you can just cut that bit out

enter image description here

\documentclass{article}
\usepackage{lineno}
\linenumbers
\makeatletter
 \def\@xfootnotenext[#1]{%
         \protected@edef\@thefnmark{#1}%
      \@footnotetext}
\makeatother

\setlength\textheight{5cm}
\begin{document}

  a\\b\\c\\d\\
    Polaris\linelabel{label1}.
    \footnotetext[\lineref{label1}]{i.e. the North Star}
\end{document}
0

For your setup it seems more advisable to use an automated approach that doesn't require you to set a \linelabel and then use it in the \footnotetext[.] immediately. Just define something like \footnoteline{<footnote>}:

enter image description here

\documentclass{article}

\usepackage{lineno}
\linenumbers

\makeatletter
\newcounter{footnotelineno}
\newcommand{\footnoteline}[1]{{%
  \stepcounter{footnotelineno}% A new \footnoteline
  \linelabel{fnln-\thefootnotelineno}% Mark the line with a unique \linelabel
   % Update \@makefnmark to use \ref instead of the counter.
   % This is a local redefinition due to the grouping within \footnoteline.
  \def\@makefnmark{\hbox{\@textsuperscript{\normalfont\ref{fnln-\thefootnotelineno}}}}%
  \footnotetext[\value{footnotelineno}]{#1}% Set the \footnotetext (with a phoney counter value)
}}
\makeatother

\setlength\textheight{5cm}% Just for this example

\begin{document}

a\\b\\c\\d\\
Polaris.\footnoteline{\textit{i.e.}, the North Star}

\end{document}

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.