表のセル内の折り返しテキスト

表のセル内の折り返しテキスト

IEEEtran私はTexLive 2022を使用して、ドキュメントクラスでLaTeXを記述します。

次のように、テーブルのセルの 1 つ (「参加者数」) に折り返されたテキストを配置したいと思います。

期待

\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}

しかし、結果は以下のようになります。

結果

「参加者数」という単語を 2 行に折り返すには、どのようなコードを追加する必要がありますか?

ありがとう。

答え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

関連情報