我是 TeX 新手,到目前为止,我遇到了一些我无法自行解决的问题。我想知道如何在使用命令时为行着色,\multirow
而不会只看到合并单元格的一半内容。此外,如何对齐小数位(使用“。”而不是“,”),同时保持在单元格的中心?最后,如何设置列宽(以及行高)?有时我不需要宽列,反之亦然。
先感谢您!!
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{xcolor}
\begin{figure}[H]
\centering
\includegraphics[width=0.7\textwidth]{figures/filtrsecr}
\caption{Models of excretion rate for different molecules.}
\label{filtrsecr}
\end{figure}
\begin{table}[!h]
\centering
\small
\setlength\tabcolsep{2pt}
\begin{tabular}{|c||c|c|c|c|c|c|}
\hline \hline
& Unit & Filtered load & Amount reabsorbed & Amount secreted & Amount excreted & Filtered load \\
& & & & & & reabsorbed (\%) \\
\hline
\rowcolor{LightGreen}
$ Na^+ $ & $mEq/day$ & 25200 & 25410 & 0 & 150 & 99.4 \\
\rowcolor{Ivory}
$ Cl^- $ & $mEq/day$ & 18000 & 17850 & 0 & 150 & 99.2 \\
\rowcolor{LightGreen}
${HCO_3}^- $& $mEq/day$ & 4320 & 4318 & 0 & 2 & 99.9 \\
\rowcolor{Ivory}
$ K^+ $& $mEq/day$ & 720 & 620 & 50 & 100 & 86.1 \\
\multirow{2}{*}{\cellcolor{LightGreen} $Ca^{2+}$}
& \cellcolor{LightGreen} $mEq/day$ & \cellcolor{LightGreen} 540 & \cellcolor{LightGreen}530 & \cellcolor{LightGreen} 0 & \cellcolor{LightGreen} 10 & \cellcolor{LightGreen} 98.1 \\
\cellcolor{Ivory} & \cellcolor{Ivory} $mmol/day$ & \cellcolor{Ivory} 270 & \cellcolor{Ivory} 265 & \cellcolor{Ivory} 0 & \cellcolor{Ivory} 5 & \cellcolor{Ivory} 98.1 \\
\multirow{2}{*}{\cellcolor{LightGreen} ${HPO_4}^{2-}$}
& \cellcolor{LightGreen} $mEq/day$ & \cellcolor{LightGreen} 260 & \cellcolor{LightGreen} 234 & \cellcolor{LightGreen} 0 & \cellcolor{LightGreen} 26 & \cellcolor{LightGreen} 90 \\
\cellcolor{Ivory} & \cellcolor{Ivory} $mmol/day$ & \cellcolor{Ivory} 144 & \cellcolor{Ivory} 130 & \cellcolor{Ivory} 0 & \cellcolor{Ivory} 14 & \cellcolor{Ivory} 90 \\
\rowcolor{LightGreen}
$ Urea $ & $mmol/day$ & 870 & 460 & 0 & 410 & 52.9 \\
\rowcolor{Ivory}
$ Glucose $ & $mmol/day$ & 800 & 799.5 & 0 & 0.5 & 99.9 \\
\rowcolor{LightGreen}
$ Uric\ acid $ & $mmol/day$ & 50 & 49 & 4 & 5 & 98 \\
\rowcolor{Ivory}
$ Creatinine $ & $mmol/day$ & 12 & 0 & 1 & 12 & 0 \\
\rowcolor{LightGreen}
$ Total\ solute $ & $mmol/day$ & 50386 & 49541.5 & 55 & 848.5 & 98 \\
\rowcolor{Ivory}
$ Water $ & $ml/day$ & 180000 & 179000 & 0 & 1000 & 99.4 \\
\hline \hline
\end{tabular}
\caption{Filtration, reabsorption, secretion and excretion rates referring to each substance \cite{RefWorks:130}.}
\label{filtreabsecret}
\end{table}
答案1
这是一个解决方案,它需要更多软件包,其中包括 ,chemformula
它有一个命令,可以以简单的方式输入化学公式和反应,以及makecell
,它允许在标准单元格中换行。我建议使用 的设计,它看起来比带有彩色行的hhline
默认 更漂亮。\hline
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[demo]{graphicx}
\usepackage{tabularx, longtable, multirow, booktabs, hhline, makecell, cellspace}
\setlength{\cellspacetoplimit}{2pt}
\setlength{\cellspacebottomlimit}{2pt}
\usepackage{array}
\usepackage[table, svgnames]{xcolor}
\usepackage{chemformula}
\usepackage{siunitx}
\DeclareSIUnit{\mEq}{mEq}
\begin{document}
\begin{figure}[!htb]
\centering
\includegraphics[width=0.7\textwidth]{figures/filtrsecr}
\sisetup{table-number-alignment=center}
\caption{Models of excretion rate for different molecules.}
\label{filtrsecr}
\end{figure}
\begin{table}[!h]
\centering\renewcommand{\theadfont}{\small}
\small\sisetup{per-mode=symbol}
\setlength{\doublerulesep}{5pt}
\rowcolors{3}{LightGreen}{Ivory}
\begin{tabular}{|Cc||Cr|S[table-format=6.0]|S[table-format=6.1]| S[table-format=2.0]|S[table-format=4.1]|S[table-format=2.1]|}
\hhline{~------}
\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Unit} & {\thead{Filtered \\ load}} & {\thead{Amount\\ reabsorbed}} & {\thead{Amount\\ secreted}} & {\thead{Amount\\ excreted}} & {\thead{Filtered load\\ reabsorbed\\ (\%)}} \\
\hhline{-::======:}
\ch{Na+} & \si{\mEq/\day} & 25200 & 25410 & 0 & 150 & 99.4 \\
\ch{Cl-} & \si{\mEq/\day} & 18000 & 17850 & 0 & 150 & 99.2 \\
\ch{HCO_3-} & \si{\mEq/\day} & 4320 & 4318 & 0 & 2 & 99.9 \\
\ch{K+ } & \si{\mEq/\day} & 720 & 620 & 50 & 100 & 86.1 \\
& \si{\mEq/\day} & 540 & 530 & 0 & 10 & 98.1 \\
\multirow{-2}{*}{\cellcolor{Ivory}\ch{Ca^{2+}}} & \si{\mmol/\day} & 270 & 265 & 0 & 5 & 98.1 \\
\cellcolor{LightGreen} & \si{\mEq/\day} & 260 & 234 & 0 & 26 & 90 \\
\multirow{-2}{*}{\cellcolor{LightGreen}\ch{HPO_4^{2-}}} & \si{\mmol/\day} & 144 & 130 & 0 & 14 & 90 \\
Urea & \si{\mmol/\day} & 870 & 460 & 0 & 410 & 52.9 \\
Glucose & \si{\mmol/\day} & 800 & 799.5 & 0 & 0.5 & 99.9 \\
Uric\ acid & \si{\mmol/\day} & 50 & 49 & 4 & 5 & 98 \\
Creatinine & \si{\mmol/\day} & 12 & 0 & 1 & 12 & 0 \\
Total\ solute & \si{\mmol/\day} & 50386 & 49541.5 & 55 & 848.5 & 98 \\
Water & \si{\ml/\day} & 180000 & 179000 & 0 & 1000 & 99.4 \\
\hhline{-||------}
\end{tabular}
\caption{Filtration, reabsorption, secretion and excretion rates referring to each substance \cite{RefWorks:130}.}
\label{filtreabsecret}
\end{table}
\end{document}