테이블 셀에 텍스트 줄 바꿈

테이블 셀에 텍스트 줄 바꿈

TexLive 2022를 사용하여 문서 클래스 로 라텍스를 작성합니다 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

관련 정보