表格适合文本宽度和文本高度

表格适合文本宽度和文本高度

下面的表格太长,无法容纳文本高度,宽度又不足以容纳文本宽度。我希望表格的高度符合注释掉的行“\resizebox*{!}{\dimexpr\textheight-4\baselineskip\relax}{%”指定的高度。但是,如果我添加该行,表格将不再拉伸以适合文本宽度(参见下面的行)。有什么建议吗?

\documentclass [twoside,12pt,letterpaper]{report}
\usepackage{booktabs}
\usepackage{graphicx}
\begin{document}
\begin{table}[t!]
\centering
\caption[Reference information for the Haydn Corpus]{Reference information (Opus number, work, movement, measures), keys, time signatures, and tempo markings for the exposition sections of each movement in the Haydn Corpus.}
%\resizebox*{!}{\dimexpr\textheight-4\baselineskip\relax}{%
\begin{tabular*}{1.0\textwidth}{@{\extracolsep{\fill}} lccl}
\toprule
\textit{Excerpts} & \textit{Key} & \textit{Time Signature} & \textit{Tempo Marking} \\
\midrule
Op. 17, No. 1, i, mm. 1–43  & E     & 4/4   & Moderato \\
Op. 17, No. 2, i, mm. 1–38  & F     & 4/4   & Moderato \\
Op. 17, No. 3, iv, mm. 1–26 & Eb    & 4/4   & Allegro molto \\
Op. 17, No. 4, i, mm. 1–53 & c     & 4/4   & Moderato \\
Op. 17, No. 5, i, mm. 1–33  & G     & 4/4   & Moderato \\
Op. 17, No. 6, i, mm. 1–73  & D     & 6/8   & Presto \\
Op. 20, No. 1, iv, mm. 1–55 & Eb    & 2/4   & Presto \\
Op. 20, No. 3, i, mm. 1–94  & g     & 2/4   & Allegro con spirito \\
Op. 20, No. 3, iii, mm. 1–43  & G     & 3/4   & Poco Adagio \\
Op. 20, No. 3, iv, mm. 1–42  & g     & 4/4   & Allegro molto \\
Op. 20, No. 4, i, mm. 1–112  & D     & 3/4   & Allegro di molto \\
Op. 20, No. 4, iv, mm. 1–49   & D     & 4/4   & Presto scherzando \\
Op. 20, No. 5, i, mm. 1–48  & f     & 4/4   & Allegro moderato \\
Op. 20, No. 6, ii, mm. 1–27  & E     & cut   & Adagio \\
Op. 33, No. 1, i, mm. 1–37  & b     & 4/4   & Allegro moderato \\
Op. 33, No. 1, iii, mm. 1–40  & D     & 6/8   & Andante \\
Op. 33, No. 2, i, mm. 1–32  & Eb    & 4/4   & Allegro moderato \\
Op. 33, No. 3, iii, mm. 1–29  & F     & 3/4   & Adagio \\
Op. 33, No. 4, i, mm. 1–31  & Bb    & 4/4   & Allegro moderato \\
Op. 33, No. 5, i, mm. 1–95   & G     & 2/4   & Vivace assai \\
Op. 33, No. 5, ii, mm. 1–30  & g     & 4/4   & Largo \\
Op. 50, No. 1, i, mm. 1–60  & Bb    & cut   & Allegro \\
Op. 50, No. 1, iv, mm. 1–75  & Bb    & 2/4   & Vivace \\
Op. 50, No. 2, i, mm. 1–106  & C     & 3/4   & Vivace \\
Op. 50, No. 2, iv, mm. 1–86   & C     & 2/4   & Vivace assai \\
Op. 50, No. 3, iv, mm. 1–74  & Eb    & 2/4   & Presto \\
Op. 50, No. 4, i, mm. 1–64  & f\#   & 3/4   & Allegro spirituoso \\
Op. 50, No. 5, i, mm. 1–65  & F     & 2/4   & Allegro moderato \\
Op. 50, No. 5, iv, mm. 1–54  & F     & 6/8   & Vivace \\
Op. 50, No. 6, i, mm. 1–54  & D     & 4/4   & Allegro \\
Op. 50, No. 6, ii, mm. 1–25  & d     & 6/8   & Poco Adagio \\
Op. 54, No. 1, i, mm. 1–47  & G     & 4/4   & Allegro con brio \\
Op. 54, No. 1, ii, mm. 1–54  & C     & 6/8   & Allegretto \\
Op. 54, No. 2, i, mm. 1–87  & C     & 4/4   & Vivace \\
Op. 54, No. 3, i, mm. 1–58  & E     & cut   & Allegro \\
Op. 54, No. 3, iv, mm. 1–82  & E     & 2/4   & Presto \\
Op. 55, No. 1, ii, mm. 1–36  & D     & 2/4   & Adagio cantabile \\
Op. 55, No. 2, ii, mm. 1–76  & f     & cut   & Allegro \\
Op. 55, No. 3, i, mm. 1–75  & Bb    & 3/4   & Vivace assai \\
Op. 64, No. 3, i, mm. 1–69  & Bb    & 3/4   & Vivace assai \\
Op. 64, No. 3, iv, mm. 1–79  & Bb    & 2/4   & Allegro con spirito \\
Op. 64, No. 4, i, mm. 1–38   & G     & 4/4   & Allegro con brio \\
Op. 64, No. 4, iv, mm. 1–66  & G     & 6/8   & Presto \\
Op. 64, No. 6, i, mm. 1–45  & Eb    & 4/4   & Allegretto \\
Op. 71, No. 1, i, mm. 1–69  & Bb    & 4/4   & Allegro \\
Op. 74, No. 1, i, mm. 1–54  & C     & 4/4   & Allegro moderato \\
Op. 74, No. 1, ii, mm. 1–57  & G     & 3/8   & Andantino grazioso \\
Op. 76, No. 2, i, mm. 1–56  & d     & 4/4   & Allegro \\
Op. 76, No. 4, i, mm. 1–68  & Bb    & 4/4   & Allegro con spirito \\
Op. 76, No. 5, ii, mm. 1–33  & F\#   & cut   & Largo. Cantabile e mesto \\
\bottomrule
\end{tabular*}%}
\label{tab:haydncorpus} 
\end{table}
\end{document}

答案1

我建议您使用longtable环境并让表格占据多页。对我来说,这种解决方案比减小表格使用的字体大小更可取。下面的代码显示了如何设置,longtable使其宽度等于文本块的宽度。

另外:该表包含大量形式为 、 和 的缩写Op.No.为了mm.通知 TeX 这些术语中的句号(句号)不是句末符号,您可以将紧跟在点后面的所有空格字符替换为~

结果表的前几行将如下所示:

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs,longtable}
\begin{document}
%%\listoftables

