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

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

QED on the last line of a center environment containing a tabular

Postby user49915 » Sat Feb 01, 2020 3:25 am

Continuing http://latex.org/forum/viewtopic.php?t=32551, running pdflatex on the input
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \pagestyle{empty}
  3. \usepackage{amssymb}
  4. \DeclareRobustCommand*{\concreteState}[1]{\ifmmode\mathsf{#1}\else\textsf{#1}\fi}
  5. \newcommand*{\textQEDendingNonProofSymbol}{\(\blacksquare\)}
  6. \makeatletter
  7. \newcommand*{\textQEDendingNonProof}{{\unskip\nobreak\hfil\penalty50\hskip1em\null\nobreak\hfil\textQEDendingNonProofSymbol\parfillskip=\z@\finalhyphendemerits=0\endgraf}}%%% A generic macro for putting QED anywhere
  8. \makeatother
  9. \newlength\lastSkipOfEndCenter
  10. \newcommand*{\qedEndingNonProofAfterCenter}{\setlength\lastSkipOfEndCenter{\lastskip}\removelastskip\nopagebreak\par\nopagebreak\vspace{\dimexpr-\baselineskip-\parskip\relax}\nopagebreak\textQEDendingNonProof\vskip\lastSkipOfEndCenter} %%% puttiung QED specifically after center
  11. \begin{document}
  12. \begin{center}%
  13. \begin{tabular}[c]{@{}r|cc@{}}
  14. from \textbackslash\ to
  15. & \concreteState{stop} & \concreteState{go}\\
  16. \hline
  17. \(\to\) \concreteState{stop} & 0 & 1\\
  18. \concreteState{go} & 1 & 0
  19. \end{tabular}\quad\qquad or, equivalently,\qquad\quad%%%% intentionally too many of \qquad's so that you see the problem.
  20. \begin{tabular}[c]{@{}r|cc@{}}
  21. from \textbackslash\ to
  22. & \concreteState{go} & \concreteState{stop}\\
  23. \hline
  24. \concreteState{go} & 0 & 1\\
  25. \(\to\) \concreteState{stop} & 1 & 0
  26. \end{tabular}%
  27. \end{center}\qedEndingNonProofAfterCenter
  28. \end{document}

we obtain
mwe.png
mwe.png (21.9 KiB) Viewed 474 times

As you might see, the bottom of the QED symbol (black square) aligns neither with the baseline of the last line of the tabular nor with the bottom of the tabular. The QED symbol is placed simply way too high. Any way to adjust the macro \qedEndingNonProofAfterCenter specifically for a tabular-inside-center setup such that the bottom of the QED symbol aligns either with the bottom of the tabular or with the baseline of the last line of the tabular?

(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: in a non-minimal example, I use the class svmono V 5.6, and 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 http://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).

A minipage-based solution would probably work, but pollute the contents with formatting. I prefer the formatting related to QED to be hidden inside separate QED-placing macros (\qedEndingNonProofAfterCenter above) as much as possible.)
Last edited by user49915 on Mon Feb 03, 2020 1:22 am, edited 1 time in total.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9568
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Feb 01, 2020 8:48 pm

Perfect minimal example, so I tested it.

I did not have time to find out more besides testing if inserting a simple \vspace before the symbol would work. \vspace{0pt} already changes the baseline, so one my take minus the height of the symbol or a certain value. If it has to be quick it could be \end{center}\vspace{-2ex}\qedEndingNonProofAfterCenter but that's like a manually done fix.

Stefan
LaTeX.org admin

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

Postby user49915 » Tue Feb 11, 2020 1:37 pm

Stefan Kottwitz wrote:\end{center}\vspace{-2ex}\qedEndingNonProofAfterCenter

First, thanks for taking your time to look into this.
Second, the main problem I have with verbatim values such as -2ex above is that they are ad-hoc, hence, have to be adapted whenever you change the font or, even worse, the current formatting (e.g. \parskip, \topskip, etc.), or, at worst, when the glue is automatically added/subtracted.
Third, beyond any doubt you know it already, I know that you know, and you know that I know that you know...


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests