使用 \resizebox{\textwidth}{!} 时调整 Latex 表中的字体大小

使用 \resizebox{\textwidth}{!} 时调整 Latex 表中的字体大小

我正在尝试增加此 Latex 表格中文本的字体大小,以使其更易于阅读,同时使用 \resizebox 使其适合页面。我该怎么做?

以下是我已经尝试过的方法:

\documentclass[english]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{graphicx}
\usepackage{babel}
\usepackage[margin=.65in, includefoot]{geometry}
\usepackage{titlesec}
\usepackage{multirow}



\begin{document}

\begin{table}[ht]
\centering
\resizebox{\textwidth}{!}{\begin{tabular}{cccccccccc}
  \hline
TX DG Customers & March 2019 & March 2018 & \% Change & March 2019 YTD & March 2018 YTD & \% Change & March 2019 Cumulative & March 2018 Cumulative & \% Change\\
\hline
\multicolumn{1}{l}{Number of Applications}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{New Applications Capacity, kW}       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Installed Capacity, kW}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Number of Meters Installed}          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\hline
\end{tabular}}


\centering
\resizebox{\textwidth}{!}{\begin{tabular}{cccccccccc}
NM DG Customers & March 2019 & March 2018 & \% Change & March 2019 YTD & March 2018 YTD & \% Change & March 2019 Cumulative & March 2018 Cumulative & \% Change\\
\hline
\multicolumn{1}{l}{Number of Applications}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{New Applications Capacity, kW}       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Installed Capacity, kW}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Number of Meters Installed}          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\hline
\end{tabular}}

\centering
\resizebox{\textwidth}{!}{\begin{tabular}{cccccccccc}
TX \& NM DG Customers & March 2019 & March 2018 & \% Change & March 2019 YTD & March 2018 YTD & \% Change & March 2019 Cumulative & March 2018 Cumulative & \% Change\\
\hline
\multicolumn{1}{l}{Total Number of Applications}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{total New Applications Capacity, kW}       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Total Installed Capacity, kW}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Total Number of Meters Installed}          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\hline
\end{tabular}}

\end{table}

\end{document}

答案1

您的标题太长,但可以通过分组轻松缩短它们。

您不应该使用三个单独的表格,而应该使用一个表格,其中的各个部分都有一个标题,我建议使用斜体并稍微向左缩进。

由于表格很大,使用tabular*TeX 来计算列间宽度是有意义的。

\documentclass[english]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{graphicx}
\usepackage{babel}
\usepackage[margin=.65in, includefoot]{geometry}
\usepackage{titlesec}
\usepackage{booktabs}



\begin{document}

\begin{table}[htp]
\centering

\setlength{\tabcolsep}{0pt} % let TeX compute the intercolumn space

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}\quad}lccccccccc}
\toprule
& \multicolumn{3}{c}{March}
& \multicolumn{3}{c}{March, YTD}
& \multicolumn{3}{c}{March, Cumulative} \\
\cmidrule{2-4}\cmidrule{5-7}\cmidrule{8-10}
& 2019 & 2018 & \% Change & 2019 & 2018 & \% Change & 2019 & 2018 & \% Change \\
\midrule
\multicolumn{1}{l}{\itshape TX DG Customers} \\
Number of Applications              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
New Applications Capacity, kW       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Installed Capacity, kW              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Number of Meters Installed          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\midrule
\multicolumn{1}{l}{\itshape NM DG Customers} \\
Number of Applications              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
New Applications Capacity, kW       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Installed Capacity, kW              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Number of Meters Installed          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\midrule
\multicolumn{1}{l}{\itshape TX \& NM DG Customers} \\
Total Number of Applications        & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Total New Applications Capacity, kW & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Total Installed Capacity, kW        & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
Total Number of Meters Installed    & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

在此处输入图片描述

答案2

我建议使用以下代码,这样可以免去您调整框大小的麻烦。它基于tabularx, makecellbooktabs使用small字体大小:

\documentclass[english]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{graphicx}
\usepackage{babel}
\usepackage[margin=.65in, includefoot, showframe]{geometry}
\usepackage{titlesec}
\usepackage{multirow, makecell, tabularx, booktabs}

