Graphics, Figures & TablesTable: force exact same column width

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Mynamedoesntfi
Posts: 2
Joined: Thu Apr 17, 2014 6:46 pm

Table: force exact same column width

Post by Mynamedoesntfi »

Hello,

I'm trieng to make a balans sheet (through table environment) and would like to have two columns with the exact same width. Anyone idea's?

This is my current Latex code and output:

\begin{table}[h!]
\centering
\begin{tabular}{lr|lr}
\multicolumn{4}{c}{Balans te 31/12/20XX} \\
\hline\hline
Revendication & 1 000 & Equity & 1 000 \\
Shares & 500 & Profit & 500 \\
& & & \\
& & Short term liability & 500 \\
\hline
\end{tabular}
\caption{Scenario A: inbreng tegen nominale waarde}
\label{table:ScA_Nom}
\end{table}
Attachments
Result Latex output
Result Latex output
Naamloos.png (18.2 KiB) Viewed 16410 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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Table: force exact same column width

Post by Johannes_B »

You can use p-columns and give them a fixed width. There are more, see the arrayy documentaion for details.
I also loaded package siunitx to take care of your number columns. Decimal points will now be aligned.

Code: Select all

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}

\begin{document}
\begin{table}%[h!]%JB: don't do that. It's really bad.
\centering
\begin{tabular}{p{3cm}S|p{3cm}S}
\multicolumn{4}{c}{Balans te 31/12/20XX} \\
\hline\hline
Revendication & 1 000 & Equity & 1 000 \\
Shares & 500 & Profit & 500 \\
& & & \\
& & Short term liability & 500 \\
Something & 5,12 & else &1000000,20 \\
\hline
\end{tabular}
\caption{Scenario A: inbreng tegen nominale waarde}
\label{table:ScA_Nom}
\end{table}
\end{document}
Hint: Click on open in writelatex.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Mynamedoesntfi
Posts: 2
Joined: Thu Apr 17, 2014 6:46 pm

Re: Table: force exact same column width

Post by Mynamedoesntfi »

Okay that did the job. Thank you for your answer.
Post Reply