Graphics, Figures & TablesVertical Alignment for Table Cell Content

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
elglanto
Posts: 6
Joined: Fri Oct 05, 2012 1:05 pm

Vertical Alignment for Table Cell Content

Post by elglanto »

Hello,

I made the following table with several images and some text:

Code: Select all

\begin{table}[htbp]
    \centering
    \begin{tabular}{c c c c c}
        \multirow{5}{*}{\rotatebox{90}{m}} & 4 & \includegraphics[scale=0.3]{41.pdf} &   &  \\\
          & 3 & \includegraphics[scale=0.3]{31.pdf} &   &  \\
          & 2 & \includegraphics[scale=0.3]{21.pdf} & \includegraphics[scale=0.3]{22.pdf} & \\
          & 1 & \includegraphics[scale=0.3]{11.pdf} & \includegraphics[scale=0.3]{12.pdf} & \includegraphics[scale=0.3]{13.pdf}\\
          & 0 & \includegraphics[scale=0.3]{01.pdf} & \includegraphics[scale=0.3]{P02.pdf} & \includegraphics[scale=0.3]{03.pdf}\\
          &   & 1 & 2 & 3\\
          &   & \multicolumn{3}{c}{n}\\
    \end{tabular}
    \caption{blabla
    \label{tab:blablabla}
\end{table}
So, I would like the "m" to be vertically centered in the first five rows and the numbers 0 to 4 to be vertically centered in each of their row. I saw several answers online but I'm having trouble to adapt them to my table.

Also, the width between each rows is smaller that the one between each columns. How could I make them equal?

Thanks a lot for your answer.

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

Vertical Alignment for Table Cell Content

Post by Stefan Kottwitz »

The baselines of images for alignment is at their bottom. You could set it to the middle by changing to

Code: Select all

\raisebox{-.5\height}{\includegraphics{name}}
Stefan
LaTeX.org admin
elglanto
Posts: 6
Joined: Fri Oct 05, 2012 1:05 pm

Vertical Alignment for Table Cell Content

Post by elglanto »

Hello,

I'm sorry but i don't really get it. I tried:

Code: Select all

\begin{table}[htbp]
    \centering
    \begin{tabular}{c c c c c}
        \multirow{5}{*}{\rotatebox{90}{m}} & 4 & \raisebox{-.5\height}\includegraphics[scale=0.3]{41.pdf} &   &  \\\
          & 3 & \raisebox{-.5\height}\includegraphics[scale=0.3]{31.pdf} &   &  \\
          & 2 & \raisebox{-.5\height}\includegraphics[scale=0.3]{21.pdf} & \raisebox{-.5\height}\includegraphics[scale=0.3]{22.pdf} & \\
          & 1 & \raisebox{-.5\height}\includegraphics[scale=0.3]{11.pdf} & \raisebox{-.5\height}\includegraphics[scale=0.3]{12.pdf} & \raisebox{-.5\height}\includegraphics[scale=0.3]{13.pdf}\\
          & 0 & \raisebox{-.5\height}\includegraphics[scale=0.3]{01.pdf} & \raisebox{-.5\height}\includegraphics[scale=0.3]{P02.pdf} & \raisebox{-.5\height}\includegraphics[scale=0.3]{03.pdf}\\
          &   & 1 & 2 & 3\\
          &   & \multicolumn{3}{c}{n}\\
    \end{tabular}
    \caption{blabla
    \label{tab:blablabla}
\end{table}
But there is an error, so i think i misunderstood.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Vertical Alignment for Table Cell Content

Post by Stefan Kottwitz »

Check the braces, \includegraphics must be in braces, like I wrote above, because it is in the second argument for \raisebox.

Stefan
LaTeX.org admin
elglanto
Posts: 6
Joined: Fri Oct 05, 2012 1:05 pm

Vertical Alignment for Table Cell Content

Post by elglanto »

Hello,

It's almost fine. But still few issues.

I would like to have the "m" from:

Code: Select all

\multirow{5}{*}{\rotatebox{90}{Ordre m}}
to be vertically centered in the 5 row.

The

Code: Select all

\raisebox{-.5\height}{\includegraphics{name}}
decreases the height between each row and i didn't want to change it.

Any ideas?

Still thank a lot for your time.
Post Reply