将大型长表缩放/缩小到 pdflscape

将大型长表缩放/缩小到 pdflscape

编译

我有一个用 excel2latex 转换的超大表格。它可能跨越几页,但目前,它远远超出了我的景观的边缘,尽管“评估指标”和“主题集群”下的列(它们可以更窄,但我无法更改它们的宽度)。是否可以使用调整框或其他缩放方法来使表格适合页面?我已经查看了论坛上发现的许多建议解决方案,但无法将它们中的任何一个应用于我的情况。我正在添加表格的前几行:

\documentclass[a4paper,12pt,headings=openany,numbers=noenddot,listof=totoc]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[USenglish]{babel}
\usepackage{erewhon}
\usepackage{graphicx}
\usepackage{float}
\usepackage[top=2.5cm,bottom=3.5cm,left=3cm,right=3cm,headheight=14.5pt,footnotesep=1cm,marginparsep=1cm]{geometry}
\usepackage{setspace}
\usepackage[markcase=ignoreupper]{scrlayer-scrpage}
\clearpairofpagestyles
\automark[subsection]{section}
\ohead{\headmark}
\ofoot*{\pagemark}
\usepackage{xcolor}
\pagenumbering{arabic}
\deffootnote[1em]{1.5em}{1em}{\thefootnotemark\ }
\usepackage[final]{pdfpages}
\usepackage{booktabs}   
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{amssymb}
\usepackage[labelsep=colon,font={footnotesize,sf},labelfont={footnotesize,sf}]{caption}
\DeclareCaptionLabelFormat{cont}{#1~#2\alph{ContinuedFloat}}
\captionsetup[ContinuedFloat]{labelsep=period,labelformat=cont}
\usepackage{chngcntr}
\counterwithout{table}{chapter}
\usepackage{afterpage}
\usepackage[figuresright]{rotating}
\usepackage{adjustbox}
\usepackage{ltablex}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}
\begin{landscape}
                \tiny
                \singlespacing
