user
how to change the dimensions of a table in latex
alphonsio

To change the dimensions of a table in LaTeX, you can adjust width, height, column spacing, and row spacing using various techniques. Here are common ways to control table dimensions:

1. Scaling the Entire Table

Use the \resizebox or \scalebox commands from the graphicx package.

Example:

\usepackage{graphicx} % in preamble

\resizebox{\textwidth}{!}{%
  \begin{tabular}{|c|c|}
    \hline
    A & B \\
    \hline
    C & D \\
    \hline
  \end{tabular}
}
  • \textwidth: set the table width relative to the text width
  • !: automatically scale height proportionally

2. Adjust Column Widths

Use the p{width} specifier or packages like tabularx.

With p{}:

\begin{tabular}{|p{4cm}|p{6cm}|}
  \hline
  Column 1 & Column 2 \\
  \hline
\end{tabular}

With tabularx:

\usepackage{tabularx} % in preamble

\begin{tabularx}{\textwidth}{|X|X|}
  \hline
  Column 1 & Column 2 \\
  \hline
\end{tabularx}
  • X columns automatically stretch to fill the total width

3. Adjust Row Height

Use \renewcommand{\arraystretch}{value} to change the vertical spacing between rows.

\renewcommand{\arraystretch}{1.5} % 1.5x default row height
\begin{tabular}{|c|c|}
  \hline
  A & B \\
  \hline
  C & D \\
  \hline
\end{tabular}

4. Cell Padding (Horizontal Spacing)

Adjust using @{\hspace{Xcm}} or modify column spec.

\begin{tabular}{|@{\hspace{0.5cm}}c@{\hspace{0.5cm}}|c|}
  \hline
  A & B \\
  \hline
\end{tabular}