セクション ヘッダーと回転したテーブルが同じページに表示される

セクション ヘッダーと回転したテーブルが同じページに表示される

サイズの関係で回転させる必要のある表があります。さらに、私の文書では、この表は付録の最初の表なので、セクション ヘッダーの後に続く必要があります。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}が、ここでは機能しません)。表自体は、私が希望するように垂直方向と水平方向に配置されています。

rotatebox の場合、キャプションを表の上に、表の注釈を表の下に配置することはできますが、何をしても表はページの下部に残ります (水平方向に中央揃えされ、垂直方向にセクション ヘッダーに追従する必要があります)。

ヒントがあれば、ぜひ教えてください。ありがとうございます。

答え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*と、次のようになります。\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は垂直位置 (回転後) に影響し、ミニページの 3 番目のオプション引数は水平位置 (回転後) に影響することに注意してください。

\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}

関連情報