Multirow and Multicol in tabular
📅 December 10, 2024 | 👁️ Views: 35

The \multicolumn{3}{alignment}{content}
command in LaTeX allows a single cell to span multiple columns. The first argument (3
) specifies the number of columns the cell will span, meaning it will cover three adjacent columns. The second argument (|c|
) determines the alignment and borders of the spanned cell, where c
centers the content, and |
adds vertical borders on both sides. The third argument (content
) is the text or content of the spanned cell. Similarly, the \multirow{2}{*}{content}
command lets a single cell span multiple rows. The first argument (2
) specifies the number of rows the cell spans, and the second argument (*
) indicates that the width is automatically adjusted to fit the content. The third argument (content
) is the actual content of the spanned cell. Together, these commands allow flexible and well-organized table designs in LaTeX.
\documentclass{standalone}
\standaloneconfig{margin=4mm}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{array}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{3}{|c|}{Multicol and multirow in tabular}\\
\hline
$t_i$ & $\ddot{y}(t_i)$ & $P[t_{i};t_{i-1}]$ \\ \hline
$t_n$ & $\ddot{y}(t_n)$ & \multirow{2}{*}{\(\frac{\ddot{y}(t_n) - \ddot{y}(t_{n-1})}{t_n - t_{n-1}}\)} \\
$t_{n-1}$ & $\ddot{y}(t_{n-1})$ & \\ \hline
\end{tabular}
\end{document}