\begin{document}

\begin{table}[ht]
\centering
\small
\setlength{\tabcolsep}{3pt}
\renewcommand{\cellset}{\renewcommand\arraystretch{0.3}}
\renewcommand{\cellalign}{bc}
\setcellgapes{2pt}\makegapedcells
\begin{tabularx}{\linewidth}{@{}X*{9}{c}@{}}
  \toprule
\centering TX DG Customers & \makecell[b]{\\ March 2019} & \makecell{\\ March 2018} &\makecell{ \%\\ Change} & \makecell{March 2019\\ YTD} & \makecell{March 2018\\ YTD}& \makecell{\%\\ Change} & \makecell{March 2019\\ Cumulative} & \makecell{March 2018\\ Cumulative} & \makecell{\%\\ Change}\\
\midrule
Number of Applications & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
New Applications Capacity, kW & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
Installed Capacity, kW & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
Number of Meters Installed & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
\bottomrule\addlinespace[3ex]
\centering NM DG Customers & \makecell{\\ March 2019} & \makecell{\\ March 2018} &\makecell{ \%\\ Change} & \makecell{March 2019\\ YTD} & \makecell{March 2018\\ YTD}& \makecell{\%\\ Change} & \makecell{March 2019\\ Cumulative} & \makecell{March 2018\\ Cumulative} & \makecell{\%\\ Change}\\
\midrule
Number of Applications & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
New Applications Capacity, kW & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
Installed Capacity, kW & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
Number of Meters Installed & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
\bottomrule\addlinespace[3ex]
\centering TX \& NM DG Customers & \makecell{\\ March 2019} & \makecell{\\ March 2018} &\makecell{ \%\\ Change} & \makecell{March 2019\\ YTD} & \makecell{March 2018\\ YTD}& \makecell{\%\\ Change} & \makecell{March 2019\\ Cumulative} & \makecell{March 2018\\ Cumulative} & \makecell{\%\\ Change}\\
\midrule
Total Number of Applications & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
total New Applications Capacity, kW & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
Total Installed Capacity, kW & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
Total Number of Meters Installed & 6 & 4 & 0 & 2 & 6 & 4 & 0 & 2 & 2 \\
\bottomrule
\end{tabularx}

\end{table}

\end{document} 

在此处输入图片描述

答案3

永远不要将其应用于\resizebox表格,因为您会发现它总是产生与文档其余部分不一致的字体大小。

也许是类似

在此处输入图片描述

\documentclass[english]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{graphicx}
\usepackage{babel}
\usepackage[margin=.65in, includefoot]{geometry}
\usepackage{titlesec}
\usepackage{multirow}
\usepackage{booktabs}



\begin{document}

\begin{table}[ht]
\centering
\begin{tabular}{cccccccccc}
  \toprule
 & \multicolumn{3}{c}{March}& \multicolumn{3}{c}{March YTD}&\multicolumn{3}{c}{March Cumulative}\\
 & 2019 & 2018 & \% Change & 2019 & 2018 & \% Change & 2019  & 2018 & \% Change\\
\cmidrule(rl){2-4}\cmidrule(rl){5-7}\cmidrule(rl){8-10}
TX DG Customers\\
\midrule
\multicolumn{1}{l}{Number of Applications}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{New Applications Capacity, kW}       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Installed Capacity, kW}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Number of Meters Installed}          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\midrule
NM DG Customers\\
\midrule
\multicolumn{1}{l}{Number of Applications}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{New Applications Capacity, kW}       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Installed Capacity, kW}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Number of Meters Installed}          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\midrule
TX \& NM DG Customers \\
\midrule
\multicolumn{1}{l}{Total Number of Applications}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Total New Applications Capacity, kW}       & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Total Installed Capacity, kW}              & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\multicolumn{1}{l}{Total Number of Meters Installed}          & 6 & 4 & 0 & 2  & 6 & 4 & 0 & 2 & 2 \\
\bottomrule
\end{tabular}

\end{table}

\noindent X\dotfill page width\dotfill X

\end{document}

相关内容