# Set width column of a table with siunitx

I would like to know how to set the column width even if I'm already defining the tabular with S. How can I define S and p at the same time?

\begin{table}[!h]
\small\sisetup{per-mode=symbol}
\setlength{\doublerulesep}{5pt}
\rowcolors{3}{PalePink}{MyWhite}
\begin{tabular}{|Cc||S[table-format=5.1]|S[table-format=3.1]|}
\hhline{~--}
\hhline{-::==:}
Water & 18 & 100 \\
Sodium & 23 & 100 \\
Chloride & 35.5 & 100 \\
Potassium & 39 & 100 \\
Urea & 60 & 100 \\
Glucose & 180 & 100 \\
Inulin & 5500 & 98 \\
Myoglobin & 17000 & 75 \\
Albumin & 69000 & 0.5 \\
\hhline{-||--}
\end{tabular}
\caption{Molecular weight and filterability index of substances \cite{RefWorks:141}.}
\label{ft_tab_ex}
\end{table}

• Should the columns become wider or smaller? Can you please make a minimal working example (MWE)? – user36296 Sep 28 '17 at 12:37
• I would like them a little bit wider, please; in a way that I can set the cm of width – silvia26 Sep 28 '17 at 12:55
• How have you defined the C column? – CarLaTeX Sep 28 '17 at 13:14
• The columns will be as wide as the widest element, so make the p as wide as you want. OTOH, to make the p precisely as wide as the S you will need to measure the widest entry (usually 22222.2). – John Kormylo Sep 28 '17 at 13:20

You can set the width with table-column-width. As you did not provide a compilable MWE I had to guess the packages which you might use and remove a few things, such as the C columns, the colours etc.

\documentclass{article}

\usepackage{siunitx}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage{hhline}

\begin{document}

\begin{table}[!h]
\small\sisetup{per-mode=symbol}
\setlength{\doublerulesep}{5pt}
\rowcolors{3}{red}{white}
\begin{tabular}{|c||S[table-format=5.1,table-column-width=4cm]|S[table-format=3.1,table-column-width=4cm]|}
\hhline{~--}
\hhline{-::==:}
Water & 18 & 100 \\
Sodium & 23 & 100 \\
Chloride & 35.5 & 100 \\
Potassium & 39 & 100 \\
Urea & 60 & 100 \\
Glucose & 180 & 100 \\
Inulin & 5500 & 98 \\
Myoglobin & 17000 & 75 \\
Albumin & 69000 & 0.5 \\
\hhline{-||--}
\end{tabular}
\caption{Molecular weight and filterability index of substances \cite{RefWorks:141}.}
\label{ft_tab_ex}
\end{table}

\end{document}

• I have the same problem and tried this method. But i get a big white empty column next to the column in question. Is this a known Problem? – simande Jul 18 at 21:17
• @simande don't ask such questions in a comment. This pings only one user and if this user is no longer there you won't get any reaction. Ask a new question. – Ulrike Fischer Jul 19 at 11:10

combination of S and p{...} column types. latter is used for column headers:

\documentclass{article}

\usepackage{siunitx}
\usepackage{ragged2e}
\usepackage[table]{xcolor}
\usepackage{array}
\newcommand\mcc[2]{\multicolumn{1}{>{\Centering}p{#1}|}{#2}}
\usepackage{hhline}

\begin{document}
\begin{table}[!h]
\centering
\sisetup{per-mode=symbol}
\renewcommand\arraystretch{1.2}
\setlength{\doublerulesep}{5pt}
\rowcolors{3}{red!30}{cyan!5}
\begin{tabular}{|l||S[table-format=5.1]
|S[table-format=3.1]|}
\hhline{~--}
\multicolumn{1}{c|}{}
& \mcc{22mm}{Molecular weight \si{\g/\mol}} % <-- width of column determine mcc
& \mcc{22mm}{Filterability (\%)}    \\
\hhline{-::==:}
Water       & 18    & 100                               \\
Sodium      & 23    & 100                               \\
Chloride    & 35.5  & 100                               \\
Potassium   & 39    & 100                               \\
Urea        & 60    & 100                               \\
Glucose     & 180   & 100                               \\
Inulin      & 5500  & 98                                \\
Myoglobin   & 17000 & 75                                \\
Albumin     & 69000 & 0.5                               \\
\hhline{-||--}
\end{tabular}
\caption{Molecular weight and filterability index of substances \cite{RefWorks:141}.}
\label{ft_tab_ex}
\end{table}
\end{document}