같은 페이지에 섹션 헤더와 회전된 표

같은 페이지에 섹션 헤더와 회전된 표

크기에 따라 회전해야 하는 테이블이 있습니다. 게다가 내 문서에서는 부록의 첫 번째 표이므로 섹션 헤더 뒤에 와야 합니다. Sidewaystable은 동일한 페이지에 섹션 헤더와 회전된 테이블을 모두 포함하는 것을 허용하지 않습니다. 따라서 hvfloat 패키지와 rotfloat / varwidth 패키지를 시도했지만 둘 다 완벽한 솔루션으로 이어지지는 않습니다.

\documentclass[12pt,a4paper]{article}

\usepackage{hvfloat}
\usepackage{rotfloat}
\usepackage{varwidth}
    
\begin{document}

\section{Test Section 1}
\begin{center}
\hvFloat[nonFloat=true, capPos=t, rotAngle=90, objectPos=c]%
{table}%
{\begin{tabular}{lll}
column 1a & column 2a & column 3a \\
column 1b & column 2b & column 3b \\
column 1c & column 2c & column 3c \\
\end{tabular}}
{A rotated table}
{tab:test1}
\end{center}

\newpage
\section{Test Section 2}       
\begin{table}[H]
\begin{center}
\rotatebox{90}{%
\begin{varwidth}{\textheight}
\caption{Another rotated table}\label{tab:test2}
\begin{tabular}{lll}
column 1a & column 2a & column 3a \\
column 1b & column 2b & column 3b \\
column 1c & column 2c & column 3c \\
\end{tabular}
\captionsetup{font=footnotesize}  
\caption*{This table is just a test.}
\end{varwidth}}
\end{center}
\end{table}

\end{document}

두 경우 모두 테이블이 섹션 헤더와 같은 페이지에 있지만 다음과 같은 결과를 얻었습니다.

hvfloat의 경우 (1) 옵션을 사용해 capPos=t도 캡션은 항상 테이블 왼쪽에 남아 있습니다. 문서를 읽었지만 여기서 내가 뭘 잘못하고 있는지 전혀 모르겠습니다. (2) 표 메모를 추가하는 옵션을 찾을 수 없습니다(제가 사용하는 표 환경에서는 작동하지 \caption*{Table Notes}않지만 여기서는 작동하지 않습니다). 테이블은 제가 원하는 대로 수직, 수평으로 배치되어 있습니다.

회전 상자의 경우 표 상단에 캡션을 표시하고 표 아래에 표 메모를 표시했지만 표는 페이지 하단에 그대로 남아 있습니다(수평으로 중앙에 배치되고 수직으로 섹션 헤더를 따라야 함). ).

어떤 힌트라도 높이 평가하겠습니다. 감사합니다.

답변1

capPos=top대신 사용하면 capPos=t다음과 같은 결과가 출력됩니다.

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

\documentclass[12pt,a4paper]{article}

\usepackage{hvfloat}
\usepackage{rotfloat}
\usepackage{varwidth}
    
\begin{document}

\section{Test Section 1}
\begin{center}
\hvFloat[nonFloat=true, capPos=top, rotAngle=90, objectPos=c]%
{table}%
{\begin{tabular}{lll}
column 1a & column 2a & column 3a \\
column 1b & column 2b & column 3b \\
column 1c & column 2c & column 3c \\
\end{tabular}}
{A rotated table}
{tab:test1}
\end{center}
\end{document}

테이블 ntes에 대한 및 tabular*a :\multicolumn

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

\documentclass[12pt,a4paper]{article}

\usepackage{hvfloat}
\usepackage{booktabs}

\begin{document}

\section{Test Section 1}
\begin{center}
\hvFloat[nonFloat=true, capPos=top, rotAngle=90, objectPos=c]%
{table}%
{\begin{tabular*}{7cm}{@{\extracolsep{\fill}}lll@{}}
\toprule
column 1a & column 2a & column 3a \\
column 1b & column 2b & column 3b \\
column 1c & column 2c & column 3c \\
\bottomrule
\multicolumn{3}{@{}p{7cm}@{}}{these are some table notes these are some table notes these are some table notes these are some table notes these are some table notes}\\
\end{tabular*}}
{A rotated table}
{tab:test1}

\end{center}
\end{document}

답변2

제목 을 추가할 때의 주요 문제점은 \section남은 공간(회전 전 너비)이 줄어든다는 것입니다. 또한 테이블을 미니페이지처럼 작동하도록 만드는 \setcaptype것보다 미니페이지를 테이블처럼 작동하도록 만드는 것이 더 쉽습니다(참고자료 참조 ).

미니페이지의 세 번째 선택적 인수 는 \centering수직 위치(회전 후)에 영향을 미치는 반면, 미니페이지의 세 번째 선택적 인수는 수평 위치(회전 후)에 영향을 미칩니다.

\documentclass[12pt,a4paper]{article}

\usepackage{adjustbox}
\usepackage{threeparttable}
\usepackage{showframe}% MWE only

\newsavebox{\tempbox}

\newcommand{\setcaptype}[1]% #1 = figure or table
  {\expandafter\def\csname @captype\endcsname{#1}\ignorespaces}
    
\begin{document}

\setbox\tempbox=\vbox{\section{Test Section 2}}% measure size of section title
\usebox\tempbox

\rotatebox{90}{\begin{minipage}[c][\textwidth][c]{\dimexpr \textheight-\ht\tempbox-\dp\tempbox-\baselineskip-\parskip}
\setcaptype{table}\centering
\begin{threeparttable}
\caption{Another rotated table}\label{tab:test2}
\begin{tabular}{lll}
column 1a & column 2a & column 3a \\
column 1b & column 2b & column 3b \\
column 1c & column 2c & column 3c \\
\end{tabular}
\begin{tablenotes}
\item The first note.
\end{tablenotes}
\end{threeparttable}
\end{minipage}}

\end{document}

관련 정보