Graphics, Figures & TablesHow to left align some text with the bottom-left corner of a table ?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to left align some text with the bottom-left corner of a table ?

Post by Cham »

I need to add some comments below a table. The comments should be left-aligned with the bottom part of the table. How can I achieve this ? Here's a MWE showing the issue :

Code: Select all

\documentclass[11pt,letterpaper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{mathtools}
\usepackage{tabularx}

\begin{document}

\begin{center}
	\small
	\renewcommand{\arraystretch}{1.5}
	\begin{tabular}{|>{\centering\arraybackslash}p{2.5cm}|>{\centering\arraybackslash}p{2.5cm}|>{\centering\arraybackslash}p{2.5cm}|>{\centering\arraybackslash}p{2.5cm}|}
	\hline
	\multicolumn{4}{|c|}{\normalsize{11.  Some table title}}
	\\ \hline
	\multicolumn{1}{|c|}{\normalsize{Column 1}}
	& \multicolumn{1}{c|}{\normalsize{Column 2}}
	& \multicolumn{1}{c|}{\normalsize{Column 3$\mathrlap{{}^{(1)}}$}}
	& \multicolumn{1}{c|}{\normalsize{Column 4$\mathrlap{{}^{(2)}}$}}
	\\ \hline
	10 & 1 & $x$ & $y$
	\\ \hline
	100 & 2 & $u$ & $v$
	\\ \hline
	1000 & 3 & $p$ & $q$
	\\ \hline
	\end{tabular}
\end{center}

\vspace{-6pt}

\noindent
\small{(1) Some usefull comments. \newline (2) Another line of useless comments.}

\end{document}
Here's a preview :
here.jpg
here.jpg (23.94 KiB) Viewed 8045 times
Maybe there's a better way to add comments below a table ? Note that I don't want a caption here.

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

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to left align some text with the bottom-left corner of a table ?

Post by Cham »

Hmm, the threeparttable package may be the solution :

Code: Select all

\documentclass[11pt,letterpaper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{threeparttable}

\begin{document}

\begin{center}
	\begin{threeparttable}
	\small
	\renewcommand{\arraystretch}{1.5}
	\begin{tabular}{|>{\centering\arraybackslash}p{2.5cm}|>{\centering\arraybackslash}p{2.5cm}|>{\centering\arraybackslash}p{2.5cm}|>{\centering\arraybackslash}p{2.5cm}|}
	\hline
	\multicolumn{4}{|c|}{\normalsize{11.  Some table title}}
	\\ \hline
	\multicolumn{1}{|c|}{\normalsize{Column 1}}
	& \multicolumn{1}{c|}{\normalsize{Column 2}}
	& \multicolumn{1}{c|}{\normalsize{Column 3$\mathrlap{{}^{(1)}}$}}
	& \multicolumn{1}{c|}{\normalsize{Column 4$\mathrlap{{}^{(2)}}$}}
	\\ \hline
	10 & 1 & $x$ & $y$
	\\ \hline
	100 & 2 & $u$ & $v$
	\\ \hline
	1000 & 3 & $p$ & $q$
	\\ \hline
	\end{tabular}
		\begin{tablenotes}
			\item[(1)] Some usefull comments.
			\item[(2)] Another line of useless comments.
		\end{tablenotes}
	\end{threeparttable}
\end{center}

\end{document}
But in case I'm missing something else, is there another way in doing this ?


EDIT : Aha ! The threeparttable documentation is very simple and clear (this is a rare case !) :)

I now can flush-left the table notes to the left using \begin{tablenotes}[flushleft], and the notes indices should be identified with \tnote{(1)}, instead of the $\mathrlap{{}^{(1)}}$ (what a kind of a hack ! :roll: ).
Post Reply