%               \setlength\LTleft{0pt}
%               \setlength\LTright{0pt}
                \setlength{\tabcolsep}{3pt}
                % Table generated by Excel2LaTeX from sheet 'Table_1'
                \begin{longtable}{ >{\tiny} p{18em}|p{1em}|p{1em}lp{1em}lp{1em}lp{1em}lp{1em}ll|llllllll|llllll|}
                        \centering
                        \multirow{2}[2]{*}{\parbox{3.8cm}{\textbf{Author and year of publication (chronologically)}}} & \multicolumn{1}{c}{\multirow{2}[2]{*}{\parbox{1cm}{\textbf{Number of datasets}}}} & \multicolumn{1}{c}{\multirow{2}[2]{*}{\parbox{1cm}{\textbf{Year of dataset}}}} & \multicolumn{1}{c}{\multirow{-8}[-8]{*}{\parbox{1cm}{\textbf{Monitoring period (year=y, month=m, week=w, day=d)}}}} & \multicolumn{1}{c}{\multirow{2}[2]{*}{\parbox{1.5cm}{\textbf{Monitoring place}}}} & \multicolumn{1}{c}{\multirow{2}[2]{*}{\parbox{.5cm}{\textbf{Obser\-vations}}}} & \multicolumn{1}{c|}{\multirow{2}[2]{*}{\parbox{.5cm}{\textbf{Vari\-ables}}}} & \multicolumn{6}{p{\widthof{GB}+\widthof{GD}+\widthof{MAE}+\widthof{MAPE}+\widthof{MASE}+\widthof{MRE}+\widthof{MSE}}}{\centering\textbf{Evaluation metrics}} & \multicolumn{4}{r|}{}         & \multicolumn{6}{l|}{\parbox{4cm}{\textbf{Thematic clusters}}} \\
                        \multicolumn{1}{|c|}{} &       &       &       &       &       &       & \multicolumn{1}{l}{\textbf{GB}} & \multicolumn{1}{l}{\textbf{GD}} & \multicolumn{1}{p{2em}}{\parbox{.25cm}{\textbf{MAE}}} & \multicolumn{1}{p{2em}}{\parbox{.25cm}{\textbf{MAPE}}} & \multicolumn{1}{p{2em}}{\parbox{.25cm}{\textbf{MASE}}} & \multicolumn{1}{p{2em}}{\parbox{.25cm}{\textbf{MRE}}} & \multicolumn{1}{p{4.055em}}{\parbox{.25cm}{\textbf{MSE}}} & \multicolumn{1}{p{4.055em}}{\textbf{RMSE}} & \multicolumn{1}{p{4.055em}}{\textbf{AUC}} & \multicolumn{1}{p{1em}|}{\parbox{0.2cm}{\textbf{$\sigma$}}} & \multicolumn{1}{p{4.055em}}{\textbf{W/E}} & \multicolumn{1}{p{4.055em}}{\textbf{TE}} & \multicolumn{1}{p{4.055em}}{\textbf{HB}} & \multicolumn{1}{p{4.055em}}{\textbf{EF}} & \multicolumn{1}{p{4.055em}}{\textbf{SocDem}} & \multicolumn{1}{p{4.055em}|}{\textbf{BT}} \\
                        \midrule
                        Hawarah, Ploix \& Jacomino (2010) & 1     &       & \multicolumn{1}{p{5.22em}}{1y} & \multicolumn{1}{p{7.665em}}{France} &       & 7     &       &       &       &       &       &       &       &       &       &       &       &       & \multicolumn{1}{p{4.055em}}{X} &       &       &  \\
                        Basu et al. (2011) & 1     &       & \multicolumn{1}{p{5.22em}}{1y} & \multicolumn{1}{p{7.665em}}{France} &       & 10    &       & \multicolumn{1}{p{4.055em}}{X} &       &       &       &       &       &       &       &       & \multicolumn{1}{p{4.055em}}{X} & \multicolumn{1}{p{4.055em}}{X} &       &       &       &  \\
                        Kandananond (2011) & 1     & \multicolumn{1}{p{4.055em}}{1986–2010} & \multicolumn{1}{p{5.22em}}{25y} & \multicolumn{1}{p{7.665em}}{Thailand} &       &       &       &       &       & \multicolumn{1}{p{4.055em}}{X} &       &       &       &       &       &       &       &       &       & \multicolumn{1}{p{4.055em}}{X} &       &  \\
\bottomrule
                        \bottomrule
                    \end{longtable}%
                    \label{tab:addlabel}%
            \end{landscape}
\end{document} 

答案1

