한 셀에 여러 줄의 단어를 넣는 방법은 무엇입니까?

한 셀에 여러 줄의 단어를 넣는 방법은 무엇입니까?

Second테이블이 너무 넓어서 아래 를 감싸서 좁게 만들고 싶은데 First어떻게 해야 하나요?

라텍스 코드는 현재 다음과 같습니다:

\begin{table*}[htbp]


 \centering
  \caption{Add caption}
    \begin{tabular}{c|ccccc}
    \hline
    \textbf{\#} & \textbf{Violations} & \textbf{First Second} & \textbf{First Second} & \textbf{First Second} & \textbf{First Second} \bigstrut\\
    \hline
    1   & 0   & 91  & 101 & 507 & 1973.54 \bigstrut[t]\\
    2   & 0   & 102 & 92  & 472 & 1874.65 \\
    3   & 0   & 104 & 92  & 459 & 1856.21 \\
    4   & 0   & 108 & 100 & 407 & 1790.56 \\
    5   & 0   & 112 & 77  & 511 & 1723.66 \\
    $\ldots$   & $\ldots$  & $\ldots$  & $\ldots$   & $\ldots$   & $\ldots$ \\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table*}%

여기에 이미지 설명을 입력하세요

답변1

미니멀하게 활용하실 수 있어요makecell패키지특정 셀의 정렬을 조정할 수 있습니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{makecell}% http://ctan.org/pkg/makecell
\begin{document}
\begin{table}[ht]
  \centering
  \caption{Add caption}
  \begin{tabular}{c|ccccc}
    \hline
    \textbf{\#} & \textbf{Violations} & 
      \bfseries\makecell[c]{First \\ Second} & 
      \bfseries\makecell[c]{First \\ Second} & 
      \bfseries\makecell[c]{First \\ Second} & 
      \bfseries\makecell[c]{First \\ Second} \\
    \hline
    5   & 0   & 112 & 77  & 511 & 1723.66 \\
    $\ldots$   & $\ldots$  & $\ldots$  & $\ldots$   & $\ldots$   & $\ldots$ \\
    \hline
  \end{tabular}%
\end{table}%
\end{document}

답변2

가장 간단한 방법은 두 줄을 사용하는 것입니다. 한 줄 제목을 행 중앙에 배치하려면 \multirow다음을 사용할 수 있습니다.패키지multirow:

여기에 이미지 설명을 입력하세요

암호:

\documentclass{article}
\usepackage{multirow}

\begin{document}
\begin{table*}[htbp]
 \centering
  \caption{Add caption}
    \begin{tabular}{c|ccccc}
    \hline
    \multirow{2}{*}{\textbf{\#}} & \multirow{2}{*}{\textbf{Violations}} & \textbf{First} & \textbf{First} & \textbf{First } & \textbf{First } \\
                &  & \textbf{Second} & \textbf{Second} & \textbf{Second} & \textbf{Second} \\
    \hline
    5   & 0   & 112 & 77  & 511 & 1723.66 \\
    $\ldots$   & $\ldots$  & $\ldots$  & $\ldots$   & $\ldots$   & $\ldots$ \\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table*}%
\end{document}

관련 정보