![文档中的引用表](https://linux22.com/image/373332/%E6%96%87%E6%A1%A3%E4%B8%AD%E7%9A%84%E5%BC%95%E7%94%A8%E8%A1%A8.png)
我已经完成了下面的表格。但是现在我想给下面的表格添加一个标题,我只想给它添加标题表 1:变量。但是当我尝试它时我遇到了问题,寻求帮助谢谢!我附上了一张截图
\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs, multirow}
\usepackage{siunitx}
\usepackage{amsmath}
\setlength{\extrarowheight}{2pt}
\usepackage{tabularx}
\begin{document}
{\footnotesize
\noindent\begin{tabularx}{\linewidth}{p{1.45cm}>{$}c<{$}Xlp{1.5cm}} \toprule
& \text{Symbol}
& \hfil Description & Unit & Constraint\\
\midrule
Variables
& S_H & Number of susceptible humans & number & $S_H \geq 0 $ \\
& I_H & Number of infected humans & number & $I_H \geq 0 $ \\
& R_H & Number of recovered humans & number & $R_H \geq 0 $ \\
& V_H & Number of vaccinated humans & number& $ V_H \geq 0$ \\
& N_H & Number of total human population & number & $N_H > 0 $ \\
& S_M & Number of susceptible mosquitoes & number & $S_M \geq 0 $ \\
& E_M & Number of exposed mosquitoes & number & $E_M \geq 0 $ \\
& I_M & Number of infected mosquitoes & number & $I_M \geq 0 $ \\
& N_M & Number of total mosquito population & number & $N_M > 0 $ \\
\bottomrule
\end{tabularx}
}
\end{document}
答案1
使用table
环境并在其中输入\caption
命令。稍后要引用它,请使用\label{...}
inside of \caption
(确保此处不引入虚假空格),并使用\ref{...}
to 引用它(\ref
将仅产生数字)。引用需要至少两次 LaTeX 运行。
\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs, multirow}
\usepackage{siunitx}
\usepackage{amsmath}
\setlength{\extrarowheight}{2pt}
\usepackage{tabularx}
\begin{document}
\begin{table}
\footnotesize
\noindent\begin{tabularx}{\linewidth}{p{1.45cm}>{$}c<{$}Xlp{1.5cm}} \toprule
& \text{Symbol}
& \hfil Description & Unit & Constraint\\
\midrule
Variables
& S_H & Number of susceptible humans & number & $S_H \geq 0 $ \\
& I_H & Number of infected humans & number & $I_H \geq 0 $ \\
& R_H & Number of recovered humans & number & $R_H \geq 0 $ \\
& V_H & Number of vaccinated humans & number& $ V_H \geq 0$ \\
& N_H & Number of total human population & number & $N_H > 0 $ \\
& S_M & Number of susceptible mosquitoes & number & $S_M \geq 0 $ \\
& E_M & Number of exposed mosquitoes & number & $E_M \geq 0 $ \\
& I_M & Number of infected mosquitoes & number & $I_M \geq 0 $ \\
& N_M & Number of total mosquito population & number & $N_M > 0 $ \\
\bottomrule
\end{tabularx}
\caption{A table\label{tab:tabel}}
\end{table}
If you want to reference it, use \ref{tab:tabel}.
\end{document}