文档中横向表格布局遵循普通表格的问题

文档中横向表格布局遵循普通表格的问题

我有横跨多页的横向表格,这些表格分为三部分,底部有一个注释部分。文档中的横向表格放在文档开头没问题。但在文本中位于普通表格之后的横向表格中,注释部分较窄(与前面非横向表格的注释部分的宽度相匹配)。

这是一个有效的例子:

\listfiles
\documentclass[12pt,a4paper,bibtotoc,liststotocnumbered,pointlessnumbers]{scrreprt}             

%---------------------------------------%
%       Layout          %
%---------------------------------------%
\usepackage[parfill]{parskip}           %use line breaks instead of
\usepackage[left=3.75cm, right=3.75cm, bottom=3.5cm]{geometry}

\usepackage{pdflscape}          %landscape single pages

%Sets up landscape pages for each landscape page.
\usepackage{pdfpages}           % http://ctan.org/pkg/pdfpages 

\usepackage[absolute]{textpos}
\usepackage{fancyhdr}

\fancypagestyle{lscape}{% 
\fancyhf{} % clear all header and footer fields 
\fancyfoot[LE]{%
\begin{textblock}{20}(1,5){\rotatebox{90}{\leftmark}}\end{textblock}}
\fancyfoot[LO] {%
\begin{textblock}{1}(14,7.5){\rotatebox{90}{\thepage}}\end{textblock}}
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{0pt}}

%---------------------------------------%
%   Tables & Figures        %
%---------------------------------------%
\usepackage{booktabs}
\usepackage{multirow}               % Allows rows in tables to be combined.
\usepackage{threeparttable}         % Allows for three part tables with a specified notes section.
\usepackage{threeparttablex}            % Lets threeparttable work with longtable
\usepackage{longtable}              % Allows tables to break across pages
\newcommand{\head}[1]{\textsf{\textbf{#1}}}

\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\usepackage{floatrow}
\floatsetup[table]{capposition = top, font = sf}    %Sets table to sans serif font and puts caption on top
\floatsetup[figure]{capposition = top, font = sf}   %Sets table to sans serif font and puts caption on top

\usepackage{caption}
\captionsetup{font={sf,large},justification=justified, singlelinecheck=false}
\setkomafont{caption}{\sffamily}
\setkomafont{captionlabel}{\upshape\bfseries\sffamily}

\renewcommand{\topfraction}{0.9}% max fraction of floats at top
\renewcommand{\textfraction}{0.07}
\renewcommand{\bottomfraction}{0.9}% max fraction of floats at bottom

%Set table for to be smaller
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{\small}
\AtBeginEnvironment{longtable}{\small}

% Package for including code in the document
\usepackage{listings}



\usepackage[english]{babel}
\usepackage{blindtext}\def\mytitle{Energy security under climate policies}
\def\myauthor{Jessica Jewell}
\begin{document}

\blindtext

\newgeometry{hmargin=3.5cm,vmargin=3.5cm}
\thispagestyle{lscape}
\pagestyle{lscape}

\begin{landscape}

\begin{ThreePartTable}
\begin{longtable}{C{4.4cm}C{1.2cm}C{1.4cm}C{1.7cm}C{3.6cm}P{8.0cm}}
\caption{\large{Previous studies}} \label{table1} 
\toprule
\ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
\head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} &\head{\centering{XXX}} \\
 \midrule
 \endfirsthead

 \toprule
 \ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
 \head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} & \head{\centering{XXX}} \\
 \midrule
 \endhead

 \multicolumn{6}{r}{{\emph{continues on next page}}} \\
 \endfoot

 \bottomrule
 \endlastfoot

  XXX & 2010 & XXXXl && This is an example of a working table \\
  XXX & 2010 & XXXXl && This is an example of a working table \\
  XXX & 2010 & XXXXl && This is an example of a working table \\
  XXX & 2010 & XXXXl && This is an example of a working table \\
  XXX & 2010 & XXXXl && This is an example of a working table \\
  XXX & 2010 & XXXXl && This is an example of a working table \\
  XXX & 2010 & XXXXl && This is an example of a working table       \end{longtable}
  \begin{tablenotes}
  \item Notes: These are some long notes to show that on the first table the text runs all the way across the bottom of the page. See? Isn't it lovely how it just lays down at the bottom of the page.

  \end{tablenotes}
  \end{ThreePartTable}
  \end{landscape}
  \restoregeometry
  \pagestyle{plain}


  \blindtext


  \begin{table*} 
  \begin{threeparttable}
 \caption{GDP and emissions of major economies} \label{meconomies}
 \begin{tabular}{lcccccc}
 \toprule
 && \multicolumn{2}{c}{\head{XXXXXXX}} && \multicolumn{2}{c}{\head{XXXXXXXX}} \\
 && XX & XX && XX & XX \\
 \midrule
 \head{XXXXX} && XX & XX && XX) & XX \\
 \head{XXXXX} && XX & XX && XX) & XX \\
 \head{XXXXX} && XX & XX && XX) & XX \\
 \bottomrule
 \end{tabular}
 \begin{tablenotes}
 \item Notes: This is meaningless not explaining the meaningless table.
 \end{tablenotes}
 \end{threeparttable}    
 \end{table*}



 \newgeometry{hmargin=3.5cm,vmargin=3.5cm}
 \thispagestyle{lscape}
 \pagestyle{lscape}

 \begin{landscape}

 \begin{ThreePartTable}
 \begin{longtable}{C{4.4cm}C{1.2cm}C{1.4cm}C{1.7cm}C{3.6cm}P{8.0cm}}
 \caption{\large{Previous studies}} \label{table2} 
 \toprule
 \ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
 \head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} &\head{\centering{XXX}} \\
 \midrule
 \endfirsthead

 \toprule
 \ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
 \head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} &   \head{\centering{XXX}} \\
 \midrule
 \endhead

 \multicolumn{6}{r}{{\emph{continues on next page}}} \\
 \endfoot

 \bottomrule
 \endlastfoot

 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table      \end{longtable}
 \begin{tablenotes}
 \item Notes: These are some long notes. See how the margin of these notes is wrong? They match the text width of the preceding threeparttable.

 \end{tablenotes}
 \end{ThreePartTable}
 \end{landscape}
 \restoregeometry
 \pagestyle{plain}