\setlength{\LTcapwidth}{\textwidth}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{}l@{\extracolsep{\fill}}lcl@{}}
\caption[Reference information for the Haydn Corpus]{Reference information (Opus number, work, movement, measures), keys, time signatures, and tempo markings for the exposition sections of each movement in the Haydn Corpus.} \label{tab:haydncorpus} \\
\toprule
\textit{Excerpts} & \textit{Key} & \textit{Time} & \textit{Tempo Marking} \\
& & \textit{Signature}\\
\midrule
\endfirsthead
\caption*{Table \ref{tab:haydncorpus}, continued}\\
\toprule
\textit{Excerpts} & \textit{Key} & \textit{Time} & \textit{Tempo Marking} \\
& & \textit{Signature}\\
\midrule
\endhead
\midrule
\multicolumn{4}{r@{}}{continued \dots}\\
\endfoot
\bottomrule
\endlastfoot
Op.~17, No.~1, i, mm.~1–43  & E     & 4/4   & Moderato \\
Op.~17, No.~2, i, mm.~1–38  & F     & 4/4   & Moderato \\
Op.~17, No.~3, iv, mm.~1–26 & E$\flat$    & 4/4   & Allegro molto \\
Op.~17, No.~4, i, mm.~1–53 & c     & 4/4   & Moderato \\
Op.~17, No.~5, i, mm.~1–33  & G     & 4/4   & Moderato \\
Op.~17, No.~6, i, mm.~1–73  & D     & 6/8   & Presto \\
Op.~20, No.~1, iv, mm.~1–55 & E$\flat$    & 2/4   & Presto \\
Op.~20, No.~3, i, mm.~1–94  & g     & 2/4   & Allegro con spirito \\
Op.~20, No.~3, iii, mm.~1–43  & G     & 3/4   & Poco Adagio \\
Op.~20, No.~3, iv, mm.~1–42  & g     & 4/4   & Allegro molto \\
Op.~20, No.~4, i, mm.~1–112  & D     & 3/4   & Allegro di molto \\
Op.~20, No.~4, iv, mm.~1–49   & D     & 4/4   & Presto scherzando \\
Op.~20, No.~5, i, mm.~1–48  & f     & 4/4   & Allegro moderato \\
Op.~20, No.~6, ii, mm.~1–27  & E     & cut   & Adagio \\
Op.~33, No.~1, i, mm.~1–37  & b     & 4/4   & Allegro moderato \\
Op.~33, No.~1, iii, mm.~1–40  & D     & 6/8   & Andante \\
Op.~33, No.~2, i, mm.~1–32  & E$\flat$    & 4/4   & Allegro moderato \\
Op.~33, No.~3, iii, mm.~1–29  & F     & 3/4   & Adagio \\
Op.~33, No.~4, i, mm.~1–31  & B$\flat$    & 4/4   & Allegro moderato \\
Op.~33, No.~5, i, mm.~1–95   & G     & 2/4   & Vivace assai \\
Op.~33, No.~5, ii, mm.~1–30  & g     & 4/4   & Largo \\
Op.~50, No.~1, i, mm.~1–60  & B$\flat$    & cut   & Allegro \\
Op.~50, No.~1, iv, mm.~1–75  & B$\flat$    & 2/4   & Vivace \\
Op.~50, No.~2, i, mm.~1–106  & C     & 3/4   & Vivace \\
Op.~50, No.~2, iv, mm.~1–86   & C     & 2/4   & Vivace assai \\
Op.~50, No.~3, iv, mm.~1–74  & E$\flat$    & 2/4   & Presto \\
Op.~50, No.~4, i, mm.~1–64  & f$\sharp$   & 3/4   & Allegro spirituoso \\
Op.~50, No.~5, i, mm.~1–65  & F     & 2/4   & Allegro moderato \\
Op.~50, No.~5, iv, mm.~1–54  & F     & 6/8   & Vivace \\
Op.~50, No.~6, i, mm.~1–54  & D     & 4/4   & Allegro \\
Op.~50, No.~6, ii, mm.~1–25  & d     & 6/8   & Poco Adagio \\
Op.~54, No.~1, i, mm.~1–47  & G     & 4/4   & Allegro con brio \\
Op.~54, No.~1, ii, mm.~1–54  & C     & 6/8   & Allegretto \\
Op.~54, No.~2, i, mm.~1–87  & C     & 4/4   & Vivace \\
Op.~54, No.~3, i, mm.~1–58  & E     & cut   & Allegro \\
Op.~54, No.~3, iv, mm.~1–82  & E     & 2/4   & Presto \\
Op.~55, No.~1, ii, mm.~1–36  & D     & 2/4   & Adagio cantabile \\
Op.~55, No.~2, ii, mm.~1–76  & f     & cut   & Allegro \\
Op.~55, No.~3, i, mm.~1–75  & B$\flat$    & 3/4   & Vivace assai \\
Op.~64, No.~3, i, mm.~1–69  & B$\flat$    & 3/4   & Vivace assai \\
Op.~64, No.~3, iv, mm.~1–79  & B$\flat$    & 2/4   & Allegro con spirito \\
Op.~64, No.~4, i, mm.~1–38   & G     & 4/4   & Allegro con brio \\
Op.~64, No.~4, iv, mm.~1–66  & G     & 6/8   & Presto \\
Op.~64, No.~6, i, mm.~1–45  & E$\flat$    & 4/4   & Allegretto \\
Op.~71, No.~1, i, mm.~1–69  & B$\flat$    & 4/4   & Allegro \\
Op.~74, No.~1, i, mm.~1–54  & C     & 4/4   & Allegro moderato \\
Op.~74, No.~1, ii, mm.~1–57  & G     & 3/8   & Andantino grazioso \\
Op.~76, No.~2, i, mm.~1–56  & d     & 4/4   & Allegro \\
Op.~76, No.~4, i, mm.~1–68  & B$\flat$    & 4/4   & Allegro con spirito \\
Op.~76, No.~5, ii, mm.~1–33  & F$\sharp$   & cut   & Largo. Cantabile e mesto \\
\end{longtable}

