
나는 교수들이 부과한 제한으로 인해 테이블에 대해 따르는 매우 일반적인 형식을 가지고 있습니다. LaTeX를 반드시 사용해야 하는 것은 아니지만 서식 지정 등의 측면에서 내 생활이 더 쉬워졌습니다. 그러나 우리가 따라야 하는 표 형식으로 인해 캡션을 올바른 위치로 옮기는 방법에 어려움을 겪었기 때문에 표에서 캡션을 사용할 수 없습니다. 이로 인해 LaTeX가 우리를 위해 추적하는 테이블 번호와 모든 성가신 항목을 추적해야 합니다. 아래에 형식과 이를 만드는 데 사용한 내용을 포함했습니다.
\begin{table}[H]
\centering
\setlength{\arrayrulewidth}{2pt}
\begin{tabular}{cccccc}
\multicolumn{5}{l}{\textbf{Table 3} Main Effects and Interactions}\\
\hline\\
\underline{Combination} & \underline{$\sum\Delta T^{+}$} & \underline{$\sum\Delta T^{-}$} & \underline{Contrast} & \underline{Main Effect (E)} & \underline{Absolute Effect $|E|$}\\[0.25cm]
A & 251.03& 376.99& -125.96& -10.49 & 10.49\\[0.125cm]
B & 372.03& 255.99& 116.04& 9.67 & 9.67\\[0.125cm]
AB & 305.82& 322.2& -16.38& -1.365 & 1.365\\[0.125cm]
C & 274.89& 353.13& -78.24& -6.52 & 6.52\\[0.125cm]
AC & 324.9& 303.12& 21.78& 1.815 & 1.815\\[0.125cm]
BC & 337.3& 290.72& 46.58& 3.88 & 3.88\\[0.125cm]
ABC & 306.09& 321.93& -15.84& -1.32 & 1.32\\[0.125cm]
\hline
\end{tabular}
\label{tab:effects}
\end{table}
나는 내가 수동으로 숫자를 추적할 필요가 없도록 이미지에 있는 방식으로 테이블 번호와 캡션을 배치할 수 있는 방법을 아는 사람이 있는지 확인하고 싶었습니다. 표 형식 환경 위에 캡션을 정의하고 정당화하는 등의 작업을 시도했지만 작동하지 않았습니다. 나는 위치 지정 요구 사항에 반드시 동의하지는 않지만 성적에 영향을 미치므로 선택의 여지가 많지 않습니다. 어떤 도움이라도 대단히 감사하겠습니다.
답변1
저는 이 caption
패키지를 사용하여 교수님의 형식 요구 사항에 맞게 캡션의 모양을 미세 조정하겠습니다. 또한 숫자 데이터 열의 형식을 지정하기 위해 siunitx
패키지와 해당 열 유형을 로드하고 간격이 적절한 수평선에 대한 패키지를 S
로드했습니다 . booktabs
을(를) 사용하지 마십시오 \underline
. 대신에 \cmidrule
. 마지막으로, 표 형식의 자료가 텍스트 블록의 너비 안에 들어갈 수 있도록 환경 tabular*
대신 환경을 사용하는 것을 고려해보세요.tabular
\documentclass{article}
\usepackage{booktabs} % for sell-spaced horizontal lines
\usepackage{siunitx} % for 'S' column type
\usepackage{caption} % fine control over caption appearance
\captionsetup{labelfont=bf,singlelinecheck=false,
labelsep=space,skip=2pt}
\begin{document}
\begin{table}
\setlength\heavyrulewidth{2pt} % does it have to be soooo wide?
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{0pt}
\caption{Main Effects and Interactions} \label{tab:effects}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
c *{2}{S[table-format= 3.2]}
S[table-format=-3.2]
S[table-format=-2.3]
S[table-format= 2.3] @{}}
\toprule
Combination & {$\sum\Delta T^{+}$} &
{$\sum\Delta T^{-}$} & {Contrast} &
{Main Effect ($E$)} & {Abs.\ Effect $|E|$} \\
\cmidrule{1-1} \cmidrule{2-2} \cmidrule{3-3}
\cmidrule{4-4} \cmidrule{5-5} \cmidrule{6-6}
A & 251.03& 376.99& -125.96& -10.49 & 10.49\\
B & 372.03& 255.99& 116.04& 9.67 & 9.67 \\
AB & 305.82& 322.2 & -16.38& -1.365 & 1.365\\
C & 274.89& 353.13& -78.24& -6.52 & 6.52 \\
AC & 324.9 & 303.12& 21.78& 1.815 & 1.815\\
BC & 337.3 & 290.72& 46.58& 3.88 & 3.88 \\
ABC & 306.09& 321.93& -15.84& -1.32 & 1.32 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
답변2
캡션 패키지와 일부 옵션에 그런 것이 있다고 생각합니까?
\documentclass[12pt]{article}
\usepackage[labelfont=bf]{caption}
\captionsetup{justification=raggedright,
singlelinecheck=false
}
\begin{document}
\begin{table}[h]
\centering
\setlength{\arrayrulewidth}{2pt}
\caption{Main Effects and Interaction}
\begin{tabular}{cccccc}
\hline\\
\underline{Combination} & \underline{$\sum\Delta T^{+}$} & \underline{$\sum\Delta T^{-}$} & \underline{Contrast} & \underline{Main Effect (E)} & \underline{Absolute Effect $|E|$}\\[0.25cm]
A & 251.03& 376.99& -125.96& -10.49 & 10.49\\[0.125cm]
B & 372.03& 255.99& 116.04& 9.67 & 9.67\\[0.125cm]
AB & 305.82& 322.2& -16.38& -1.365 & 1.365\\[0.125cm]
C & 274.89& 353.13& -78.24& -6.52 & 6.52\\[0.125cm]
AC & 324.9& 303.12& 21.78& 1.815 & 1.815\\[0.125cm]
BC & 337.3& 290.72& 46.58& 3.88 & 3.88\\[0.125cm]
ABC & 306.09& 321.93& -15.84& -1.32 & 1.32\\[0.125cm]
\hline
\end{tabular}
\label{tab:effects}
\end{table}
\end{document}
도움이 되길 바랍니다 :-)
로맹
답변3
원하는 것이 무엇인지 잘 이해했다면 caption
및 floatrow
패키지를 사용하여 원하는 것을 얻을 수 있습니다. 테이블에 몇 가지 개선 사항을 추가했습니다. s를 (from ) \underline
으로 바꾸어 모든 짧은 줄을 동일한 수준에 두고, 열 지정자를 에서 로 변경하여 열의 모든 숫자를 소수점에 정렬하도록 했습니다.cmidrule
booktabs
c
S
또한 테이블이 기본 여백에 비해 너무 넓습니다. 그래서 보다 합리적인 기본값을 정의하는 기하학을 로드했습니다.
\documentclass{article}
\usepackage{array, caption, floatrow, booktabs}
\usepackage{siunitx}
\usepackage[showframe]{geometry}
\begin{document}
\setcounter{table}{2}
\begin{table}[!htb]
\centering
\captionsetup{singlelinecheck=off, labelfont=bf, skip=0pt}
\floatsetup{captionskip=6pt}
\setlength{\arrayrulewidth}{2pt}
\sisetup{ table-number-alignment=center}
\ttabbox{\caption{Main Effects and Interactions}\label{tab:effects}}
{\begin{tabular}{c*{2}{S[table-format=3.2]}S[table-format=-3.2]S[table-format=-2.3]S[table-format=2.3]}
\toprule
Combination & {$\sum\Delta T^{+}$} & {$\sum\Delta T^{-}$} & {Contrast} & {Main Effect (E)} &{Absolute Effect $|E|$}\\
\cmidrule(lr){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(lr){5-5}\cmidrule(lr){6-6}
\addlinespace
A & 251.03& 376.99& -125.96& -10.49 & 10.49\\
\addlinespace
B & 372.03& 255.99& 116.04& 9.67 & 9.67\\
\addlinespace
AB & 305.82& 322.2& -16.38& -1.365 & 1.365\\
\addlinespace
C & 274.89& 353.13& -78.24& -6.52 & 6.52\\
\addlinespace
AC & 324.9& 303.12& 21.78& 1.815 & 1.815\\
\addlinespace
BC & 337.3& 290.72& 46.58& 3.88 & 3.88\\
\addlinespace
ABC & 306.09& 321.93& -15.84& -1.32 & 1.32\\
\bottomrule
\end{tabular}}
\end{table}
\end{document}
편집하다:
여기에 사용된 구문은 다소 구체적입니다 floatrow
. 일반 매크로를 정의합니다 \floatbox
. 이 매크로는 각각 그림과 표에 대한 a \ffigbox
및 a 매크로를 전문으로 하며 \ttabbox
두 개의 필수 인수(캡션, 플로팅 개체), 세 개의 선택적 인수(상자 컨테이너의 너비와 높이, 개체의 수직 위치)를 사용합니다. 그 상자. 캡션 너비는 상자 너비이며 기본적으로 부동 개체의 기본 너비입니다.