[Tex/LaTex] Fit table to textwidth AND textheight

adjustboxtables

The table below was too long to fit the textheight and not wide enough to fit the textwidth. I would prefer the height of the table to conform to the height specified by the commented-out line '\resizebox*{!}{\dimexpr\textheight-4\baselineskip\relax}{%'. However, if I include the line, the table no longer stretches to fit the textwidth (see the line directly below). Any suggestions?

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

Best Answer

I would like to suggest that you use a longtable environment and let the table occupy more than one page. To me, such a solution is preferable to one that reduces the font size used for the table. The code below shows how one may set up a longtable so that its width equals that of the text block.

Aside: The table contains a lot of abbreviations of the form Op., No., and mm.. To inform TeX that the periods (full stops) in these terms are not of the sentence-ending variety, you could replace all space characters that immediately follow the dots with ~.

The first few lines of the resulting table will look like this:

enter image description here

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