简体   繁体   English

表格的字体太小了 Latex

[英]The font size of tables is way too small in Latex

I am generating tables in latex. But the text's font is way too small compared to the main text size, which is 12 pt.我在 latex 中生成表格。但是与 12 pt 的主要文本大小相比,文本的字体太小了。 Here is the Latex code这是 Latex 代码

\begin{table}[htp]
\renewcommand{\arraystretch}{2}
\large
\resizebox{1\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\textbf{Air pollutant}    & \textbf{Detection limit} & \textbf{Concentration range to expect 
by EPA} & \textbf{Concentration  range in Bristol, UK} & \textbf{Range in Bristol, UK} \\[3ex] 
\hline
 \textbf{Ozone (O$_{3}$) }       & \textbf{10 ppb}          & \textbf{0--150 ppb }                           
&       \textbf{0--100 ppb}                              &                      \\[3ex] \hline
\textbf{Nitrogen dioxide}  & \textbf{10 ppb}          & \textbf{0--50 ppb}                             
& \textbf{20--55  ppb}                              &                      \\[3ex] \hline
\textbf{PM$_{2.5}$}            & \textbf{5 }              & \textbf{0--40 \SI{} 
 {\micro\gram/m^3}}                            & \textbf{0--40    \SI{}{\micro\gram/m^3}  }                         
 &                      \\[3ex] \hline
 \textbf{PM$_{10}$}              & \textbf{10}              & \textbf{0--100   \SI{} 
 {\micro\gram/m^3} }                            & \textbf{0--100  \SI{}{\micro\gram/m^3}}                             
  &                      \\[3ex] \hline
 \textbf{Temperature  range} & -----           & ------                               & ---- 
      --                              & \textbf{3--$ 21 ^\circ C $}                 \\[3ex] 
 \hline
 \textbf{Humidity }         & -----           & -----                                & ----- 
    --                             & \textbf{50\%--75\% }               \\[3ex] \hline
 \end{tabular}%
 }
 \end{table}

and here is a screenshot of part of PDF to compare the main text and table font这是 PDF 的一部分的屏幕截图,用于比较主要文本和表格字体

在此处输入图像描述

I have this issue for several tables, so any help would be greatly appreciated.我有几个表有这个问题,所以任何帮助将不胜感激。

You should never use \resizebox for elements which contain text.永远不要对包含文本的元素使用\resizebox

Instead you could save some space by using multiple lines for your header cells and restructure your table a bit:相反,您可以通过为 header 单元格使用多行来节省一些空间,并稍微重组您的表格:

\documentclass[12pt]{article}
\usepackage[text-series-to-math=true]{siunitx}
\usepackage{tabularray}
\usepackage{geometry}
\begin{document}

\begin{table}[htp]
\caption{... The temperature range in Bristol, UK was 3--\SI{21}{\degree C} and the humidity 50\%--75\% during the measurement.}
\begin{tblr}{
 colspec={XXXXX},
 columns={halign=c,valign=m},
 row{1}={font=\bfseries},
 column{1}={font=\bfseries},
 stretch=0, 
 rows={ht=2\baselineskip},
 hlines,
 vlines
}
Air pollutant & Detection limit & Concentration range to expect 
by EPA & Concentration range in Bristol, UK \\
Ozone (O\textsubscript{3}) & 10 ppb & 0--150 ppb & 0--100 ppb  \\
Nitrogen dioxide & 10 ppb & 0--50 ppb & 20--55 ppb  \\
PM\textsubscript{2.5} & 5 & 0--40 \SI{}{\micro\gram/m^3} & 0--40 \SI{}{\micro\gram/m^3}  \\
PM\textsubscript{10} & 10 & 0--100 \SI{}{\micro\gram/m^3}  & 0--100 \SI{}{\micro\gram/m^3}  \\
\end{tblr}%
\end{table}

\end{document}

在此处输入图像描述

Can I suggest a few things?我可以提出一些建议吗?

