我有以下 MWE,它有一个长表(为清楚起见,仅显示一部分)。我想更改字体大小,同时保留标题大小。MWE 1 会更改字体和标题大小,如图所示。为了更改表格条目字体大小,我尝试了 MWE 2,但它会出错,无法按预期工作。如何在不影响标题大小的情况下更改表格条目字体大小?
微波能量吸收 1
\documentclass[a4paper,twoside,12pt]{report}
\usepackage{threeparttablex}
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\begin{ThreePartTable}
{\fontsize{7pt}{7pt}
\selectfont
\centering
\begin{longtable}{lccccccccc}
\caption{Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction} & \multicolumn{3}{c}{Mole fraction} & HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule(l{2pt}r{2pt}){2-4} \cmidrule(l{2pt}r{2pt}){5-7}
& Carbon & Hydrogen & Oxygen & Carbon & Hydrogen & Oxygen \\
\toprule
\endfirsthead
\caption{(continued) Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction} & \multicolumn{3}{c}{Mole fraction} & HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule(l{2pt}r{2pt}){2-4} \cmidrule(l{2pt}r{2pt}){5-7}
& Carbon & Hydrogen & Oxygen & Carbon & Hydrogen & Oxygen \\
\toprule
\endhead
\bottomrule
\endlastfoot
Coal 1 & 0.050 & 0.050 & 0.900 & 0.068 & 0.044 & 0.888 & 10.9 & 11.0 \\
Coal 2 & 0.050 & 0.100 & 0.850 & 0.068 & 0.088 & 0.844 & 11.9 & 13.9 \\
Coal 3 & 0.050 & 0.150 & 0.800 & 0.069 & 0.133 & 0.799 & 22.8 & 15.9 \\
Coal 4 & 0.050 & 0.200 & 0.750 & 0.069 & 0.178 & 0.753 & 23.8 & 27.9 \\
Coal 5 & 0.050 & 0.250 & 0.700 & 0.069 & 0.224 & 0.707 & 34.8 & 29.8 \\
Coal 6 & 0.050 & 0.300 & 0.650 & 0.070 & 0.270 & 0.660 & 35.7 & 31.7 \\
Coal 7 & 0.050 & 0.350 & 0.600 & 0.070 & 0.317 & 0.613 & 46.6 & 33.7 \\
Coal 8 & 0.050 & 0.400 & 0.550 & 0.071 & 0.365 & 0.565 & 47.6 & 45.6
\label{tab:sm_coal_sample_matrix}
\end{longtable}}
\begin{tablenotes}
\item[1]{Obtained from XYZ}
\end{tablenotes}
\end{ThreePartTable}
\end{document}
微波辐射计 2
\documentclass[a4paper,twoside,12pt]{report}
\usepackage{threeparttablex}
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\begin{ThreePartTable}
\centering
\begin{longtable}{lccccccccc}
\caption{Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction} & \multicolumn{3}{c}{Mole fraction} & HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule(l{2pt}r{2pt}){2-4} \cmidrule(l{2pt}r{2pt}){5-7}
& Carbon & Hydrogen & Oxygen & Carbon & Hydrogen & Oxygen \\
\toprule
\endfirsthead
\caption{(continued) Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction} & \multicolumn{3}{c}{Mole fraction} & HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule(l{2pt}r{2pt}){2-4} \cmidrule(l{2pt}r{2pt}){5-7}
& Carbon & Hydrogen & Oxygen & Carbon & Hydrogen & Oxygen \\
\toprule
\endhead
\bottomrule
\endlastfoot
{\fontsize{7pt}{7pt}
\selectfont
Coal 1 & 0.050 & 0.050 & 0.900 & 0.068 & 0.044 & 0.888 & 10.9 & 11.0 \\
Coal 2 & 0.050 & 0.100 & 0.850 & 0.068 & 0.088 & 0.844 & 11.9 & 13.9 \\
Coal 3 & 0.050 & 0.150 & 0.800 & 0.069 & 0.133 & 0.799 & 22.8 & 15.9 \\
Coal 4 & 0.050 & 0.200 & 0.750 & 0.069 & 0.178 & 0.753 & 23.8 & 27.9 \\
Coal 5 & 0.050 & 0.250 & 0.700 & 0.069 & 0.224 & 0.707 & 34.8 & 29.8 \\
Coal 6 & 0.050 & 0.300 & 0.650 & 0.070 & 0.270 & 0.660 & 35.7 & 31.7 \\
Coal 7 & 0.050 & 0.350 & 0.600 & 0.070 & 0.317 & 0.613 & 46.6 & 33.7 \\
Coal 8 & 0.050 & 0.400 & 0.550 & 0.071 & 0.365 & 0.565 & 47.6 & 45.6}
\label{tab:sm_coal_sample_matrix}
\end{longtable}}
\begin{tablenotes}
\item[1]{Obtained from XYZ}
\end{tablenotes}
\end{ThreePartTable}
\end{document}
答案1
- 要使标题字体的大小与表格中使用的字体大小无关,请使用包
caption
(如建议的那样约翰·科米洛在他的评论中) - 为了使表格适合文本宽度,可以
\tabcolsep
相应减少,如果您喜欢减小表格中的字体大小,\small
可以这样做
\documentclass[a4paper,twoside,12pt]{report}
\usepackage{booktabs, longtable, threeparttablex}
\usepackage[skip=1ex]{caption}% font=footnotesize
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{ThreePartTable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{0pt}
\small
\begin{longtable}{@{\ \extracolsep{\fill}} lccccccccc}
\caption{Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction}
& \multicolumn{3}{c}{Mole fraction}
& HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule{2-4} \cmidrule{5-7}
& Carbon & Hydrogen & Oxygen & Carbon & Hydrogen & Oxygen \\
\midrule[\heavyrulewidth]
\endfirsthead
%
\caption{(continued) Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction}
& \multicolumn{3}{c}{Mole fraction}
& HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule{2-4} \cmidrule{5-7}
& Carbon & Hydrogen & Oxygen & Carbon & Hydrogen & Oxygen \\
\midrule[\heavyrulewidth]
\endhead
%
\bottomrule
\endlastfoot
%
Coal 1 & 0.050 & 0.050 & 0.900 & 0.068 & 0.044 & 0.888 & 10.9 & 11.0 \\
Coal 2 & 0.050 & 0.100 & 0.850 & 0.068 & 0.088 & 0.844 & 11.9 & 13.9 \\
Coal 3 & 0.050 & 0.150 & 0.800 & 0.069 & 0.133 & 0.799 & 22.8 & 15.9 \\
Coal 4 & 0.050 & 0.200 & 0.750 & 0.069 & 0.178 & 0.753 & 23.8 & 27.9 \\
Coal 5 & 0.050 & 0.250 & 0.700 & 0.069 & 0.224 & 0.707 & 34.8 & 29.8 \\
Coal 6 & 0.050 & 0.300 & 0.650 & 0.070 & 0.270 & 0.660 & 35.7 & 31.7 \\
Coal 7 & 0.050 & 0.350 & 0.600 & 0.070 & 0.317 & 0.613 & 46.6 & 33.7 \\
Coal 8 & 0.050 & 0.400 & 0.550 & 0.071 & 0.365 & 0.565 & 47.6 & 45.6
\label{tab:sm_coal_sample_matrix}
\end{longtable}\vspace{-\baselineskip}
\begin{tablenotes}\footnotesize
\item[1] Obtained from XYZ
\end{tablenotes}
\end{ThreePartTable}
\end{document}
- 可能值得考虑使用化学符号(并使列变窄)
\documentclass[a4paper,twoside,12pt]{report}
\usepackage{booktabs, longtable, threeparttablex}
\usepackage[skip=1ex]{caption}% font=footnotesize
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{ThreePartTable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\hspace{\tabcolsep}\extracolsep{\fill}} l
cccc ccc cc}
\caption{Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction}
& \multicolumn{3}{c}{Mole fraction}
& HHV\tnote{a} & LHV\tnote{a} \\
\cmidrule{2-4} \cmidrule{5-7}
& C\tnote{b} & H\tnote{c} & O\tnote{d} & C\tnote{b} & H\tnote{c} & O\tnote{d} \\
\midrule[\heavyrulewidth]
\endfirsthead
%
\caption{(continued) Sample matrix of coal} \\
\toprule
Sample & \multicolumn{3}{c}{Volume fraction}
& \multicolumn{3}{c}{Mole fraction}
& HHV\tnote{1} & LHV\tnote{1} \\
\cmidrule{2-4} \cmidrule{5-7}
& C\tnote{b} & H\tnote{c} & O\tnote{d} & C\tnote{b} & H\tnote{c} & O\tnote{d} \\
\midrule[\heavyrulewidth]
\endhead
%
\bottomrule
\endlastfoot
%
Coal 1 & 0.050 & 0.050 & 0.900 & 0.068 & 0.044 & 0.888 & 10.9 & 11.0 \\
Coal 2 & 0.050 & 0.100 & 0.850 & 0.068 & 0.088 & 0.844 & 11.9 & 13.9 \\
Coal 3 & 0.050 & 0.150 & 0.800 & 0.069 & 0.133 & 0.799 & 22.8 & 15.9 \\
Coal 4 & 0.050 & 0.200 & 0.750 & 0.069 & 0.178 & 0.753 & 23.8 & 27.9 \\
Coal 5 & 0.050 & 0.250 & 0.700 & 0.069 & 0.224 & 0.707 & 34.8 & 29.8 \\
Coal 6 & 0.050 & 0.300 & 0.650 & 0.070 & 0.270 & 0.660 & 35.7 & 31.7 \\
Coal 7 & 0.050 & 0.350 & 0.600 & 0.070 & 0.317 & 0.613 & 46.6 & 33.7 \\
Coal 8 & 0.050 & 0.400 & 0.550 & 0.071 & 0.365 & 0.565 & 47.6 & 45.6
\label{tab:sm_coal_sample_matrix}
\end{longtable}\vspace{-\baselineskip}
\begin{tablenotes}[para]\footnotesize
\item[a] Obtained from XYZ
\item[b] C: Carbon
\item[c] H: Hydrogen
\item[d] O: Oxygen
\end{tablenotes}
\end{ThreePartTable}
\end{document}
答案2
好吧,对于定义表格和图形的标题,使用 caption 包是很常见的。在那里,您可以通过 \captionsetup 正确设置标题定义。
\usepackage{caption}[2016/02/21]
\captionsetup{
labelsep=period, %Sets a point
%format=hang,
labelfont=bf,
textfont=bf,
font=large %Large font for example
}
编辑:如果您尝试将表格调整到页面大小,则不必寻找合适的字体大小。您可以使用 \resizebox width 调整实际页面大小。例如:
\begin{table}[htb]
\center
\caption{My Table Caption}
\label{tab:NewTable}
\resizebox{\pagewidth}{!}{%
\input{ExternTable}
}
\end{table}