问题描述
在 Latex 中,我知道我们可以使用如下所示的 multirow 命令,
\begin{table}[!h]
\centering
\begin{tabular}{|c|l|}
\hline
\multirow{2}{*}{A}
& I want to place this sentence in multiple lines,\\
& but don't want to control the linebreak myself \\
\hline
\end{tabular}
\end{table}
我认为自己控制换行符太愚蠢了。
任何其他使文本宽度适合线宽的替代方法?
解决方法
\documentclass{article}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabularx}{\linewidth}{|c|X|}
\hline
A
& I want to place this sentence in multiple lines,but don't want to control the linebreak myself \\
\hline
\end{tabularx}
\end{table}
\end{document}