\end{document}

答案2

缩放文本会导致字体大小任意,最好使用类指定的字体,例如\footnotesize,根据使用的字体系列也可能使用该尺寸的字体设计,而不是简单的缩放版本。

如果它需要在一页上,就像这样,虽然多页表可能会更好。

就我个人而言,我只会使用tabular不强制它全宽tabular*,扩展列只会使跨表行阅读变得更加困难,但我tabular*在这里使用了(纠正缺少的序言@{})。

在此处输入图片描述

\documentclass{article}
\usepackage{array,booktabs}
\begin{document}

\begin{table}[tp]
\centering
\caption[Reference information for the Haydn Corpus]{Reference information (Opus number, work, movement, measures), keys, time signatures, and tempo markings for the exposition sections of each movement in the Haydn Corpus.}

\footnotesize
\begin{tabular*}{1.0\textwidth}{@{\extracolsep{\fill}} lccl@{}}
\toprule
\textit{Excerpts} & \textit{Key} & \textit{Time Signature} & \textit{Tempo Marking} \\
\midrule
Op. 17, No. 1, i, mm. 1–43  & E     & 4/4   & Moderato \\
Op. 17, No. 2, i, mm. 1–38  & F     & 4/4   & Moderato \\
Op. 17, No. 3, iv, mm. 1–26 & Eb    & 4/4   & Allegro molto \\
Op. 17, No. 4, i, mm. 1–53 & c     & 4/4   & Moderato \\
Op. 17, No. 5, i, mm. 1–33  & G     & 4/4   & Moderato \\
Op. 17, No. 6, i, mm. 1–73  & D     & 6/8   & Presto \\
Op. 20, No. 1, iv, mm. 1–55 & Eb    & 2/4   & Presto \\
Op. 20, No. 3, i, mm. 1–94  & g     & 2/4   & Allegro con spirito \\
Op. 20, No. 3, iii, mm. 1–43  & G     & 3/4   & Poco Adagio \\
Op. 20, No. 3, iv, mm. 1–42  & g     & 4/4   & Allegro molto \\
Op. 20, No. 4, i, mm. 1–112  & D     & 3/4   & Allegro di molto \\
Op. 20, No. 4, iv, mm. 1–49   & D     & 4/4   & Presto scherzando \\
Op. 20, No. 5, i, mm. 1–48  & f     & 4/4   & Allegro moderato \\
Op. 20, No. 6, ii, mm. 1–27  & E     & cut   & Adagio \\
Op. 33, No. 1, i, mm. 1–37  & b     & 4/4   & Allegro moderato \\
Op. 33, No. 1, iii, mm. 1–40  & D     & 6/8   & Andante \\
Op. 33, No. 2, i, mm. 1–32  & Eb    & 4/4   & Allegro moderato \\
Op. 33, No. 3, iii, mm. 1–29  & F     & 3/4   & Adagio \\
Op. 33, No. 4, i, mm. 1–31  & Bb    & 4/4   & Allegro moderato \\
Op. 33, No. 5, i, mm. 1–95   & G     & 2/4   & Vivace assai \\
Op. 33, No. 5, ii, mm. 1–30  & g     & 4/4   & Largo \\
Op. 50, No. 1, i, mm. 1–60  & Bb    & cut   & Allegro \\
Op. 50, No. 1, iv, mm. 1–75  & Bb    & 2/4   & Vivace \\
Op. 50, No. 2, i, mm. 1–106  & C     & 3/4   & Vivace \\
Op. 50, No. 2, iv, mm. 1–86   & C     & 2/4   & Vivace assai \\
Op. 50, No. 3, iv, mm. 1–74  & Eb    & 2/4   & Presto \\
Op. 50, No. 4, i, mm. 1–64  & f\#   & 3/4   & Allegro spirituoso \\
Op. 50, No. 5, i, mm. 1–65  & F     & 2/4   & Allegro moderato \\
Op. 50, No. 5, iv, mm. 1–54  & F     & 6/8   & Vivace \\
Op. 50, No. 6, i, mm. 1–54  & D     & 4/4   & Allegro \\
Op. 50, No. 6, ii, mm. 1–25  & d     & 6/8   & Poco Adagio \\
Op. 54, No. 1, i, mm. 1–47  & G     & 4/4   & Allegro con brio \\
Op. 54, No. 1, ii, mm. 1–54  & C     & 6/8   & Allegretto \\
Op. 54, No. 2, i, mm. 1–87  & C     & 4/4   & Vivace \\
Op. 54, No. 3, i, mm. 1–58  & E     & cut   & Allegro \\
Op. 54, No. 3, iv, mm. 1–82  & E     & 2/4   & Presto \\
Op. 55, No. 1, ii, mm. 1–36  & D     & 2/4   & Adagio cantabile \\
Op. 55, No. 2, ii, mm. 1–76  & f     & cut   & Allegro \\
Op. 55, No. 3, i, mm. 1–75  & Bb    & 3/4   & Vivace assai \\
Op. 64, No. 3, i, mm. 1–69  & Bb    & 3/4   & Vivace assai \\
Op. 64, No. 3, iv, mm. 1–79  & Bb    & 2/4   & Allegro con spirito \\
Op. 64, No. 4, i, mm. 1–38   & G     & 4/4   & Allegro con brio \\
Op. 64, No. 4, iv, mm. 1–66  & G     & 6/8   & Presto \\
Op. 64, No. 6, i, mm. 1–45  & Eb    & 4/4   & Allegretto \\
Op. 71, No. 1, i, mm. 1–69  & Bb    & 4/4   & Allegro \\
Op. 74, No. 1, i, mm. 1–54  & C     & 4/4   & Allegro moderato \\
Op. 74, No. 1, ii, mm. 1–57  & G     & 3/8   & Andantino grazioso \\
Op. 76, No. 2, i, mm. 1–56  & d     & 4/4   & Allegro \\
Op. 76, No. 4, i, mm. 1–68  & Bb    & 4/4   & Allegro con spirito \\
Op. 76, No. 5, ii, mm. 1–33  & F\#   & cut   & Largo. Cantabile e mesto \\
\bottomrule
\end{tabular*}
\label{tab:haydncorpus} 
\end{table}

