我怎样才能统一这两个表格的大小和字体大小
\documentclass{article}
\usepackage{graphicx}
\begin{document}
% Table 1
\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|}
\hline
\multicolumn{1}{|c|}{\textbf{Day}} & \multicolumn{1}{c|}{\textbf{Summary}} \\ \hline
\textbf{Monday} & \textbf{\begin{tabular}[c]{@{}l@{}}A clear day with lots of sunshine. \end{tabular}} \\ \hline
\textbf{Tuesday} & \textbf{\begin{tabular}[c]{@{}l@{}}Cloudy with rain, across many\\ northern regions, clear spells,across most of Scotland and Northern Ireland, but rain reaching the far\\ northwest.\end{tabular}} \\ \hline
\end{tabular}
}
\end{table}
% Table 2
\begin{table}[h]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|}
\hline
\multicolumn{1}{|c|}{\textbf{Min Temp}} & \multicolumn{1}{c|}{\textbf{Max Temp}} \\ \hline
\textbf{11C} & \textbf{22C} \\ \hline
\end{tabular}
}
\end{table}
\end{document}
答案1
像这样!
\documentclass{article}
\usepackage{array}
\begin{document}
% Table 1
\begin{table}[h]
\begin{tabular}{|>{\centering\arraybackslash}p{\dimexpr0.2\textwidth-2\tabcolsep-\arrayrulewidth\relax}|
p{\dimexpr0.8\textwidth-2\tabcolsep-2\arrayrulewidth\relax}|}
\hline
\textbf{Day} & \multicolumn{1}{c|}{\textbf{Summary}} \\ \hline
\textbf{Monday} & \textbf{A clear day with lots of sunshine.} \\ \hline
\textbf{Tuesday} & \textbf{Cloudy with rain, across many northern regions, clear spells,across most of Scotland and Northern Ireland, but rain reaching the far northwest.} \\ \hline
\end{tabular}
\end{table}
% Table 2
\begin{table}[h]
\begin{tabular}{|>{\centering\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-\arrayrulewidth\relax}|
>{\centering\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-\arrayrulewidth\relax}|}
\hline
\textbf{Min Temp} & \textbf{Max Temp} \\ \hline
\textbf{11C} & \textbf{22C} \\ \hline
\end{tabular}
\end{table}
\end{document}
答案2
如果你加载表格型包,它提供了tabularx
环境和一个名为的列类型X
,LaTeX 将自动为您执行所有所需的列宽计算。
根据需要,在类型列中的材料X
(或基于类型的列中)会自动插入换行符X
- 如下面第一个表所示。
剩下的就是指定所需的总宽度表格,例如,\textwidth
。
\documentclass{article}
\usepackage{tabularx}
%% create two additional column types that are based on the 'X' type
\newcolumntype{L}{>{\raggedright\arraybackslash}X} % for ragged-right material
\newcolumntype{C}{>{\centering\arraybackslash}X} % for centered material
\begin{document}
% Table 1
\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|L|}
\hline
\textbf{Day} & \multicolumn{1}{c|}{\textbf{Summary}}\\
\hline
\textbf{Monday} &
\textbf{A clear day with lots of sunshine.}\\
\hline
\textbf{Tuesday} &
\textbf{Cloudy with rain, across many northern regions, clear spells,across most of
Scotland and Northern Ireland, but rain reaching the far northwest.} \\
\hline
\end{tabularx}
\end{table}
% Table 2
\begin{table}[h]
\begin{tabularx}{\textwidth}{|C|C|}
\hline
\textbf{Min Temp} & \textbf{Max Temp} \\
\hline
\textbf{11C} & \textbf{22C} \\
\hline
\end{tabularx}
\end{table}
\end{document}