TransWikia.com

Vertically align text next to (not in) a table

TeX - LaTeX Asked by at. on April 20, 2021

There are plenty of questions about vertically aligning text within a table. I wan’t to make text to the left of a table vertically aligned to the top:

I want this text aligned to top:
begin{tabular}{lll} 
     1. & First step &
     2. & Second step &
     3. & Go back & Step 1\
     hline
     4. & Can't get here & Error.
end{tabular}

This is what the above LaTeX looks like:
enter image description here

Is there a way to make the "I want this text aligned to top" be aligned to the top instead of the vertical center of the table?

3 Answers

You need to add option [t] to tabular for its position:

documentclass{article}

begin{document}
I want this text aligned to top:
begin{tabular}[t]{lll} % <--- observe `t`
     1. & First step &
     2. & Second step &
     3. & Go back & Step 1\
     hline
     4. & Can't get here & Error.
end{tabular}
end{document}

enter image description here

Correct answer by Zarko on April 20, 2021

simplicity as our elite member Zarko said

enter image description here

    begin{tabular}[]{lll} 
    I want this text aligned to top:&   1. & First step 
                                    &   2. & Second step 
                                    &   3. & Go back Step 1
                            cline{2-3}
                                    &   4. & Can't get here Error.
    end{tabular}

Answered by js bibra on April 20, 2021

As said by Zarko, the solution to that question is to use the key t of the environment {tabular} but, for information, I add this answer to show that with {NiceTabular} of nicematrix, there is also a key baseline to choice the row of the alignment.

documentclass{article}

usepackage{nicematrix}

begin{document}
I want this text aligned to the second row:
begin{NiceTabular}{lll}[baseline=2]
     1. & First step &
     2. & Second step &
     3. & Go back & Step 1\
     hline
     4. & Can't get here & Error.
end{NiceTabular}
end{document}

You need several compilations because nicematrix uses PGF/Tikz.

Output of the above code

Answered by F. Pantigny on April 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP