셀 정렬의 중앙에 있는 테이블

셀 정렬의 중앙에 있는 테이블

이 정렬을 달성하는 방법은 무엇입니까? 여기에 이미지 설명을 입력하세요 대신에:

\documentclass{article}
\usepackage{array, tabu} 
\begin{document}
\begin{table}[h]
\begin{tabu} to 1.0\textwidth { |X[c]|X[c]| }
\hline
$ N_{1} $ & $ (0: 1] $ \\[3cm]  \hline
\end{tabu}
\end{table}
\end{document}

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

답변1

다음과 같은 더러운 트릭을 시도해 보세요.

\documentclass{article}
\usepackage{array, tabu}
\begin{document}
\begin{table}[h]

\begin{tabu} to 1.0\textwidth { |X[c,$] | X[c,$]m{0pt}|}
\hline
N_{1}  &  (0: 1]  & \\[3cm]  \hline
\end{tabu}
\end{table}
\end{document}

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

왜 그렇게 이상한 테이블 디자인이 필요한지는 명확하지 않습니다. 그리고 패키지 사용이 tabu까다롭습니다. 유지 관리되지 않으며 버그가 포함되어 있습니다 ...

부록:셀 내용의 수직 중앙 정렬은 간단한 작업이 아닙니다. 이를 위해 m{0pt}위의 예에는 행의 기준선이 수직으로 중앙에 배치되는 가짜 열이 추가되었습니다.

테이블 의 셀 내용을 가로 가운데에 맞추려면 tabularx새 열 유형을 정의해야 합니다. 예를 들어

\newcolumntype{C}{>{\centering\arraybackslash}X}

전체 열의 내용이 수학 모드에 있는 경우에는 전체 열이 이 모드에 있도록 정의됩니다. 그러면 각 셀에 쓸 필요가 없습니다 $<math expression>$. 이 경우 새 열 유형을 다음과 같이 정의할 수 있습니다.

\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}

Complete code is then:

\documentclass{article}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}

\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{ | C | C @{}m{0pt}|}
\hline
N_{1}  &  (0: 1]  & \\[3cm]  \hline
\end{tabularx}
\end{table}
\end{document}

보시다시피 여기에서도 이전과 동일한 트릭이 사용됩니다. 위의 MWE에서는 @{}열 간 공간을 제거했기 때문에 첫 번째 예에 비해 결과가 약간 향상되었습니다 .

부록 2:\\[3cm]셀 내용 주위에 더 많은 수직 공간을 만드는 데 사용하는 이유는 명확하지 않습니다 . 변경으로 얻을 수 있는 문제가 적은 유사한 효과 \arraystretch. 예를 들어 셀에 수직 공간을 더 합리적으로 추가하면 다음과 같이 테이블을 디자인할 수 있습니다.

\documentclass{article}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}% <-- cell's contend is vertically centered
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}

\begin{document}
\begin{table}[h]
    \renewcommand{\arraystretch}{3}
    \setlength{\extrarowheight}{-2.5pt}% <-- correction of vertical centering
\begin{tabularx}{\textwidth}{ | C | C |}
\hline
N_{1}
    &  (0: 1]   \\  \hline
\end{tabularx}
\end{table}
\end{document}

보시다시피 이제 가짜 열이 추가되지 않았습니다.

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

관련 정보