How to place the text top left in a table cell
2,411
The easiest solution is to modify the contents of the cell, The first solutions added a "strut" extending downward, while the second shows a more general approach using \raisebox
.
\documentclass{article}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\rule[-2\normalbaselineskip]{0pt}{3\normalbaselineskip}% strut
a) T.Insert(8) & b) T.Insert(12) & c) T.Insert(10) \\
\hline
\end{tabular}
\bigskip
\begin{tabular}{|c|c|c|}
\hline
\raisebox{\normalbaselineskip}{a) T.Insert(8)} &
\raisebox{0pt}[2\normalbaselineskip][1.6\normalbaselineskip]{b) T.Insert(12)} &% baseline here
\raisebox{-\normalbaselineskip}{c) T.Insert(10)} \\
\hline
\end{tabular}
\end{document}
Related videos on Youtube
Author by
kelalaka
Updated on January 13, 2020Comments
-
kelalaka almost 4 years
We can use
\renewcommand{\arraystretch}{2}
to increase the height of rows. The text, however, is just in the center.
How can we simply put it on the top-left, as in second and third columns in the picture?
Note : this is drawn by Tikz. I want it with tabular if possible.
-
buhtz over 7 yearsIt doesn't look like a real solution. It looks like a workaround. Could we just say that in normal circumstances there is no easy way to align cell content top-left? You always have to use typographic "tricks". Isn't it that way?
-
John Kormylo over 7 years@bulitz - All of LaTeX is based on typographical tricks. There is strut automatically added whose size is determined by \arraystretch. If you want to modify the source code you could have a real solution. But in the end, both would be doing the exact same thing.