Graphics, Figures & TablesSpecify Width of columns in tabular

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

Specify Width of columns in tabular

Post by Eenzc »

Hello,

I have the following table:

Code: Select all


\begin{table} [H]
\begin{center}
\begin{tabular}{|c|r@{}l|r@{}l|r@{}l|}
\hline
Electrode & \multicolumn{2}{c|}{Radius} & \multicolumn{2}{c|}{Charge Passed to plate Hg}
 & \multicolumn{2}{c|}{Hg Mass} \\
% & & & & & & & & \\
\hline
P4 		& \SI{500}{} & \SI{}{\mu m} & \SI{1}{} 			&	\SI{}{C}			& \SI{1}{} 			&\SI{}{mg}		 \\
Set 1 & \SI{500}{} & \SI{}{\mu m} & \SI{1}{} 			&	\SI{}{C}			& \SI{1}{}			&\SI{}{mg}		 \\
Set 2 & \SI{250}{} & \SI{}{\mu m} & \SI{125}{} 		&	\SI{}{mC} 		& \SI{130}{}		&\SI{}{\mu g}	 \\
Set 3 & \SI{100}{} & \SI{}{\mu m}	& \SI{8}{} 			&	\SI{}{mC} 		& \SI{8}{}			&\SI{}{\mu g}\\
Set 4 & \SI{50}{} & \SI{}{\mu m} 	& \SI{1}{} 			&	\SI{}{mC} 		& \SI{1}{}			&\SI{}{\mu g}\\
Set 5 & \SI{20}{} & \SI{}{\mu m}	& \SI{64}{} 		&	\SI{}{\mu C} 	& \SI{67}{}			&\SI{}{ng}	 \\
Set 6 & \SI{10}{} & \SI{}{\mu m}	& \SI{8}{} 			& \SI{}{\mu C} 	& \SI{8}{}			&\SI{}{ng}	 \\
\hline
\end{tabular}
\caption{Test Table: Values for electrodeposition of a flattened hemi-sphere of Hg onto electrode arrays of defined radii, Hg mass values calculated to 2 significant figures (each electrode within the array considered independent).}
\label{Table:ElectrodeHgMasses}
\end{center}
\end{table}

I would like to specify the widths of the visble columns to be 3cm each

Ie : | 3cm | 1.5cm : 1.5cm | 1.5cm : 1.5cm | 1.5cm : 1.5cm |

Is there an easy way to do this? I've done a bit of searching but couldn't find a simple answer.

Thanks

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Specify Width of columns in tabular

Post by localghost »

Those basics are listed in lshort. The array package has some enhancements to the tabular environment.


Best regards
Thorsten¹
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Specify Width of columns in tabular

Post by phi »

You can use the column type p{3cm}. But it would be much better to put the units into the header and use an S column for the numbers. Replace \SI{x}{} by \num{x} and \SI{}{x} by \si{x}. Don't use the center environment inside the table environment, rather use \centering. If you use siunitx, which is recommended for typesetting for typesetting numbers, units and quantities, make sure that you have read the manual carefully, especially the sections 4, 5, 7 and 21.
Here is a much better version of your table:

Code: Select all

\documentclass{article}

\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{siunitx}

\sisetup{unitmode=text}

\begin{document}

\begin{table}
\centering
\begin{tabular}{cS[tabformat=3]S[tabformat=3e-1]S[tabformat=3e-1]}
\toprule
Electrode & {Radius (\si{\micrometre})} & {Charge Passed to plate Hg (\si{\milli\coulomb})} & {Hg Mass (\si{\microgram})} \\
\midrule
P4    & 500 &   1e3  &   1e3  \\
Set 1 & 500 &   1e3  &   1e3  \\
Set 2 & 250 & 125    & 130    \\
Set 3 & 100 &   8    &   8    \\
Set 4 &  50 &   1    &   1    \\
Set 5 &  20 &  64e-3 &  67e-3 \\
Set 6 &  10 &   8e-3 &   8e-3 \\
\bottomrule
\end{tabular}
\caption{Test Table: Values for electrodeposition of a flattened hemi-sphere of Hg onto electrode arrays of defined radii, Hg mass values calculated to 2 significant figures (each electrode within the array considered independent).}
\label{Table:ElectrodeHgMasses}
\end{table}

\end{document}
Post Reply