6

The question is about the qed symbol in an amsthm. For example with

\documentclass{article}

\usepackage{amsthm}

\begin{document}
    \begin{proof}
        asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdfas
    \end{proof}
\end{document}

I get the following:

enter image description here

I don't like this at all, because if the text continues after the proof, there will be a lot of blank space which disrupts the flow of the text in my opinion (even more than if a paragraph ends with a single word on the last line, which is also frowned upon in typography, as far as I know). So I wonder if TeX tries to avoid this situation at all and if there is a penalty that I could increase.

2
  • increasing the penalty will only have an effect if there is an alternative break with a lower penalty which seems unlikely in your example. You would have to stretch the inter-word space making things infinitely bad in order to bring some text on to the next line. Mar 26, 2018 at 10:06
  • 1
    You can add \linebreak in front of the last word. In this particular case, I get no “underfull \hbox” message. The best is to edit the text.
    – egreg
    Mar 26, 2018 at 10:39

2 Answers 2

10

amsthm defines \qed by

\DeclareRobustCommand{\qed}{%
  \ifmmode \mathqed
  \else
    \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
    \quad\hbox{\qedsymbol}%
  \fi
}

so it already assigns the largest possible penalty short of 10000 (which is the maximum) that means that in your example there is no feasible breakpoint with penalty less than this.

1
  • This answers my question :-)
    – user157036
    Mar 26, 2018 at 10:12
3

There are a few strategies, but the main one is to edit the offending paragraph.

Strategy 1: \linebreak

Strategy 2: \looseness=1

Here strategy 2 comes into two variants, the latter with \mbox to avoid hyphenation.

I'm afraid that making this automatic would be very complicated and fragile, but you could try and add \looseness=1 to the definition of \qed, which might work in several cases.

\documentclass{article}

\usepackage{amsthm}

\begin{document}

\begin{proof}
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdfa.
\end{proof}

\begin{proof}
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
\linebreak asdfa.
\end{proof}

\begin{proof}
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
asdfa.\looseness=1
\end{proof}

\begin{proof}
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
\mbox{asdfa}.\looseness=1
\end{proof}

\end{document}

enter image description here

You must log in to answer this question.