使用的标记非常复杂(您永远不需要在 ap 列中嵌套 parbox,并且除了标题之外,您根本不需要在这里使用 parbox 换行。虽然我可能错过了一些垂直线和对齐,但这是合适的。

在此处输入图片描述

\documentclass[a4paper,12pt,headings=openany,numbers=noenddot,listof=totoc]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[USenglish]{babel}
\usepackage{erewhon}
\usepackage{graphicx}
\usepackage{float}
\usepackage[top=2.5cm,bottom=3.5cm,left=3cm,right=3cm,headheight=14.5pt,footnotesep=1cm,marginparsep=1cm]{geometry}
\usepackage{setspace}
\usepackage[markcase=ignoreupper]{scrlayer-scrpage}
\clearpairofpagestyles
\automark[subsection]{section}
\ohead{\headmark}
\ofoot*{\pagemark}
\usepackage{xcolor}
\pagenumbering{arabic}
\deffootnote[1em]{1.5em}{1em}{\thefootnotemark\ }
\usepackage[final]{pdfpages}
\usepackage{booktabs}   
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{amssymb}
\usepackage[labelsep=colon,font={footnotesize,sf},labelfont={footnotesize,sf}]{caption}
\DeclareCaptionLabelFormat{cont}{#1~#2\alph{ContinuedFloat}}
\captionsetup[ContinuedFloat]{labelsep=period,labelformat=cont}
\usepackage{chngcntr}
\counterwithout{table}{chapter}
\usepackage{afterpage}
\usepackage[figuresright]{rotating}
\usepackage{adjustbox}
\usepackage{ltablex}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}
\begin{landscape}
                \tiny
                \singlespacing
               \setlength\LTleft{-1.5cm plus 1fill}
               \setlength\LTright{-1.5cm plus 1fill}
                \setlength{\tabcolsep}{2pt}
                % Table generated by Excel2LaTeX from sheet 'Table_1'
                \begin{longtable}{@{}p{18em}|l|lllllllllll|llllllll|llllll|@{}}
                \bfseries\thead{Author and year\\ of publication\\ (chronologically)} &
 \bfseries\thead{Number\\ of\\ datasets} &
\bfseries\thead{Year\\ of\\ dataset} &
\bfseries\thead{Monit-\\oring\\ period} &
\bfseries\thead{Monit-\\oring\\ place} & 
\bfseries\thead{Obser-\\vations} &
\bfseries\thead{Vari-\\ables} &
\multicolumn{6}{c}{\bfseries\thead{Evaluation metrics}} &
 \multicolumn{4}{r|}{}         &
 \multicolumn{6}{l|}{\bfseries\thead{Thematic clusters}}\\
                        \multicolumn{1}{|c|}{} &       &       &       &       &       &       & \textbf{GB} & \textbf{GD} & \textbf{MAE} & \textbf{MAPE} & \textbf{MASE} & \textbf{MRE} & \textbf{MSE} & \textbf{RMSE} & \textbf{AUC} & \boldmath$\sigma$ & \textbf{W/E} & \textbf{TE} & \textbf{HB} & \textbf{EF} & \textbf{SocDem} & \textbf{BT}\\
                        \midrule
                        Hawarah, Ploix \& Jacomino (2010) & 1     &       & 1y & France &       & 7     &       &       &       &       &       &       &       &       &       &       &       &       & X &       &       &  \\
                        Basu et al. (2011) & 1     &       & 1y & France &       & 10    &       & X &       &       &       &       &       &       &       &       & X & X &       &       &       &  \\
                        Kandananond (2011) & 1     & 1986–2010 & 25y & Thailand &       &       &       &       &       & X &       &       &       &       &       &       &       &       &       & X &       &  \\
\bottomrule
                        \bottomrule
                    \end{longtable}%
                    \label{tab:addlabel}%
            \end{landscape}
\end{document} 

答案2

在此处输入图片描述

\documentclass[a4paper,12pt,headings=openany,numbers=noenddot,listof=totoc]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[USenglish]{babel}
\usepackage{erewhon}
\usepackage{graphicx}
\usepackage{float}
\usepackage[top=2.5cm,bottom=3.5cm,left=3cm,right=3cm,headheight=14.5pt,footnotesep=1cm,marginparsep=1cm]{geometry}
\usepackage{setspace}
\usepackage[markcase=ignoreupper]{scrlayer-scrpage}
\clearpairofpagestyles
\automark[subsection]{section}
\ohead{\headmark}
\ofoot*{\pagemark}
\usepackage{xcolor}
\pagenumbering{arabic}
\deffootnote[1em]{1.5em}{1em}{\thefootnotemark\ }
\usepackage[final]{pdfpages}
\usepackage{booktabs}   
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{amssymb}
\usepackage[labelsep=colon,font={footnotesize,sf},labelfont={footnotesize,sf}]{caption}
\DeclareCaptionLabelFormat{cont}{#1~#2\alph{ContinuedFloat}}
\captionsetup[ContinuedFloat]{labelsep=period,labelformat=cont}
\usepackage{chngcntr}
\counterwithout{table}{chapter}
\usepackage{afterpage}
\usepackage[figuresright]{rotating}
\usepackage{adjustbox}
\usepackage{ltablex}
\usepackage{multirow}
\usepackage{makecell}
\renewcommand{\theadfont}{\bfseries}
\usepackage{xltabular}

\begin{document}
\begin{landscape}
  \scriptsize
  \setlength{\tabcolsep}{2pt}
  \begin{xltabular}{\textwidth}{@{}>{\raggedright\arraybackslash}Xccrlrr*{17}{c}@{}}
  \caption{caption on the first page}
  \label{tab:key}\\
  \toprule
    \multirow{2}{*}{\thead{Author\\ \& year\textsuperscript{a)}}} 
    & \multirow{2.25}{*}{\thead{No. of\\ datasets}} 
    & \multirow{2.25}{*}{\thead{Year of\\ dataset}} 
    & \multicolumn{2}{c}{\thead{Monitoring}} 
    & \multirow{2.25}{*}{\thead{Obser-\\ vations}} 
    & \multirow{2.25}{*}{\thead{Vari-\\ ables}} 
    & \multicolumn{6}{c}{\thead{Evaluation metrics}} 
    & & & &        
    & \multicolumn{6}{c}{\thead{Thematic clusters}} 
\\
\cmidrule{4-5} \cmidrule{8-13} \cmidrule{18-24}
    &  &  &  \thead{period\textsuperscript{b)}}   &  \thead{place}  &  & 
    & \thead{GB}   & \thead{GD}       & \thead{MAE}    & \thead{MAPE} 
    & \thead{MASE} & \thead{MRE}      & \thead{MSE}    & \thead{RMSE} 
    & \thead{AUC}  & \thead{$\sigma$} & \thead{W/E}    & \thead{TE} 
    & \thead{HB}   & \thead{EF}       & \thead{SocDem} & \thead{BT} \\
