我有一张表格,你(可能)看到我希望比利时在换行符中,但与澳大利亚在同一行内(波兰和意大利也是如此)。
\begin{table}[]
\begin{tabular}{|l|r|}
\hline
Country & Counted \\ \hline
Australia and \newline Belgium & 690 \\ \hline
Germany & 1000 \\ \hline
Poland and \newline Italy & 240 \\ \hline
India & 5397 \\ \hline
\end{tabular}
\end{table}
我不是在寻找一个解决方案,我改变
\begin{tabular}{|l|r|}
类似于
\begin{tabular}{| p{3cm}|r|}
我可以这样做:
Australia & \\
Belgium & 690 \\ \hline
但有没有更好看或更有效的解决方案呢?
答案1
借助该makecell
包:
\documentclass{article}
\usepackage{makecell}
\begin{document}
\begin{table}[]
\begin{tabular}{|l|r|}
\hline
Country & Counted \\ \hline
\makecell[l]{Australia and\\ Belgium} & 690 \\ \hline
Germany & 1000 \\ \hline
\makecell[l]{Poland and\\ Italy} & 240 \\ \hline
India & 5397 \\ \hline
\end{tabular}
\end{table}
\end{document}
或使用m
列类型:
\documentclass{article}
\usepackage{array}
\newlength\colwidth
\begin{document}
\begin{table}[ht]
\settowidth\colwidth{Australia and}
\begin{tabular}{|m{\colwidth}|r|}
\hline
Country & Counted \\ \hline
Australia and Belgium & 690 \\ \hline
Germany & 1000 \\ \hline
Poland and Italy & 240 \\ \hline
India & 5397 \\ \hline
\end{tabular}
\end{table}
\end{document}
结果和以前一样。