\blindtext

\end{document}

答案1

我最终使用 ThreePartTable 包找到了正确的解决方案。诀窍是ThreePartTable(与 一起工作,与longtable不同threeparttable,与 不一起工作)需要\TableNotes而不是\tablenotes。此外,插入这些的方式ThreePartTable略有不同。请参阅包装文档(第 3 页上的第一个示例)。这里也是我修正了最小工作示例的代码。

\listfiles
\documentclass[12pt,a4paper,bibtotoc,liststotocnumbered,pointlessnumbers]{scrreprt}             

%---------------------------------------%
%       Layout          %
%---------------------------------------%
\usepackage[parfill]{parskip}           %use line breaks instead of
\usepackage[left=3.75cm, right=3.75cm, bottom=3.5cm]{geometry}

 \usepackage{pdflscape}          %landscape single pages

 %Sets up landscape pages for each landscape page.
 \usepackage{pdfpages}           % http://ctan.org/pkg/pdfpages 

 \usepackage[absolute]{textpos}
 \usepackage{fancyhdr}

 \fancypagestyle{lscape}{% 
 \fancyhf{} % clear all header and footer fields 
 \fancyfoot[LE]{%
 \begin{textblock}{20}(1,5){\rotatebox{90}{\leftmark}}\end{textblock}}
 \fancyfoot[LO] {%
 \begin{textblock}{1}(14,7.5){\rotatebox{90}{\thepage}}\end{textblock}}
 \renewcommand{\headrulewidth}{0pt} 
 \renewcommand{\footrulewidth}{0pt}}

