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, ...)
Post Reply
user49915
Posts: 81
Joined: Wed Apr 17, 2019 12:51 pm

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

Post by user49915 »

Continuing http://latex.org/forum/viewtopic.php?t=32551, running pdflatex on the input

Code: Select all

\documentclass{article}
\pagestyle{empty}
\usepackage{amssymb}
\DeclareRobustCommand*{\concreteState}[1]{\ifmmode\mathsf{#1}\else\textsf{#1}\fi}
\newcommand*{\textQEDendingNonProofSymbol}{\(\blacksquare\)}
\makeatletter
\newcommand*{\textQEDendingNonProof}{{\unskip\nobreak\hfil\penalty50\hskip1em\null\nobreak\hfil\textQEDendingNonProofSymbol\parfillskip=\z@\finalhyphendemerits=0\endgraf}}%%% A generic macro for putting QED anywhere
\makeatother
\newlength\lastSkipOfEndCenter
\newcommand*{\qedEndingNonProofAfterCenter}{\setlength\lastSkipOfEndCenter{\lastskip}\removelastskip\nopagebreak\par\nopagebreak\vspace{\dimexpr-\baselineskip-\parskip\relax}\nopagebreak\textQEDendingNonProof\vskip\lastSkipOfEndCenter} %%% puttiung QED specifically after center
\begin{document}
\begin{center}%
  \begin{tabular}[c]{@{}r|cc@{}}
    from \textbackslash\ to
    & \concreteState{stop} & \concreteState{go}\\
    \hline
    \(\to\) \concreteState{stop} & 0 & 1\\
    \concreteState{go} & 1 & 0
  \end{tabular}\quad\qquad or, equivalently,\qquad\quad%%%% intentionally too many of \qquad's so that you see the problem.
  \begin{tabular}[c]{@{}r|cc@{}}
    from \textbackslash\ to
    & \concreteState{go} & \concreteState{stop}\\
    \hline
    \concreteState{go} & 0 & 1\\
    \(\to\) \concreteState{stop} & 1 & 0
  \end{tabular}%
\end{center}\qedEndingNonProofAfterCenter
\end{document}
we obtain
mwe.png
mwe.png (21.9 KiB) Viewed 2564 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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

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

Post by Stefan Kottwitz »

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: 81
Joined: Wed Apr 17, 2019 12:51 pm

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

Post by user49915 »

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...
Post Reply