我正在尝试使用 tabu 环境,因为我听说它是表格制作中最新和最好的环境。我遇到了一个奇怪的问题,即使用多行时文本溢出到下面的单元格中。我在下面包含了一个 MWE(我没有清理 usepackages,以防出现一些问题 - 我可能有一些冲突或多余的东西。TABLE STUFF 注释下的一些内容来自其他实验。本质上,我只是试图找到最简单的表格解决方案。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage[hidelinks]{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
%%%%%TABLE STUFF
\usepackage{makecell}
\usepackage[flushleft]{threeparttable}
\usepackage{multirow}
\usepackage{booktabs,caption}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1\textwidth}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1\textwidth}}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{tabu}
\begin{document}
\tableofcontents
\newpage
\listoffigures
\newpage
\listoftables
\newpage
\begingroup
\renewcommand{\arraystretch}{1.5}
\begin{tabu} to \textwidth {X X X X X}
\toprule
Quantity & Symbol & Defining Equation & SI Unit & Units Definition \\ \midrule
mass & m & \multirow{4}{\linewidth}{Basic physical units defined arbitrarily and maintained in standardization laboratories} & kilogram (kg) \\
length & l & & meter (m) \\
time & t & & second (s) \\
current & I & & ampere (A) \\
force & F & F = mass * acceleration & newton (N) & 1 N = 1 kgms-2 \\
energy & E & E = Force * length & joule (J) & 1 J = 1 kgm2 s-2 \\
power & P & P = E / t & watt (W) & 1 W = 1 J/s \\
frequency & f, v & number per second & hertz (Hz) & 1 Hz = 1 s-1 \\
charge & Q & Q = I t & coulomb (C) & 1 C = 1 A s \\
potential & V & V = E / Q & volt (V) & 1 V = 1 J/C \\
\multirow{2}{*}[-1.05ex]{absorbed dose} & D & E absorbed from ionizing radiation per kg & gray (Gy) & 1 Gy = 1 J / kg \\
& & & & 1 Gy = 100 rads \\
exposure & X & Q liberated by ionizing radiation per kg of air & C kg-1 & roentgen, R (old) \\
& & & & 1 R = 2.58x10-4 C/kg \\
activity & A & disintigrations of radioactive material per t & becquerel (Bq) & 1 Bq = 1 s-1 \\
& & & & 1 Ci (curie, old) = 3.7x1010 Bq \\
\bottomrule
\end{tabu}
\endgroup
\end{document}
答案1
更新
我添加了之前缺失的\multirow
命令,并改进了“吸收剂量”、“活动性”和“暴露”单位定义的对齐方式。这样,表格就可以轻松地放入一页中,而无需减少边距或字体大小。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{booktabs,caption}
\usepackage{array}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{pdflscape} % For second example only
%% \usepackage{geometrx} % Used for the third screenshot
\begin{document}
{\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\linewidth}{l l L l L}
\toprule
Quantity & Symbol & Defining Equation & SI Unit & Units Definition \\ \midrule
mass & m & \multirow{4.5}{=}{Basic physical units defined arbitrarily and maintained in standardization laboratories} & kilogram (kg) \\
length & l & & meter (m) \\
time & t & & second (s) \\
current & I & & ampere (A) \\
\\
force & F & F = mass * acceleration & newton (\si{\newton}) & \SI{1}{\newton} = \SI{1}{\kilogram\meter\per\square\second} \\
energy & E & E = Force * length & joule (\si{\J}) & \SI{1}{\J} = \SI{1}{\kg\square\m\per\square\s} \\
power & P & P = E / t & watt (W) & 1 W = 1 J/s \\
frequency & f, v & number per second & hertz (Hz) & 1 Hz = 1 s-1 \\
charge & Q & Q = I t & coulomb (C) & 1 C = 1 A s \\
potential & V & V = E / Q & volt (V) & 1 V = 1 J/C \\
\makecell[tl]{absorbed\\ dose} & D & E absorbed from ionizing radiation per kg & gray (Gy) & 1 Gy = 1 J / kg \newline 1 Gy = 100 rads \\
exposure & X & Q liberated by ionizing radiation per kg of air & C kg-1 & roentgen, R (old) \newline 1 R = 2.58x10-4 C/kg \\
activity & A & disintigrations of radioactive material per t & becquerel (Bq) & 1 Bq = 1 s-1 \newline 1 Ci (curie, old) = 3.7x1010 Bq\\
\bottomrule
\end{tabularx}}
\end{document}
原始答案:
以下是表格的三个版本:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{booktabs,caption}
\usepackage{array}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{pdflscape} % For second example only
%% \usepackage{geometrx} % Used for the third screenshot
\begin{document}
{\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\linewidth}{l l L l L}
\toprule
Quantity & Symbol & Defining Equation & SI Unit & Units Definition \\ \midrule
mass & m & Basic physical units defined arbitrarily and maintained in standardization laboratories & kilogram (kg) \\
length & l & & meter (m) \\
time & t & & second (s) \\
current & I & & ampere (A) \\
force & F & F = mass * acceleration & newton (\si{\newton}) & \SI{1}{\newton} = \SI{1}{\kilogram\meter\per\square\second} \\
energy & E & E = Force * length & joule (\si{\J}) & \SI{1}{\J} = \SI{1}{\kg\square\m\per\square\s} \\
power & P & P = E / t & watt (W) & 1 W = 1 J/s \\
frequency & f, v & number per second & hertz (Hz) & 1 Hz = 1 s-1 \\
charge & Q & Q = I t & coulomb (C) & 1 C = 1 A s \\
potential & V & V = E / Q & volt (V) & 1 V = 1 J/C \\
\makecell[tl]{absorbed\\ dose} & D & E absorbed from ionizing radiation per kg & gray (Gy) & 1 Gy = 1 J / kg \\
& & & & 1 Gy = 100 rads \\
exposure & X & Q liberated by ionizing radiation per kg of air & C kg-1 & roentgen, R (old) \\
& & & & 1 R = 2.58x10-4 C/kg \\
activity & A & disintigrations of radioactive material per t & becquerel (Bq) & 1 Bq = 1 s-1 \\
& & & & 1 Ci (curie, old) = 3.7x1010 Bq \\
\bottomrule
\end{tabularx}}
\begin{landscape}
\noindent
{\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\linewidth}{l l L l l}
\toprule
Quantity & Symbol & Defining Equation & SI Unit & Units Definition \\ \midrule
mass & m & Basic physical units defined arbitrarily and maintained in standardization laboratories & kilogram (kg) \\
length & l & & meter (m) \\
time & t & & second (s) \\
current & I & & ampere (A) \\
force & F & F = mass * acceleration & newton (\si{\newton}) & \SI{1}{\newton} = \SI{1}{\kilogram\meter\per\square\second} \\
energy & E & E = Force * length & joule (\si{\J}) & \SI{1}{\J} = \SI{1}{\kg\square\m\per\square\s} \\
power & P & P = E / t & watt (W) & 1 W = 1 J/s \\
frequency & f, v & number per second & hertz (Hz) & 1 Hz = 1 s-1 \\
charge & Q & Q = I t & coulomb (C) & 1 C = 1 A s \\
potential & V & V = E / Q & volt (V) & 1 V = 1 J/C \\
\makecell[tl]{absorbed\\ dose} & D & E absorbed from ionizing radiation per kg & gray (Gy) & 1 Gy = 1 J / kg \\
& & & & 1 Gy = 100 rads \\
exposure & X & Q liberated by ionizing radiation per kg of air & C kg-1 & roentgen, R (old) \\
& & & & 1 R = 2.58x10-4 C/kg \\
activity & A & disintigrations of radioactive material per t & becquerel (Bq) & 1 Bq = 1 s-1 \\
& & & & 1 Ci (curie, old) = 3.7x1010 Bq \\
\bottomrule
\end{tabularx}}
\end{landscape}
\end{document}
如果您的表格变长并且您需要在表格内分页,我建议用tabularx
替换xltabular
。
答案2
Leandriis 的评论让我意识到,这是因为表格不能超过 1 页,而这次超支就是因为这个原因(即表格对于 1 页来说太大,所以压缩了它)。通过更改字体大小或增加边距可以解决这个问题