Time for action – merging cells

Regarding our example table, commands and declarations are both input, whereas, the remaining column contains output. We shall emphasize that in our header:

  1. In our example, insert another header row. Use \multicolumn to merge cells. Alter the column formatting argument and the middle rule. Changes are highlighted:
    \begin{tabular}{@{}*3l@{}}
      \toprule[1.5pt]
      \multicolumn{2}{c}{\head{Input}} &
      \multicolumn{1}{c}{\head{Output}}\\
      \head{Command} & \head{Declaration} & \\
      \cmidrule(r){1-2}\cmidrule(l){3-3} \verb|\textrm| & \verb|\rmfamily| & \rmfamily Example text\\ \verb|\textsf| & \verb|\sffamily| & \sffamily Example text\\ \verb|\texttt| & \verb|\ttfamily| & \ttfamily Example text\\ \bottomrule[1.5pt] \end{tabular} ...

Get LaTeX Beginners Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.