How can I use this piece of TeX code within LaTeX?

I would like to implement a particular arrangement of footnotes:

Paragraph short footnotes following multiline footnotes; prevent footnotes being paragraphed if they go onto a second line.

The user wipet gave an excellent answer to this question---written in TeX.

I would like to use this within a LaTeX document. Is this possible? And how?

(The answers to TeX within a LaTeX document? do not answer my question).

  • ? There is generally no prerequisite of any kind, as far as I know, to use TeX in a LaTeX document. The last link you provided seems to be rather clear on that point (as well as on several other points). Just be careful on one point: don't copypaste the \bye to your code. It ends input or something. I'm not very familiar with that, though.
    – Alice M.
    Aug 2, 2017 at 18:39
  • @AliceM. It did not work in LaTeX without (slight) modification, which David Carlisle helpfully made below.
    – anon
    Aug 3, 2017 at 11:52

1 Answer 1


I left wipet's code untouched, just added it at the point latex normally does \unvbox\footins rather than the point plain TeX does the same.

enter image description here


\newcount\specfootnum % for global counting the footnotes
\newcount\fnotenum    % for footnote marks


\def\footnote{\global\advance\fnotenum by1 \fnmark\footnoteA}  
\def\footnoteA#1{\global\advance\specfootnum by1
   \expandafter\gdef\csname specfoot:\the\specfootnum
   \ifdim\wd0<.45\hsize \dimen0=.5\baselineskip
   \else \ifdim\wd0>\hsize \setbox0=\vbox{\tmp\strut#1\strut\par\kern0pt}\dimen0=\ht0
                   \vbox to\dimen0{\vss\penalty\specfootnum}\penalty0}%

  \dimen@=\dp\@cclv \unvbox\@cclv % open up \box255
  \ifvoid\footins\else % footnote info is present
    \vskip\skip\footins \footnoterule \printspecfoot \fi
  \ifr@ggedbottom \kern-\dimen@ \vfil \fi

\gdef \@makecol {%
     \setbox\@outputbox \box\@cclv
     \setbox\@outputbox \vbox {%
       \boxmaxdepth \@maxdepth
       \unvbox \@cclv
       \vskip \skip\footins
         \footnoterule \printspecfoot 
  \ifx\@textbottom\relax\else\kern-\dimen@ \vfil \fi
   \global \let \@midlist \@empty
     \setbox\@outputbox \vbox to\@colht {%
       \dimen@ \dp\@outputbox
       \unvbox \@outputbox
       \vskip -\dimen@
   \global \maxdepth \@maxdepth


  \setbox0=\vbox{\repeattrue \unvbox\footins 
     \loop \unpenalty \setbox0=\lastbox
        \ifvoid0 \repeatfalse 
        \else \setbox0=\vbox{\unvbox0 \xdef\tmp{\the\lastpenalty,\tmp}}\fi
        \ifrepeat \repeat
    \dimen1=\hsize \rm
      \setbox0=\hbox{\csname specfoot:#1\endcsname}%
          \vskip-\baselineskip \vskip-\parskip
          \noindent\hskip.5\hsize \hskip-.5\parindent \box0 \par
          \noindent\unhbox0 \newdimenone
   \else \csname specfoot:#1\endcsname \newdimenone \fi
   \global\expandafter\let\csname specfoot:#1\endcsname=\relax
   \expandafter \printspecfootA\fi
  \abovedisplayskip=0pt \belowdisplayskip=0pt
  \abovedisplayshortskip=0pt \belowdisplayshortskip=0pt
  $$\advance\dimen1 by-2em\vskip-\baselineskip

%%% the test:



  Lorem ipsum dolor sit amet, consectetuer%
\footnote{First text.}
  adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,   
  adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu%
\footnote{Second text.}
  libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
  vehicula augue eu neque. Pellentesque habitant morbi tristique  
  senectus et netus et malesuada fames ac turpis egestas. Mauris ut  
  leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna%
\footnote{Third text.}
  fringilla ultrices.  Phasellus eu tellus sit amet tortor gravida  
  placerat. Integer sapien est, iaculis in, pretium quis, viverra ac,
  nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus.  
  Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla.
  Curabitur auctor semper nulla. Donec varius orci eget risus. Duis%
\footnote{Next text.}
  nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis
  eget orci sit amet orci dignissim rutrum.

  Morbi auctor lorem non justo. Nam lacus%
\footnote{Nulla malesuada porttitor diam. Donec felis
erat, congue non, volutpat at, lobortis vitae, tincidunt tristique, libero.}
  libero, pretium at, lobortis vitae, ultricies et, tellus. Donec
  aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna,%
\footnote{Short text.}
  vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit%
\footnote{Next short text.}
  mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla.%
\footnote{Intersting short text.}
  Cum sociis natoque penatibus et magnis dis parturient montes, 
  nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper
  vestibulum turpis. Pellentesque cursus luctus mauris.%
\footnote{The last footnote.}

  • That is great; thank you! Now that I am able to use it in my LaTeX preamble, I see that it has three unintended effects: (a) it makes the type size in footnotes the same as in body text (rather than smaller); (b) it makes the line spacing in footnotes the same as in body text (i.e. setspace evidently does now affect footnotes); (c) the footnote numbers (both in the body text and in the footnote block) are now in Computer Modern even if another font has been specified (with fontspec). Is the reason for these changes clear/are they readily reversible? In any case, thanks for this.
    – anon
    Aug 2, 2017 at 20:18
  • @Jacob Given that you supplied absolutely no code with your question, it's not that surprising that things might not work as you hoped. I would accept David's answer and ask a new question with a minimal working document using this code that shows the problems you are now having.
    – Alan Munn
    Aug 2, 2017 at 21:01
  • 1
    Okay. A new question is now here: tex.stackexchange.com/questions/384581/…
    – anon
    Aug 3, 2017 at 9:13

You must log in to answer this question.