\end{document}

问题已被编辑以显示12pt选项有效,在这种情况下需要采取更激烈的行动才能使其适合一页:

在此处输入图片描述

\documentclass [twoside,12pt,letterpaper]{report}
%LaTeX Warning: Float too large for page by 129.1507pt on input line 68.

\usepackage{array,booktabs}
\begin{document}

\begin{table}[tp]
\centering
\vspace{-55pt}
\small
\caption[Reference information for the Haydn Corpus]{Reference information (Opus number, work, movement, measures), keys, time signatures, and tempo markings for the exposition sections of each movement in the Haydn Corpus.}

\footnotesize\renewcommand\arraystretch{.9}
\begin{tabular*}{1.0\textwidth}{@{\extracolsep{\fill}} lccl@{}}
\toprule
\textit{Excerpts} & \textit{Key} & \textit{Time Signature} & \textit{Tempo Marking} \\
\midrule
Op. 17, No. 1, i, mm. 1–43  & E     & 4/4   & Moderato \\
Op. 17, No. 2, i, mm. 1–38  & F     & 4/4   & Moderato \\
Op. 17, No. 3, iv, mm. 1–26 & Eb    & 4/4   & Allegro molto \\
Op. 17, No. 4, i, mm. 1–53 & c     & 4/4   & Moderato \\
Op. 17, No. 5, i, mm. 1–33  & G     & 4/4   & Moderato \\
Op. 17, No. 6, i, mm. 1–73  & D     & 6/8   & Presto \\
Op. 20, No. 1, iv, mm. 1–55 & Eb    & 2/4   & Presto \\
Op. 20, No. 3, i, mm. 1–94  & g     & 2/4   & Allegro con spirito \\
Op. 20, No. 3, iii, mm. 1–43  & G     & 3/4   & Poco Adagio \\
Op. 20, No. 3, iv, mm. 1–42  & g     & 4/4   & Allegro molto \\
Op. 20, No. 4, i, mm. 1–112  & D     & 3/4   & Allegro di molto \\
Op. 20, No. 4, iv, mm. 1–49   & D     & 4/4   & Presto scherzando \\
Op. 20, No. 5, i, mm. 1–48  & f     & 4/4   & Allegro moderato \\
Op. 20, No. 6, ii, mm. 1–27  & E     & cut   & Adagio \\
Op. 33, No. 1, i, mm. 1–37  & b     & 4/4   & Allegro moderato \\
Op. 33, No. 1, iii, mm. 1–40  & D     & 6/8   & Andante \\
Op. 33, No. 2, i, mm. 1–32  & Eb    & 4/4   & Allegro moderato \\
Op. 33, No. 3, iii, mm. 1–29  & F     & 3/4   & Adagio \\
Op. 33, No. 4, i, mm. 1–31  & Bb    & 4/4   & Allegro moderato \\
Op. 33, No. 5, i, mm. 1–95   & G     & 2/4   & Vivace assai \\
Op. 33, No. 5, ii, mm. 1–30  & g     & 4/4   & Largo \\
Op. 50, No. 1, i, mm. 1–60  & Bb    & cut   & Allegro \\
Op. 50, No. 1, iv, mm. 1–75  & Bb    & 2/4   & Vivace \\
Op. 50, No. 2, i, mm. 1–106  & C     & 3/4   & Vivace \\
Op. 50, No. 2, iv, mm. 1–86   & C     & 2/4   & Vivace assai \\
Op. 50, No. 3, iv, mm. 1–74  & Eb    & 2/4   & Presto \\
Op. 50, No. 4, i, mm. 1–64  & f\#   & 3/4   & Allegro spirituoso \\
Op. 50, No. 5, i, mm. 1–65  & F     & 2/4   & Allegro moderato \\
Op. 50, No. 5, iv, mm. 1–54  & F     & 6/8   & Vivace \\
Op. 50, No. 6, i, mm. 1–54  & D     & 4/4   & Allegro \\
Op. 50, No. 6, ii, mm. 1–25  & d     & 6/8   & Poco Adagio \\
Op. 54, No. 1, i, mm. 1–47  & G     & 4/4   & Allegro con brio \\
Op. 54, No. 1, ii, mm. 1–54  & C     & 6/8   & Allegretto \\
Op. 54, No. 2, i, mm. 1–87  & C     & 4/4   & Vivace \\
Op. 54, No. 3, i, mm. 1–58  & E     & cut   & Allegro \\
Op. 54, No. 3, iv, mm. 1–82  & E     & 2/4   & Presto \\
Op. 55, No. 1, ii, mm. 1–36  & D     & 2/4   & Adagio cantabile \\
Op. 55, No. 2, ii, mm. 1–76  & f     & cut   & Allegro \\
Op. 55, No. 3, i, mm. 1–75  & Bb    & 3/4   & Vivace assai \\
Op. 64, No. 3, i, mm. 1–69  & Bb    & 3/4   & Vivace assai \\
Op. 64, No. 3, iv, mm. 1–79  & Bb    & 2/4   & Allegro con spirito \\
Op. 64, No. 4, i, mm. 1–38   & G     & 4/4   & Allegro con brio \\
Op. 64, No. 4, iv, mm. 1–66  & G     & 6/8   & Presto \\
Op. 64, No. 6, i, mm. 1–45  & Eb    & 4/4   & Allegretto \\
Op. 71, No. 1, i, mm. 1–69  & Bb    & 4/4   & Allegro \\
Op. 74, No. 1, i, mm. 1–54  & C     & 4/4   & Allegro moderato \\
Op. 74, No. 1, ii, mm. 1–57  & G     & 3/8   & Andantino grazioso \\
Op. 76, No. 2, i, mm. 1–56  & d     & 4/4   & Allegro \\
Op. 76, No. 4, i, mm. 1–68  & Bb    & 4/4   & Allegro con spirito \\
Op. 76, No. 5, ii, mm. 1–33  & F\#   & cut   & Largo. Cantabile e mesto \\
\bottomrule
\end{tabular*}
\label{tab:haydncorpus} 
\vspace{-20pt}
\end{table}

\end{document}

相关内容