0

I would like to have a symbol like \blacksquare at the end of the environment \newtheorem{example}{Example}. However, this symbol should be well-behaved in presence of formulae (i.e. no white space between the formula, and the symbol).

For example, the following line of code does not behave correctly, as can be easily checked.

\documentclass[11pt]{article}

\usepackage{mathtools}

\newcommand\xqed[1]{%
  \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
  \quad\hbox{#1}}
\newcommand\demo{\xqed{$\diamond$}}

\newtheorem{example}{Example}

\begin{document}

\begin{example}

\begin{align*}
f(x) &= \bigg( g(x) \bigg) \\
h(x) &= \bigg(r(x) \bigg).
\end{align*}

\demo
\end{example}

\end{document}

How can I achieve what I am looking for?

Any feedback is greatly appreciated.
Thank you for your time.

Kolmin
  • 559
  • 1
    Might be an idea to switch to ntheorem instead of amsthm, there every theorem like construction can be given an end marker, which (is used correctly) can place it self "more correctly" – daleif Jun 30 '16 at 13:03
  • @daleif: Thanks for the feedback. I will take a serious look at it, even if I would prefer to stick to amsthm (most probably kind of an irrational preference, but before getting into something new, I would like to see what happens with in the "known" context). – Kolmin Jun 30 '16 at 13:12
  • To the moderators: This is only partially (at least answer-wise) a duplicate of the question referenced, because by scrolling and checking the comment, the OP did not get an answer to his problem, namely that there is a gap between the last line in the equation and the symbol. See my edit. – Kolmin Jun 30 '16 at 15:50
  • \qedhere is the answer – egreg Jun 30 '16 at 16:06
  • @egreg: I am trying but it does not work. Moreover, can I personalize \qedhere with whatever symbol I want? – Kolmin Jun 30 '16 at 16:12
  • @Kolmin Did you try my answer with examplex? If you have a final display in the example environment, adding \qedhere to the last (or only) line of the display will produce the chosen QED symbol, in that case the triangle. – egreg Jun 30 '16 at 16:16
  • @egreg: Now I tried it, and it is really smooth, but unfortunately still it does not work. The point is that if you write \qedhere inside the align, it is literally after the big bracket, while if you put outside at the end, there is still the undesired spacing. – Kolmin Jun 30 '16 at 16:23
  • 1
    @Kolmin I added a full example; the triangle is at the right margin as it should. – egreg Jun 30 '16 at 16:29
  • @egreg: First of all, thanks a lot for the time you are devoting to this issue, I really appreciate that! Concerning the edit, I saw it, I implemented it, and indeed it works (again thanks!). Now, there is still a small issue that is barely noticeable when we use small braces, but that is evident with big braces, namely that the symbol is in line with the center of the bracket, and not with the bottom as it should be. – Kolmin Jun 30 '16 at 16:39
  • @Kolmin It mostly depends on what you think the position should be. The baseline is the right place, in my opinion. I wouldn't move it. – egreg Jun 30 '16 at 17:27
  • @egreg: I see what you mean. It is just that I do not really like how it look like. Anyway, here there is a new question I wrote concerning this issue: http://tex.stackexchange.com/questions/317415/qedhere-in-line-with-the-bottom-of-a-bigg-in-a-formula-that-ends-a-proof-exam . If I remember correctly, somwhere I found an answer where a user (maybe Barbara Beaton) was writing about this issue. However, I am not sure. – Kolmin Jun 30 '16 at 17:33

0 Answers0