You should avoid long headings with narrow content like numbers, unless cells contain long paragraphs, as well.您应该避免使用数字等窄内容的长标题,除非单元格也包含长段落。 Find the way to shorten the headings, eg by adding line breaks.找到缩短标题的方法,例如通过添加换行符。

Repeated content can be grouped and move to separate cells, which can also help with excessive widths.重复的内容可以分组并移动到单独的单元格中,这也有助于解决宽度过大的问题。

As you load siunitx , I would recommend to use \qtyrange{}{}{} .当你加载siunitx时,我建议使用\qtyrange{}{}{} Typing them takes the same space and time but in case you need to make changes eg you have to change a range marker from -- to to you will appreciate to only have to do it in one place via siunitx .键入它们需要相同的空间和时间,但如果您需要进行更改,例如您必须将范围标记从--更改为to您将很高兴只需通过siunitx在一个地方进行。 If you repeat long units, it is also possible to define your own units, for the same reason to make changes in one place.如果你重复很长的单位,也可以定义你自己的单位,出于同样的原因在一个地方进行更改。 I think \SI{}{} is deprecated and should be changed to qty{}{} , although I am not entirely sure about it.我认为\SI{}{}已被弃用,应更改为qty{}{} ,尽管我对此并不完全确定。

This is my personal taste but IMO tables can look much better without vertical bars.这是我个人的品味,但没有垂直条的 IMO 表格看起来会好得多。 I also added booktabs for improved horizontal rules.我还添加了booktabs以改进水平规则。

Here's a different version of your table这是你的桌子的不同版本

在此处输入图像描述

and the code和代码

\documentclass{article}
\usepackage{array}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{rotating}
\usepackage{booktabs}

\sisetup{
  range-units=single,
  range-phrase={\,--\,},
}
\DeclareSIUnit\ppb{ppb}
\newcommand\nullval{---}

\renewcommand\theadfont{\normalfont\bfseries}
\renewcommand\theadgape{\Gape[0pt][0pt]}


\begin{document}
\begin{sidewaystable}
  \renewcommand\arraystretch{1.2}
  \caption{Caption of the table}
  \label{tab:table}
  \centering
  \begin{tabular}{
      wc{4cm}
      wc{2cm} @{\hspace{1em}}
      *3{wc{3cm}}
      wc{2cm}
    }
    \toprule
    \multirow{3}*{\thead*{Air\\pollutant}}
    & \multirow{3}*{\thead{Detection\\limit}}
    & \multicolumn{2}{c}{\thead{Concentration range:}}
    & \multirow{3}*{\thead{Range\\in Bristol, UK}} \\
    \cmidrule(lr){3-4}
    & & \thead{to expect\\by EPA} & \thead{in Bristol\\UK} &  \\
    \midrule
    \thead{Ozone (O\textsubscript{3})}
    & \qty{10}{\ppb} & \qtyrange{0}{150}{\ppb}    & \qtyrange{0}{100}{\ppb}    & \nullval \\
    \thead{Nitrogen dioxide}
    & \qty{10}{\ppb} & \qtyrange{0}{50}{\ppb}     & \qtyrange{20}{55}{\ppb}    & \nullval \\
    \thead{PM\textsubscript{2.5}}
    &  5             & \qtyrange{0}{40}{\mg/m^3}  & \qtyrange{0}{40}{\ug/m^3}  & \nullval \\
    \thead{PM\textsubscript{10}}
    & 10             & \qtyrange{0}{100}{\ug/m^3} & \qtyrange{0}{100}{\ug/m^3} & \nullval \\
    \thead{Temperature range}
    & \nullval       & \nullval                   & \nullval                   & \qtyrange{3}{21}{\degreeCelsius} \\
    \thead{Humidity}
    & \nullval       & \nullval                   & \nullval                   & \qtyrange{50}{75}{\%} \\
    \bottomrule
  \end{tabular}
\end{sidewaystable}
\end{document}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM