LaTeX forum ⇒ Text FormattingQED on the last line of the center environment containing a TikZ drawing

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
user49915
Posts: 58
Joined: Wed Apr 17, 2019 12:51 pm

QED on the last line of the center environment containing a TikZ drawing

Postby user49915 » Tue Jun 04, 2019 6:15 pm

Running pdflatex on the input
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{svmono}% v5.6 from <!-- m --><a class="postlink" href="https://www.springer.com/gp/authors-editors/book-authors-editors/resources-guidelines/rights-permissions-licensing/manuscript-preparation/5636">https://www.springer.com/gp/authors-edi ... ation/5636</a><!-- m -->, dated 23 April 2019. If you use "book" instead, define the environment "example" yourself.
  2. \usepackage{newtxtext}
  3. \usepackage[slantedGreek]{newtxmath}%% Should be loaded after the text font according to its manual. The default uppercase Greek letter
  4. \usepackage{lipsum}
  5. \usepackage{tikz}\usetikzlibrary{calc,shapes,positioning}
  6. \usepackage{mathtools}\mathtoolsset{mathic=true} %%% See <!-- m --><a class="postlink" href="http://tex.stackexchange.com/a/3496/">http://tex.stackexchange.com/a/3496/</a><!-- m -->
  7. \newcommand*{\mathQEDendingNonProofSymbol}{\Box}%%% Alternatives: \square, \boxempty
  8. \newcommand*{\textQEDendingNonProofSymbol}{\(\mathQEDendingNonProofSymbol\)}%%% Alternatives: \square, \boxempty
  9. \makeatletter
  10. \newcommand*{\textQEDendingNonProof}{{\unskip\nobreak\hfil\penalty50\hskip1em\null\nobreak\hfil\textQEDendingNonProofSymbol\parfillskip=\z@\finalhyphendemerits=0\endgraf}}
  11. \makeatother
  12. \newcommand*{\qedEndingNonProofAfterTikzCenter}{\nopagebreak\par\nopagebreak\vspace{-1.57\baselineskip}\nopagebreak\textQEDendingNonProof}%%% -1.57\baselineskip is a wild guess; it is subject to change depending on the font used
  13. \begin{document}
  14. \begin{example}
  15. \lipsum[1][1-2]
  16. \begin{center}
  17. \begin{tikzpicture}[atomicNode/.style={ellipse,draw,inner sep=.3ex,minimum width=3em},startNode/.style={circle,inner sep=.2ex,fill},startText/.style={inner sep=.15ex}]
  18. \node (MThreeText) {\(M_3\):};
  19. \node[startText,below=1ex of MThreeText] (MThreeStartText) {\(x\coloneqq 2\)};
  20. \node[startNode,anchor=north] (MThreeStart) at (MThreeStartText.south) {};
  21. \node[atomicNode] (MThreeSOne) at ($(MThreeStart.south east)+(3em,-4ex)$) {\(S_1\)};
  22. \node[atomicNode,right=5em of MThreeSOne] (MThreeSTwo) {\(S_2\)};
  23. \draw[-latex] (MThreeStart) -- (MThreeSOne);
  24. \draw[-latex] (MThreeSOne) to[bend left]node[above,pos=.55]{\(\{\mathit{odd}(x)\}\,x\coloneqq 2\)} (MThreeSTwo);
  25. \end{tikzpicture}
  26. \end{center}%
  27. \qedEndingNonProofAfterTikzCenter%
  28. \end{example}
  29. \end{document}

produces the output
screenshot.png
output
screenshot.png (43.54 KiB) Viewed 791 times

In this example, the qed symbol (square) should be placed on the base line of the TikZ drawing (which can be arbitrarily complicated) and flushed to the right.
My current solution involves finishing the `center` environment, introducing a wildly guessed negative vertical space, putting the box, and continuing from there on. This is fragile: wild guesses break when the general parameters such as the font or the baselineskip change. Instead, we should undo the vertical skip(s) introduced by `\endcenter` in a font-independent way (which boils down to undoing the vertical skip(s) introduced by `\endtrivlist`), put the QED symbol, and redo the vertical skip(s). However, the definition of `\endtrivlist` is a bit too complicated for me to understand. I imagine that `trivlist` is a very standard thing, so, someone has probably already done the job. Any help?

