Graphics, Figures & TablesColumn Width and Cell Content Alignment

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Motore
Posts: 1
Joined: Tue Feb 05, 2013 2:27 pm

Column Width and Cell Content Alignment

Post by Motore »

Hi,

I have a few problems with a simple table of mine. Here are two examples of the same table, the first one is supposed to be align at the left side of the page and the first column should be 0,5 cm wide and right align, all the other columns should be the same width at least 1 cm and center aligned.

Code: Select all

\documentclass[a4paper]{article}
\usepackage[slovene]{babel}
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}
    \begin{tabular}{c*{5}{|r}}
            $n\backslash k$     & 1      & 2      & 3      & 4       & 5     \\ \hline
            1   	       	& 223,3  &   	  &   	   &  	     &       \\  
            2   		& 236,9  & 410,3  &   	   &         &       \\  
            3   		& 241,7  & 446,7  & 583,6  &   	     &       \\  
            4   		& 244,0  & 464,1  & 638,8  & 751,0   &       \\  
            5   		& 245,3  & 473,8  & 670,0  & 820,6   & 915,3  
    \end{tabular}
\end{document}
See how it looks in table1.pdf

When i change the first column width and alignment with the command p{0,5cm} it becomes like in table2.pdf

Also the number 410,3 is a little out of center.
If you can help me, thank you.

Motore
Attachments
table2.pdf
(20.37 KiB) Downloaded 373 times
table1.pdf
(20.37 KiB) Downloaded 441 times

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Column Width and Cell Content Alignment

Post by cgnieder »

Hi Motore,

Welcome to the LaTeX community!

I am not able to reproduce your issues. When I copy and compile the code you posted I get this:
table.png
table.png (12.25 KiB) Viewed 3323 times
Regards
site moderator & package author
Post Reply