Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I unify the table size and the font size for these two tables

\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}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

Like this!

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

enter image description here

share|improve this answer
    
Thank you very much :) –  Linda Jun 14 at 1:04

If you load the tabularx package, which provides the tabularx environment and a column type named X, LaTeX will perform all required column width calculations for you automatically.

Line breaks are inserted automatically, as needed, in the material that's in a column of type X (or in a column of a type that's based on X -- as in the first table below).

What's left for you is to specify the desired overall width of the table, say, \textwidth.

enter image description here

\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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.