Generalhelp with tabular columns please

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
masterkajo
Posts: 2
Joined: Fri Apr 04, 2008 3:02 pm

help with tabular columns please

Post by masterkajo »

I am trying to to a very simple table that accomplishes two things:
1. set the width of both columns to 4cm (to get appr. 8cm table)
2. center both columns' input

\begin{tabular}[H]{ c | c }
nicht gewichtet & statistisch gewichtet \\ \hline \\
$\frac{\Delta x_c}{x_c} = 0,00343$ & $\frac{\Delta x_c}{x_c} = 0,00543$ \\
$\frac{\Delta w}{w} = 0,03769$ & $\frac{\Delta w}{w} = 0,05194$ \\
$\frac{\Delta A}{A} = 0,03264$ & $\frac{\Delta A}{A} = 0,05410$ \\
\end{tabular}

{c | c} centers the fractions however the columns have different width, which I don't want.
{p{4cm} | p{4cm}} sets both columns' width to 4cm but doesn't center the input

I'd really appreciate your help as this paper is due to monday.

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

help with tabular columns please

Post by Stefan Kottwitz »

Hi,

you could use p-columns and \centering inside the table cells.
Additionally you may use the aligned environment of amsmath, to align the equal signs:

Code: Select all

\begin{tabular}[H]{p{4cm}|p{4cm}}
nicht gewichtet & statistisch gewichtet \\ \hline \\
\centering$\begin{aligned}
  \tfrac{\Delta x_c}{x_c} &= 0,00343 \\
  \tfrac{\Delta w}{w} &= 0,03769 \\
  \tfrac{\Delta A}{A} &= 0,03264
\end{aligned}$ & 
\centering$\begin{aligned}
  \tfrac{\Delta x_c}{x_c} &= 0,00543 \\
  \tfrac{\Delta w}{w} &= 0,05194 \\
  \tfrac{\Delta A}{A} &= 0,05410
\end{aligned}$
\end{tabular}
Of course you can use \centering inside the first row too. And there may be other ways than that example above.

Stefan
masterkajo
Posts: 2
Joined: Fri Apr 04, 2008 3:02 pm

Re: help with tabular columns please

Post by masterkajo »

Thank very much... I still got some minor problems but I managed to accomplish what I want after a little weaking.

One question though, why do you use the command \tfrac{}{}? When I try it, I do not get a fraction but rather a multiplication. Anyway thanks again!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

help with tabular columns please

Post by Stefan Kottwitz »

Hi,

I used \tfrac because it gives the fraction like {\textstyle\frac ... } (actually defined as \genfrac{}{}{}1) , see amsmath user's manual. It should work if you are using amsmath.

Stefan
Post Reply