%---------------------------------------%
%   Tables & Figures        %
%---------------------------------------%
\usepackage{booktabs}
\usepackage{multirow}               % Allows rows in tables to be combined.
\usepackage{threeparttable}         % Allows for three part tables with a specified notes section.
 \usepackage{threeparttablex}            % Lets threeparttable work with longtable
 \usepackage{longtable}              % Allows tables to break across pages
 \newcommand{\head}[1]{\textsf{\textbf{#1}}}

 \usepackage{array}
 \usepackage{ragged2e}
 \newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
 \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
 \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

 \usepackage{floatrow}
 \floatsetup[table]{capposition = top, font = sf}    %Sets table to sans serif font and puts caption on top
 \floatsetup[figure]{capposition = top, font = sf}   %Sets table to sans serif font and puts caption on top

 \usepackage{caption}
 \captionsetup{font={sf,large},justification=justified, singlelinecheck=false}
 \setkomafont{caption}{\sffamily}
 \setkomafont{captionlabel}{\upshape\bfseries\sffamily}


% Package for including code in the document
\usepackage{listings}



 \usepackage[english]{babel}
 \usepackage{blindtext}\def\mytitle{Energy security under climate policies}
 \def\myauthor{Jessica Jewell}
 \begin{document}

 \blindtext

 \newgeometry{hmargin=3.5cm,vmargin=3.5cm}
 \thispagestyle{lscape}
 \pagestyle{lscape}

 \begin{landscape}

 \begin{ThreePartTable}
 \begin{TableNotes}
 \item Notes: These are some long notes to show that on the first table the text runs all the way across the bottom of the page. See? Isn't it lovely how it just lays down at the bottom of the page.

 \end{TableNotes}
 \end{ThreePartTable}

 \begin{longtable}{C{4.4cm}C{1.2cm}C{1.4cm}C{1.7cm}C{3.6cm}P{8.0cm}}
 \caption{\large{Previous studies}} \label{table1} 
 \toprule
 & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
\head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} &\head{\centering{XXX}} \\
 \midrule
 \endfirsthead

 \toprule
 \ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
 \head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} & \head{\centering{XXX}} \\
 \midrule
 \endhead

 \multicolumn{6}{r}{{\emph{continues on next page}}} \\
 \endfoot

 \bottomrule
 \insertTableNotes\\
 \endlastfoot

 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table \\
 XXX & 2010 & XXXXl && This is an example of a working table     \end{longtable}

\end{landscape}
\restoregeometry
\pagestyle{plain}


\blindtext


\begin{table*} 
\begin{threeparttable}
\caption{GDP and emissions of major economies} \label{meconomies}
\begin{tabular}{lcccccc}
\toprule
 && \multicolumn{2}{c}{\head{XXXXXXX}} && \multicolumn{2}{c}{\head{XXXXXXXX}} \\
 && XX & XX && XX & XX \\
\midrule
\head{XXXXX} && XX & XX && XX) & XX \\
\head{XXXXX} && XX & XX && XX) & XX \\
\head{XXXXX} && XX & XX && XX) & XX \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item Notes: This is meaningless not explaining the meaningless table.
\end{tablenotes}
\end{threeparttable}    
\end{table*}



\newgeometry{hmargin=3.5cm,vmargin=3.5cm}
\thispagestyle{lscape}
\pagestyle{lscape}

\begin{landscape}

\begin{ThreePartTable}
\begin{TableNotes}
\item Notes: These are some long notes. See how the margin of these notes is wrong? They match the text width of the preceding threeparttable.
\end{TableNotes}

\begin{longtable}{C{4.4cm}C{1.2cm}C{1.4cm}C{1.7cm}C{3.6cm}P{8.0cm}}
\caption{\large{Previous studies}} \label{table2} 
\toprule
\ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
\head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} &\head{\centering{XXX}} \\
\midrule
\endfirsthead

\toprule
 \ & & \multicolumn{3}{l}{\hspace{1.0cm}\head{Energy security focus}} & \\
 \head{XXX} & \head{XXX} & \head{XXX} & \head{XXX} & \head{\centering{XXXX}} &   \head{\centering{XXX}} \\
\midrule
\endhead

\multicolumn{6}{r}{{\emph{continues on next page}}} \\
\endfoot

\bottomrule
\insertTableNotes\\
\endlastfoot

XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table \\
XXX & 2010 & XXXXl && This is an example of a working table     \end{longtable}

\end{ThreePartTable}
\end{landscape}
\restoregeometry
\pagestyle{plain}

\blindtext

\end{document}

相关内容