
다음과 같은 부분 테이블이 있습니다.
\begin{table}[!h]
\centering
\begin{adjustbox}{width=1\textwidth}
\small
\begin{tabular}{|l||l|}
\hline
\textbf{Element Name} & \textbf{Description} \\
\hline
SemiMajorAxis & The length of the semi-major axis $a$, $b$ and $c$ of the 3D \\\hline
\end{tabular}
\end{adjustbox}
\caption[A description of the XML elements containing the ellipsoid information]{A description of the XML elements containing the information of the ellipsoid.}
\label{tab:XML_defs}
\end{table}
나머지 행에 영향을 주지 않고 "요소 이름"과 "설명"이라는 이름을 셀 중앙에 정렬하고 싶습니다.
답변1
교체해야합니다
\textbf{Element Name} &
\textbf{Description}
~와 함께
\multicolumn{1}{|c||}{\textbf{Element Name}} &
\multicolumn{1}{c|}{\textbf{Description}}
\adjustbox
테이블을 텍스트 블록의 너비에 맞추는 대신 tabularx
환경 대신 환경 을 사용하고 두 번째 열에 tabular
유형의 열을 사용하는 것을 고려하십시오. 필요에 따라 X
열의 텍스트 X
를 줄 바꿈할 수 있습니다. 모든 수직선을 제거하고 수평선을 좀 더 아껴서 테이블을 좀 더 "개방적인" 모양으로 만드는 것을 고려할 수도 있습니다. 다음 스크린샷에서는 패키지의 선 그리기 매크로를 사용하여 두 번째 테이블을 그립니다 booktabs
.
\documentclass{article}
\usepackage{tabularx,booktabs}
\begin{document}
\begin{table}[!h]
\begin{tabularx}{\textwidth}{|l||X|}
\hline
\multicolumn{1}{|c||}{\textbf{Element Name}} &
\multicolumn{1}{c|}{\textbf{Description}} \\
\hline
SemiMajorAxis & The length of the semi-major axis $a$, $b$ and $c$ of the 3D \\
\hline
\end{tabularx}
\caption[A description of the XML elements containing the ellipsoid information]{A description of the XML elements containing the information of the ellipsoid.}
\label{tab:XML_defs}
\bigskip\bigskip
\begin{tabularx}{\textwidth}{lX}
\toprule
\textbf{Element Name} & \textbf{Description} \\
\addlinespace
SemiMajorAxis & The length of the semi-major axis $a$, $b$ and $c$ of the 3D \\
\bottomrule
\end{tabularx}
\caption{Another, more ``open'' form of the same table}
\end{table}
\end{document}
답변2
패키지를 사용할 수 있습니다 makecell
. 해당 \thead
명령(및 일부 다른 명령)은 내용의 공통 형식 지정 및 줄 바꿈을 허용합니다. 기본적으로 수직 및 수평 중앙에 위치합니다. \setcellgapes
및 명령을 사용하여 셀에 수직 패딩을 제공할 수 있습니다 \makegapedcells
. 수직 이중 괘와 수평 괘를 깔끔하게 교차시키려면 s를 사용하는 것이 더 좋습니다 \hhline
:
\documentclass{article}
\usepackage{adjustbox, array, hhline}
\usepackage{makecell}
\renewcommand\theadfont{\normalfont\bfseries}
\setcellgapes{4pt}
\usepackage[showframe]{geometry}
\begin{document}
\vspace*{1cm}
\begin{table}[!h]
\centering\makegapedcells
\begin{tabular}{|l||l|}
\hline
\thead{Element Name} & \thead{Description} \\
\hhline{|-||-|}
SemiMajorAxis & The length of the semi-major axis $a$, $b$ and $c$ of the 3D \\\hline
\end{tabular}%
\caption[A description of the XML elements containing the ellipsoid information]{A description of the XML elements containing the information of the ellipsoid.}
\label{tab:XML_defs}
\end{table}
\end{document}