
我使用 TexLive 2022 使用文件類別編寫 Latex IEEEtran
。
我想將文字包裝在表格的單元格之一(“參與者數量”)中,如下所示:
\documentclass[journal]{IEEEtran}
\usepackage{tabualarx,caption}
\begin{document}
\begin{table}[ht]
\renewcommand{\arraystretch}{1.25}
\captionof{table}{Participation}
\label{tab:example_MRT}
\noindent\begin{tabularx}{\linewidth} { |
c |
>{\raggedright\arraybackslash}X |
}
\hline
\textbf{The number of participants} & \textbf{Destination} \\
\hline
$1$ & A \\
\hline
$2$ & B \\
\hline
$3$ & C\\
\hline
$4$ & D\\
\hline
\end{tabularx}
\end{table}
\end{document}
然而,結果如下。
需要增加什麼代碼才能將「參加人數」這兩個字換成兩行?
謝謝。
答案1
您可以\makecell
從makecell
包裝中使用
\documentclass[journal]{IEEEtran}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{makecell}
\begin{document}
\begin{table}[ht]
\renewcommand{\arraystretch}{1.25}
\captionof{table}{Participation}
\label{tab:example_MRT}
\noindent\begin{tabularx}{\linewidth} { |
c |
>{\raggedright\arraybackslash}X |
}
\hline
\textbf{\makecell{The number of\\participants}} & \textbf{Destination} \\
\hline
$1$ & A \\
\hline
$2$ & B \\
\hline
$3$ & C\\
\hline
$4$ & D\\
\hline
\end{tabularx}
\end{table}
\end{document}
與 無關但caption
不相容IEEEtran
,並且您\captionof
破壞了表格標題設定。