我想知道如何设置列宽,即使我已经用 定义了表格S
。我如何同时定义S
和?p
\begin{table}[!h]
\centering\renewcommand{\theadfont}{\small}
\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{~--}
\multicolumn{1}{c|}{} & {\thead{Molecular \\ weight \si{\g/\mol}}} & {\thead{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}
答案1
您可以使用来设置宽度table-column-width
。由于您没有提供可编译的 MWE,我不得不猜测您可能使用的包并删除一些东西,例如C
列、颜色等。
\documentclass{article}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage{hhline}
\begin{document}
\begin{table}[!h]
\centering\renewcommand{\theadfont}{\small}
\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{~--}
& {\thead{Molecular \\ weight \si{\g/\mol}}} & {\thead{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}
答案2
S
和列类型的组合p{...}
。后者用于列标题:
\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}
(以上答案的基础是从 nice 那里偷来的萨姆卡特回答)。