My tables seems to have different width to one another. How do i set the width of the colums in a table.
This is the coding for the table i am using:
\begin{table}[H]
\begin{center}
\begin{tabular}{ | l | l | }
\hline
Test No & 1 \\ \hline
Description & Selecting continue from welcome page \\ \hline
Input & Button click \\ \hline
Result & Expected result \\ \hline
Conclusion & The button did its function and routed the user to the next page \\
\hline
\end{tabular}
\caption{Test case 1: Welcome page button}
\label{tb:Test case 1: Welcome page button}
\end{center}
\end{table}
Where would i need to apply the neccessary coding:
General ⇒ Adjusting width of table
NEW: TikZ book now 40% off at Amazon.com for a short time.
Adjusting width of table
You can use the p{...} (or m{...} if the array package was loaded) modifier in the declaration of the table format, as the following example suggests:
Code: Select all
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[H]
\setlength\extrarowheight{3pt}
\centering
\begin{tabular}{|p{2cm}|p{5cm}|}
\hline
Test No & 1 \\ \hline
Description & Selecting continue from welcome page \\ \hline
Input & Button click \\ \hline
Result & Expected result \\ \hline
Conclusion & The button did its function and routed the user to the next page \\
\hline
\end{tabular}
\caption{Test case 1: Welcome page button}
\label{tb:Test_case_1}
\end{table}
%requires the array package
\begin{table}[H]
\setlength\extrarowheight{3pt}
\centering
\begin{tabular}{|m{2cm}|m{5cm}|}
\hline
Test No & 1 \\ \hline
Description & Selecting continue from welcome page \\ \hline
Input & Button click \\ \hline
Result & Expected result \\ \hline
Conclusion & The button did its function and routed the user to the next page \\
\hline
\end{tabular}
\caption{Test case 2: Welcome page button}
\label{tb:Test_case_2}
\end{table}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: Adjusting width of table
Could you please tell the difference between the following two line of codes
\caption{xyz}
\label{tb:xyz}
\caption{xyz}
\label{tb:xyz}
Adjusting width of table
The \caption command sets the caption for your float enviroment (usually table or figure); the \label{key} command allows you to cross-reference objects using the corresponding \ref{key} command. Inside a floating environment you should always use \label after \caption.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Adjusting width of table
Basic LaTeX documentation is available with lshort and l2tabu. Useful hints about float environments can be found in epslatex.ma501th wrote:Could you please tell the difference between the following two line of codes
\caption{xyz}
\label{tb:xyz}
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10