\midrule
\endfirsthead
  \caption[]{caption on the following pages}\\
    \multirow{2}{*}{\thead{Author\\ \& year\textsuperscript{a)}}} 
    & \multirow{2.25}{*}{\thead{No. of\\ datasets}} 
    & \multirow{2.25}{*}{\thead{Year of\\ dataset}} 
    & \multicolumn{2}{c}{\thead{Monitoring}} 
    & \multirow{2.25}{*}{\thead{Obser-\\ vations}} 
    & \multirow{2.25}{*}{\thead{Vari-\\ ables}} 
    & \multicolumn{6}{c}{\thead{Evaluation metrics}} 
    & & & &        
    & \multicolumn{6}{c}{\thead{Thematic clusters}} 
\\
\cmidrule{4-5} \cmidrule{8-13} \cmidrule{18-24}
    &  &  &  \thead{period\textsuperscript{b)}}   &  \thead{place}  &  & 
    & \thead{GB}   & \thead{GD}       & \thead{MAE}    & \thead{MAPE} 
    & \thead{MASE} & \thead{MRE}      & \thead{MSE}    & \thead{RMSE} 
    & \thead{AUC}  & \thead{$\sigma$} & \thead{W/E}    & \thead{TE} 
    & \thead{HB}   & \thead{EF}       & \thead{SocDem} & \thead{BT} \\
\midrule
\endhead
\bottomrule
\multicolumn{24}{l}{\textsuperscript{a)} sorted chronologically by publication year, \textsuperscript{b)} year=y, month=m, week=w, day=d}\\
\endfoot
   Hawarah, Ploix \& Jacomino (2010) & 1     &       & 1 y & France &       & 7     &       &       &       &       &       &       &       &       &       &       &       &       & X &       &       &  \\ \addlinespace
  Basu et al. (2011) & 1     &       & 1 y & France &       & 10    &       & X &       &       &       &       &       &       &       &       & X & X &       &       &       &  \\ \addlinespace
  Kandananond (2011) & 1     & 1986–2010 & 25 y & Thailand &       &       &       &       &       & X &       &       &       &       &       &       &       &       &       & X &       &  \\
\end{xltabular}
\end{landscape}
\end{document} 

相关内容