1

I have the following MWE, which has a longtable (shown only part for clarity). I want to change the font size while preserving the caption size. MWE 1 changes the font and caption size as shown in figure. To change table entry font size I tried MWE 2, which gives error and doesn't work as expected. How to change the table entry font size without affecting the caption size?

enter image description here

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

MWE 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
  • 1
    Actually, just loading the caption package will fix the problem. No setup needed. Commented Sep 19, 2017 at 12:49

2 Answers 2

1
  • to have size of caption font independent from size of font used in table use package caption (as suggest John Kormylo in his coment)
  • for fit table into text width is sufficient to reduce \tabcolsep accordingly and if you liked decrease font size in table use \small for doing this

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

enter image description here

  • probably is worth consider of use chemical symbols (and with this make columns narrower)

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

enter image description here

0

Well, for defining the captions of tables and figures, it is quite common to use the caption package. There, you can set properly your caption definitions via \captionsetup.

\usepackage{caption}[2016/02/21] 

\captionsetup{
labelsep=period,    %Sets a point
%format=hang,       
labelfont=bf,
textfont=bf,
font=large          %Large font for example
}

Edit: If you are trying to fit the table to your page, you don't have to find an appropiate font size. You can use \resizebox width your actual page size. For example:

\begin{table}[htb]
\center
  \caption{My Table Caption}
  \label{tab:NewTable}
  \resizebox{\pagewidth}{!}{%
  \input{ExternTable}
  }
\end{table}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .