关于这篇文章:
\documentclass{article}
\usepackage{array}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}
\begin{document}
\begin{table}
\begin{tabular}{|L|c|L|}\hline
one & two & three \\\hline
This is two line thing and centered & only one line& \multicolumn{1}{m{3cm}|}{This is justified and may go to second line as well, neatly}\\\hline
one & two & three \\\hline
one & two & three \\\hline
\end{tabular}
\end{table}
\end{document}
现在我想对这个表格做如下补充:
将第 2 行、第 1 列的文本转换为该单元格中以“=”对齐的两个方程式。即:
y=mx+b
y=x+1插入标题和标签
- 将表格和标题置于页面的中心
答案1
检查以下修改后的 MWE 形式。
\documentclass{article}
\usepackage{array,amsmath}
\newcolumntype{L}{>{\centering\arraybackslash}m{3cm}}
\begin{document}
\begin{table}
\caption{The table's caption goes here}\label{tab:example}
\centering
\begin{tabular}{|L|c|L|}\hline
one & two & three \\
\hline
This is two line thing and centered & only one line&
\multicolumn{1}{m{3cm}|}{This is justified and may go to second line as well, neatly}\\
\hline
$\begin{aligned}
y&=mx+b\\
y&=x+1
\end{aligned}$ & two & three \\\hline
one & two & three \\\hline
\end{tabular}
\end{table}
\end{document}
为了实现您的目标,我对您的代码进行了以下更改:
第 2 行、第 1 列包含一个
aligned
环境(在$
...$
数学模式分隔符内),其中的&
符号用于将方程式与相应的等号对齐。和之间有新的
\caption
和\label
命令\begin{table}
\begin{tabular}
\centering
语句之前紧接着有一个指令\begin{tabular}
。请注意,标题将自动居中(除非其长度超过\textwidth
)。