Graphics, Figures & TablesVertically centered text in the table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ciema7
Posts: 22
Joined: Sat Nov 10, 2018 2:31 am

Vertically centered text in the table

Post by ciema7 »

Hello Friends,

today I have simply question, but I cannot apply solutions that I found in the forums.
Do you know how to vertically center my text in each cell ?

Code: Select all

\resizebox{\textwidth}{!}{
	
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|}
 \hline
    \rowcolor[RGB]{31,78,121} 
         \multicolumn{1}{|c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF} Liczba porzadkowa}} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}1  }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}2 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}3 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}4 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}5 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}6 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}7 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}8 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}9 }}  & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}10 }} & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}11 }}  & \multicolumn{1}{c|}{\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF}12 }}  \\ \hline
\rowcolor[RGB]{208,206,206} 
\cellcolor[RGB]{31,78,121}{\color[HTML]{FFFFFF} Kolejne postaci drgan wlasnych [Hz]}   &   {\color[HTML]{000000}1931.9}   & {\color[HTML]{000000}1738.1}   &                              {\color[HTML]{000000}1429.9}   &
			{\color[HTML]{000000}1376.3}   &
			{\color[HTML]{000000}272.5} &
			{\color[HTML]{000000}380.5} &
			{\color[HTML]{000000}595.6}&                              {\color[HTML]{000000}871.9}   &
			{\color[HTML]{000000}1000.9}   &
			{\color[HTML]{000000}0.4} &
			{\color[HTML]{000000}0.4} &
			{\color[HTML]{000000}0.4}  \\ \hline
		
		\end{tabular}
	}

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

ciema7
Posts: 22
Joined: Sat Nov 10, 2018 2:31 am

Vertically centered text in the table

Post by ciema7 »

I think the best solution is to generate a new table on website with spacing adjusted manually and then to copy the code to LaTeX file, thanks for help ! :) .
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Vertically centered text in the table

Post by Stefan Kottwitz »

Centering by cell would destroy the alignment of th text baseline in a row. Some cells have letters with decenders, such as p and g. Seo we have different text heights but with the same base line by default.

Stefan
LaTeX.org admin
Post Reply