An aside is worth being made. Marginnote-based solutions to place the qed symbol are of second choice, since the package is abandoned and does lead to problems with a large book. Marginpar/marginline sometimes requires manual vertical adjustments, i.e., a no-go for automation. Using `amsthm` or `ntheorem` is also a no-go: `amsthm` clashes with `svmono` in various ways, and `ntheorem` has bugs (e.g., doesn't jive with UTF-8 engines and has other problems, see https://tex.stackexchange.com/questions/tagged/ntheorem) and is both antique and abandoned. The inclusion of `ntheorem` with some options into `svmono.cls` is, in fact, so far from a clever design that I had to turn off `ntheorem` manually. (If you have problems with getting `svmono.cls` for the purpose of trying this very example out, go with the `book` class instead and define `example` via `\newtheorem`).
Last edited by user49915 on Fri Jun 07, 2019 11:30 pm, edited 1 time in total.

User avatar
thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am

Postby thomasb » Wed Jun 05, 2019 2:24 pm

You are going to say that you don't like it :
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{proof}
  2. (...)
  3. \end{proof}
?

user49915
Posts: 58
Joined: Wed Apr 17, 2019 12:51 pm

Postby user49915 » Thu Jun 06, 2019 11:29 pm

thomasb wrote:You are going to say that you don't like it

No. I'm going to say that what you typed is unrelated to my question.

User avatar
thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am

Postby thomasb » Thu Jun 06, 2019 11:45 pm

user49915 wrote:No. I'm going to say that what you typed is unrelated to my question.

Well, I'm not sure I understood the question then ! You need the QED not to go another line ?

user49915
Posts: 58
Joined: Wed Apr 17, 2019 12:51 pm

Postby user49915 » Fri Jun 07, 2019 1:02 pm

thomasb wrote:You need the QED not to go another line ?

Yes. But replacing "example" with "proof" leads to "Proof" instead of "Example" in the output.

User avatar
thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am

Postby thomasb » Fri Jun 07, 2019 6:14 pm

user49915 wrote:Yes. But replacing "example" with "proof" leads to "Proof" instead of "Example" in the output.

It seems you can define your own environments : http://distrib-coffee.ipsl.jussieu.fr/p ... heorem.pdf

user49915
Posts: 58
Joined: Wed Apr 17, 2019 12:51 pm

Postby user49915 » Fri Jun 07, 2019 11:26 pm

thomasb wrote:It seems you can define your own environments : http://distrib-coffee.ipsl.jussieu.fr/p ... heorem.pdf

`ntheorem` has bugs and is unmaintained. I think I wrote a note about it in the question.

User avatar
thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am

Postby thomasb » Sat Jun 08, 2019 12:37 am

user49915 wrote:`ntheorem` has bugs and is unmaintained. I think I wrote a note about it in the question.

Indeed...

rais
Posts: 242
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Sat Jun 08, 2019 4:31 pm

I didn't understand the benefit of putting a `proof' symbol into an example environment; all that even for a Springer class, which I find highly unusual to be tinkered with.
Anyway, my idea would be to put everything but the qed symbol into a {minipage}, align it to the bottom, and put the qed symbol next to it, e.g.,
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{svmono}% v5.6 from <!-- m --><a class="postlink" href="https://www.springer.com/gp/authors-editors/book-authors-editors/resources-guidelines/rights-permissions-licensing/manuscript-preparation/5636">https://www.springer.com/gp/authors-edi ... ation/5636</a><!-- m -->, dated 23 April 2019. If you use "book" instead, define the environment "example" yourself.
  2. \usepackage{newtxtext}
  3. \usepackage[slantedGreek]{newtxmath}%% Should be loaded after the text font according to its manual. The default uppercase Greek letter
  4. \usepackage{lipsum}
  5. \usepackage{showframe}%<-- only for orientation
  6. \usepackage{tikz}\usetikzlibrary{calc,shapes,positioning}
  7. \usepackage{mathtools}\mathtoolsset{mathic=true} %%% See <!-- m --><a class="postlink" href="http://tex.stackexchange.com/a/3496/">http://tex.stackexchange.com/a/3496/</a><!-- m -->
  8. \newcommand*{\mathQEDendingNonProofSymbol}{\Box}%%% Alternatives: \square, \boxempty
  9. \newcommand*{\QEDendingNonProofSymbol}{%
  10. \ensuremath{\mathQEDendingNonProofSymbol}%
  11. }% actually, this way it could be called \textormathQEDendingNonProofSymbol
  12. \newlength\QEDSymbolSpace
  13. \begin{document}
  14. \begin{example}
  15. \lipsum[1][1-2]
  16. \begin{center}
  17. \settowidth\QEDSymbolSpace{\QEDendingNonProofSymbol}%
  18. \hspace{\QEDSymbolSpace}%
  19. \begin{minipage}[b]{\dimexpr\linewidth-2\QEDSymbolSpace}
  20. \centering
  21. \begin{tikzpicture}[atomicNode/.style={ellipse,draw,inner sep=.3ex,minimum width=3em},startNode/.style={circle,inner sep=.2ex,fill},startText/.style={inner sep=.15ex}]
  22. \node (MThreeText) {\(M_3\):};
  23. \node[startText,below=1ex of MThreeText] (MThreeStartText) {\(x\coloneqq 2\)};
  24. \node[startNode,anchor=north] (MThreeStart) at (MThreeStartText.south) {};
  25. \node[atomicNode] (MThreeSOne) at ($(MThreeStart.south east)+(3em,-4ex)$) {\(S_1\)};
  26. \node[atomicNode,right=5em of MThreeSOne] (MThreeSTwo) {\(S_2\)};
  27. \draw[-latex] (MThreeStart) -- (MThreeSOne);
  28. \draw[-latex] (MThreeSOne) to[bend left]node[above,pos=.55]{\(\{\mathit{odd}(x)\}\,x\coloneqq 2\)} (MThreeSTwo);
  29. \end{tikzpicture}
  30. \end{minipage}\QEDendingNonProofSymbol
  31. \end{center}%
  32. \end{example}
  33. \end{document}

is that less troublesome for you?

KR
Rainer

User avatar
thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am

Postby thomasb » Sat Jun 08, 2019 9:51 pm

Wow ! What about \hfill\QEDendingNonProofSymbol at the end ?


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 2 guests