3

Suppose that for random reasons I want the footnote mark before the text it is related to instead of after it. Then the code

\documentclass{memoir}

\begin{document}

Hello my name is Gaussler and I have a problem with footnotes before linebreaks. If the word is sufficiently long, the line breaks look just \footnote{Footnote}superhypoerproblematic and I don't know what to do about it, so can you help me solve this problem? It would be really nice, and I would appreciate it and +1 your answer and say thank you very much, you're very nice.

\end{document}

produces

enter image description here

Wait, that looks horrible. The word goes outside the margin. How to solve this?

(BTW, yes, I have noticed the typo. And I don't care.)

Gaussler
  • 12,801

2 Answers2

5

You could do this...

\documentclass{memoir}

\begin{document}

  Hello my name is Gaussler and I have a problem with footnotes before linebreaks. If the word is sufficiently long, the line breaks look just \footnote{Footnote}\nolinebreak\hspace{0pt}superhypoerproblematic and I don't know what to do about it, so can you help me solve this problem? It would be really nice, and I would appreciate it and +1 your answer and say thank you very much, you're very nice.

\end{document}

hyphenation after marker

EDIT Corrected thanks to egreg's comment.

cfr
  • 198,882
  • And I don't risk something like a line break between the footnote and the word? – Gaussler Dec 29 '14 at 19:27
  • @Gaussler Actually, I don't know. You might need to tell LaTeX not to break the line there as well, but I'm not certain of the best way to do this. – cfr Dec 29 '14 at 20:50
  • 1
    @Gaussler Yes, but adding \nolinebreak before \hspace{0pt} (better than \hskip0pt) fixes the problem. Why not \hskip? Well, try \footnote{x}\hskip0pt minuscule – egreg Dec 29 '14 at 21:05
  • @Gaussler I've corrected/adjusted this in light of egreg's comment. (Of course, \hskip 0pt minus... gets read as a single instruction which is not what you want!) – cfr Dec 29 '14 at 21:11
  • @egreg It causes problems if the footnote is the first word in the paragraph. Then I get a There's no line here to end. I tried reversing the order of \nolinebreak and \hspace{0pt}, and it complied, but no longer worked as intended. – Gaussler Dec 30 '14 at 15:08
  • And I'm converting from an XML document, so I cannot just omit it. – Gaussler Dec 30 '14 at 15:09
  • 1
    @Gaussler I'm not sure to follow: if I have \footnote{foo}\nolinebreak\hspace{0pt}bar at the start of a paragraph, I get no error. – egreg Dec 30 '14 at 15:19
  • @Gaussler I just checked after seeing egreg's comment and I can't reproduce the error either - not even if the footnote is the first word of the entire document. – cfr Dec 30 '14 at 15:36
  • Well, it probably has something to do with the fact that I'm really using my own homemade footnote environment. Well, egreg's comment solved the problem anyway. – Gaussler Dec 30 '14 at 15:39
  • Or did you try doing it as the very first thing in the entire document? – Gaussler Dec 30 '14 at 15:41
  • @Gaussler Both. I tried it at the start of the first paragraph, with nothing prior, and at the start of the second paragraph. Worked fine. No errors. – cfr Dec 30 '14 at 15:43
  • Okay, seems the problem only really concerned my own environment. So there is probably no need to change the answer. – Gaussler Dec 30 '14 at 15:45
2

My original \kern0pt approach suffered from breaking hyphenation. So far, the only remedy I have found is to manually supply hyphenatation points to the word following the footnote. In this case, the \kern or \hskip is unnecessary.

\documentclass{memoir}

\begin{document}


Hello my name is Gaussler and I have a problem with footnotes before linebreaks. If the word is 
sufficiently long, the line breaks look just 
\footnote{Footnote}su\-per\-hy\-po\-er\-prob\-lem\-at\-ic and I don't know what to do about it, 
so can you help me solve this problem? It would be really nice, and I would appreciate it 
and +1 your answer and say thank you very much, you're very nice.

Hello my name is Gaussler and I have a problem with footnotes before linebreaks. If the word is 
sufficiently long, the line breaks look xxxxxxxjust 
\footnote{Footnote}su\-per\-hy\-po\-er\-prob\-lem\-at\-ic and I don't know what to do about it, 
so can you help me solve this problem? It would be really nice, and I would appreciate it 
and +1 your answer and say thank you very much, you're very nice.

\end{document} 

enter image description here