[Tex/LaTex] How to horizontally align text in a multirow element

horizontal alignmentmultirowtables

In the tabular environment, horizontal alignment is traditionally achieved using such arguments as l, c, and r for the table spec. However, when \multirow (from package multirow) is used, the chosen alignment seems to no longer apply. This example

\documentclass{standalone}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|r|p{5cm}|}
 \multirow{2}{2.3cm}{text1 text1 text1} & text2 \\
 & text3 \\
 & text4 \\
\end{tabular}
\end{document}

produces

MWE showing left-aligned text in column 1

The problem is that "text1" is left-aligned despite the fact that the first column was created using an 'r' argument to tabular. How can I specify the alignment of the text in the multirow element? For example, how could I right-align or center it instead?

Best Answer

If you specify a width in \multirow, it is essentially a p column, so you specify alignment in the same way:

\documentclass{standalone}
\usepackage{multirow}

\begin{document}
\begin{tabular}{|r|p{5cm}|}
 \multirow{2}{2.3cm}{\raggedleft text1 text1 text1} & text2 \\
 & text3 \\
 & text4 \\
\end{tabular}
\end{document}