如何增加字体大小和改变表格列宽?

如何增加字体大小和改变表格列宽?

我希望表格只适合页面的列。为此,我使用了 resizebox:

\begin{table}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{Sample table}
\label{table_example}
\centering
\resizebox{\columnwidth}{!}{%
\begin{tabular}{|c|c|c|}
\hline
Sr & Hypothesis & Result \\
\hline\hline
1 & May indulgence difficulty ham can put especially. Bringing remember & Proved \\
\hline
2 & Manor we shall merit by chief wound no or would. Oh towards between & Proved \\
\hline
3 & Style never met and those among great. At no or september sportsmen & Level1 Proved, Level2 Not Proved \\
\hline
4 & Cottage out enabled was entered greatly prevent message. No procured unlocked an likewise. & Level1 Proved, Level2 Not Proved \\
\hline
\end{tabular}
}
\end{table}

这给了我以下输出:

在此处输入图片描述

表格内容的字体变小了?如何增大字体大小?

另外,我想在增加字体大小后增加第二列的大小并减小第三列的大小。我该怎么做?

答案1

您的表格比页面宽度宽。因此,您尝试将其适合列宽,同时\resizebox减小字体大小...唯一合理的解决方案是重新设计表格,将单元格中的文本分成更多的行,并使用字体大小\small以便表格更好地适合单元格中的文本:

在此处输入图片描述

\documentclass[twocolumn]{article}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
    \begin{table}[htb]
\renewcommand{\arraystretch}{1.3}
\setlength\tabcolsep{4pt}
\caption{Sample table}
    \label{table_example}
\centering
\small
%\resizebox{\columnwidth}{!}{%
\begin{tabularx}{\linewidth}{|c|>{\hsize=1.2\hsize}L
                               |>{\hsize=0.8\hsize}L|}
\hline
Sr & Hypothesis & Result \\
\hline\hline
1 & May indulgence difficulty ham can put especially. Bringing remember & Proved \\
\hline
2 & Manor we shall merit by chief wound no or would. Oh towards between & Proved \\
\hline
3 & Style never met and those among great. At no or september sportsmen & Level1 Proved, Level2 Not Proved \\
\hline
4 & Cottage out enabled was entered greatly prevent message. No procured unlocked an likewise. & Level1 Proved, Level2 Not Proved \\
\hline
\end{tabularx}
%}
\end{table}
\lipsum
\end{document}

在上面姆韦用于表格环境,您已为其规定了表格宽度。对于列,通过包中的宏tabularx定义新的列类型。这样,单元格中的多行文本格式比居中更好(根据我的口味)。列宽比也发生了变化。如果您希望表格中的字体大小与文本中的字体大小相同,只需删除。,但表格会不那么好看(再次符合我的口味)。L\RaggedRightragged2e\small

答案2

要打印适合列宽且包含与周围文本大小合理的文本的表格,您可以tabu像下面的 MWE 中一样使用包。

\documentclass[twocolumn]{scrreprt}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{tabu}

\begin{document}

\lipsum
\lipsum

\begin{table}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{Sample table}
\label{table_example}
\centering
\tabulinesep=1.2mm
\begin{tabu} to \columnwidth{|c|X[c]|X[0.5c]|}
\hline
Sr & Hypothesis & Result \\
\hline\hline
1 & May indulgence difficulty ham can put especially. Bringing remember & Proved \\
\hline
2 & Manor we shall merit by chief wound no or would. Oh towards between & Proved \\
\hline
3 & Style never met and those among great. At no or september sportsmen & Level1 Proved, Level2 Not Proved \\
\hline
4 & Cottage out enabled was entered greatly prevent message. No procured unlocked an likewise. & Level1 Proved, Level2 Not Proved \\
\hline
\end{tabu}
\end{table}

\end{document}

在此处输入图片描述

相关内容