1

I am trying to set the footnote ragged right instead of justified. However I am not able to get it working. Below is a MWE

\documentclass{article}
\usepackage{expl3}
\usepackage{xparse}
\raggedright

\ExplSyntaxOn
\makeatletter
\RenewDocumentCommand\@makefntext{+m}{
  \group_begin:
  \raggedright
  \leavevmode\normalfont
  \hbox_to_wd:nn{0pt}{\hss\@thefnmark\enspace}
  #1
  \group_end:
}
\makeatother
\ExplSyntaxOff

\begin{document}

A\footnote{Non eram nescius, Brute, cum, quae summis ingeniis exquisitaque
  doctrina philosophi Graeco sermone tractavissent, ea Latinis litteris
  mandaremus, fore ut hic noster labor in varias reprehensiones incurreret. nam
  quibusdam, et iis quidem non admodum indoctis, totum hoc displicet
  philosophari. quidam autem non tam id reprehendunt, si remissius agatur, sed
  tantum studium tamque multam operam ponendam in eo non arbitrantur. erunt
  etiam, et ii quidem eruditi Graecis litteris, contemnentes Latinas, qui se
  dicant in Graecis legendis operam malle consumere. postremo aliquos futuros
  suspicor, qui me ad alias litteras vocent, genus hoc scribendi, etsi sit
  elegans, personae tamen et dignitatis esse negent.}

\end{document}

enter image description here I am attempting two things, first is to set the number before each footnote in normal face, protruded to the left, instead of a raised small number. This part works fine. The other part is to set the text ragged right instead of justified. However, neither the use of \raggedright inside \@makefntext or document-wise, seems to have any effect on the footnote.

Is there any way achieve ragged footnote setting without redefining the whole \footnote macro, or \@footnotetext, but only the inner most \@makefntext?

Edit I found that I missed \par after #1, which makes all the different. I will leave the question open, either one has a better solution, or someone else find it useful, as I didn't find anything answer this question (there's one for memoir though).

  • By the way, \normalfont doesn't affect the size at all. – cfr Jan 18 '17 at 2:26
  • @cfr I merely use it to ensure that it use the document main font, if for any possible reason that it was changed at that point. The font size was left to be \footnotesize as intended – Yan Zhou Jan 18 '17 at 2:43
  • But you said you wanted to change as little as possible. So fine if you want to change more, but then you are embarked on a different project. – cfr Jan 18 '17 at 2:46
  • @cfr I meant I do not want to replicate other work of \footnote, for example, the skips around footnotes, etc., which I would need t do if I redefine an "outer" macro such as \footnote instead of the inner most one \@makefntext. Anyway, I wasn't phrasing it clear. sorry for the confusion. – Yan Zhou Jan 18 '17 at 2:52
2

You need the \raggedright to be active when the paragraph ends. I am not sure why you've added a group, since there is none in the original definition. Nor am I sure why you've added \normalfont which will do nothing to change the size.

Why not just this?

\documentclass{article}
\usepackage{kantlipsum}
\usepackage{xparse}
% \raggedright

\ExplSyntaxOn
\makeatletter
\RenewDocumentCommand\@makefntext{+m}{
  \raggedright
  \leavevmode
  \hbox_to_wd:nn{0pt}{\hss\@thefnmark\enspace}
  #1
}
\makeatother
\ExplSyntaxOff

\begin{document}

\kant[1]

A\footnote{Non eram nescius, Brute, cum, quae summis ingeniis exquisitaque
  doctrina philosophi Graeco sermone tractavissent, ea Latinis litteris
  mandaremus, fore ut hic noster labor in varias reprehensiones incurreret. nam
  quibusdam, et iis quidem non admodum indoctis, totum hoc displicet
  philosophari. quidam autem non tam id reprehendunt, si remissius agatur, sed
  tantum studium tamque multam operam ponendam in eo non arbitrantur. erunt
  etiam, et ii quidem eruditi Graecis litteris, contemnentes Latinas, qui se
  dicant in Graecis legendis operam malle consumere. postremo aliquos futuros
  suspicor, qui me ad alias litteras vocent, genus hoc scribendi, etsi sit
  elegans, personae tamen et dignitatis esse negent.}

\kant[2]
\end{document}

ragged right footnote

I commented the \raggedright in the preamble just to show you can do this even if you want only footnotes ragged right and the body text justified. Obviously, uncomment it if you want it all ragged right.

xparse etc. seems overkill here. Why not just

\makeatletter
\renewcommand\@makefntext[1]{%
  \raggedright
  \leavevmode
  \rlap{\hss\@thefnmark\enspace}%
  #1%
}
\makeatother

which does the same? Although, admittedly the %ing gets annoying.

  • I figured out this reason out myself, though my solution was simply to add an \par at the end before exiting the group (see my edit). I still feel more conformable to have them inside a group that I know of. But I will accept this answer anyway. Thanks – Yan Zhou Jan 18 '17 at 2:45
  • @YanZhou I worry that adding a \par will produce unintended and undesirable side-effects at some point. – cfr Jan 18 '17 at 2:59
  • That's a good point – Yan Zhou Jan 18 '17 at 5:34
  • 1
    adding \par within a footnote isn't recommended, but it's okay to add \endgraf there. (it's a plain tex equivalent to the primitive \par, without all the extra stuff that latex loads onto \par.) – barbara beeton Jan 18 '17 at 16:06
  • 1
    @YanZhou -- yes, \par is a ("original tex") primitive, but lates redefines it all over the place. look into latex.ltx for \par and \@setpar and you'll see the consequences. \endgraf retains the original primitive meaning, so can be used safely in places where the redefined \par would explode. – barbara beeton Feb 18 '17 at 14:00

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.