0

In this example

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{l l l}
  00pad & 01pad & 02pad\\
  10 & 11 & 12\\
  20 & \multicolumn{1}{r}{21} & 22\\
  30 & 31 & 32\\
  \multicolumn{1}{r}{40} & \multicolumn{1}{r}{41} & \multicolumn{1}{r}{42}\\
  50 & 51 & 52\\
\end{tabular}
\end{document}

I have overridden the column alignment in cell 21 and row 4. The result is:

enter image description here

Is using \multicolumn the most efficient and simple macro to achieve the desired effect?

2 Answers 2

2

Using makecell is slightly shorter – and it allows you to have multiline cells in this context. By default, it is vertically and horizontally centred, but it can be changed with the optional argument which can contain up to 2 letters each in the groups r, l, c and t, b, c.

Demo:

\documentclass{article}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}

\begin{tabular}{l l l}
  00pad & 01pad & 02pad\\
  10 & 11 & 12\\
  20 & \makecell[r]{21} & 22\\
  30 & 31 & 32\\
  \makecell[r]{40} & \makecell[r]{41} & \makecell[r]{42\\43}\\
  50 & 51 & 52\\
\end{tabular}

\end{document} 

enter image description here

1

In your example I would not use \multicolumn, because a simple \hfill will do (for right-aligned cell).

hfilled

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{l l l}
  00pad & 01pad & 02pad\\
  10 & 11 & 12\\
  20 & \hfill 21 & 22\\
  30 & 31 & 32\\
    \hfill 40 & \hfill 41 & \hfill 42\\
  50 & 51 & 52\\
\end{tabular}
\end{document}
2
  • What if I wanted to override left alignment with centring?
    – Viesturs
    Jan 3, 2018 at 15:50
  • 1
    You could use \hfill 21 \hfill.
    – Sandy G
    Jan 3, 2018 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .