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 377 times
table1.pdf
(20.37 KiB) Downloaded 445 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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 3342 times
Regards
site moderator & package author
Post Reply