我想尝试将表格并排放置。我按照网上的教程操作,但无法运行。我还在等待编译。
\documentclass[12pt]{report}
\usepackage{multicol}
\usepackage[english]{babel}
\begin{document}
\begin{table}[h]
\begin{subtable}[h]{0.45\textwidth}
\centering
\begin{tabular}[h]{lccc}
\hline
\textbf{Symbol} & \textbf{Value} & \textbf{Units} & \textbf{Notes} \\
\hline
h & 10668 & m & Altitude\\
$\rho$ & 0.379 & $\text{kg/m}^3$ & Air density \\
Ma & 0.90 & & Mach number\\
$\theta = 0$ & 2.86 & deg & Initial attitude \\
\hline
\end{tabular}
\caption{Flight conditions}
\end{subtable}
\hfill
\begin{subtable}[h]{0.45\textwidth}
\centering
\begin{tabular}[h]{lccc}}
\textbf{Symbol} & \textbf{Value} & \textbf{Units} & \textbf{Notes} \\
\hline
A & 18.22 & $m^2$ & Wing area\\
b & 0.379 & m & Wing span \\
c & 2.91 & m & Wing mean chord \\
AR & 2.45 & & Aspect ratio \\
e & 0.92 & & Oswald factor \\
\hline
\end{tabular}
\caption{Geometric data}
\end{subtable}
\end{table}
\newpage
\end{document}
感谢您的帮助,
答案1
}
第二个中有一个错误\begin{tabular}[h]{lccc}}
,您应该使用该siunitx
包来排版单元,最后您需要在数学环境中amsmath
使用该包。\text{}
稍微改变边距,我得到:
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage[english]{babel}
\usepackage{subcaption}
\usepackage{siunitx}
\begin{document}
\begin{table}[h]
\begin{subtable}[h]{0.45\textwidth}
\centering
\begin{tabular}[h]{lccc}
\hline
\textbf{Symbol} & \textbf{Value} & \textbf{Units} & \textbf{Notes} \\
\hline
h & 10668 & m & Altitude\\
$\rho$ & 0.379 & $\text{kg/m}^3$ & Air density \\
$\rho$ & 0.379 & \si{\kilogram\per \meter^3} & Air density \\
Ma & 0.90 & & Mach number\\
$\theta = 0$ & 2.86 & deg & Initial attitude \\
\hline
\end{tabular}
\caption{Flight conditions}
\end{subtable}
\hfill
\begin{subtable}[h]{0.45\textwidth}
\centering
\begin{tabular}[h]{lccc}
\textbf{Symbol} & \textbf{Value} & \textbf{Units} & \textbf{Notes} \\
\hline
A & 18.22 & \si{\meter^2} & Wing area\\
b & 0.379 & m & Wing span \\
c & 2.91 & m & Wing mean chord \\
AR & 2.45 & & Aspect ratio \\
e & 0.92 & & Oswald factor \\
\hline
\end{tabular}
\caption{Geometric data}
\end{subtable}
\end{table}
\newpage
\end{document}
答案2
您的 MWE 出现错误的原因是:
- 你没有加载
subcaption
包 - 第二个表中的列规范
}
太多了
除此之外,您的表格太宽,所以它们重叠了。
您可能喜欢以下重新设计的表格
\documentclass[12pt]{report}
\usepackage[english]{babel}
\usepackage{subcaption}
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\footnotesize
\setlength\tabcolsep{0pt}
\begin{subtable}[b]{0.48\linewidth}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} lll}
\hline
\textbf{Symbol} & {\textbf{Value}} & \textbf{Notes} \\
\hline
h & \SI{10668}{m} & Altitude \\
$\rho$ & \SI{0.379}{kg/m^3} & Air density \\
Ma & 0.90 & Mach number \\
$\theta = 0$ & \SI{2.86}{\degree} & Initial attitude \\
\hline
\end{tabular*}
\caption{Flight conditions}
\end{subtable}
\hfill
\begin{subtable}[b]{0.48\linewidth}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} lll}
\hline
\textbf{Symbol} & {\textbf{Value}} & \textbf{Notes} \\
\hline
A & \SI{18.22}{m^2} & Wing area \\
b & \SI{0.379}{m} & Wing span \\
c & \SI{2.91}{m} & Wing mean chord \\
AR & 2.45 & Aspect ratio \\
e & 0.92 & Oswald factor \\
\hline
\end{tabular*}
\caption{Geometric data}
\end{subtable}
\end{table}
\end{document}