Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
Aligning inside tabular environment, specific cell

I have a simple table with a given align. I want to know if there is a way to specify a different align for a cell. For example, in the following table, how can I make Item 3 align right?

\begin{table}
    \begin{tabular}{|l|r|}
        \hline
        Header1 & HeaderX \\ \hline
        Item1   & X1      \\ 
        Item2   & X2      \\ 
        Item3   & X3      \\
        \hline
    \end{tabular}
\end{table}
share|improve this question

marked as duplicate by Peter Grill, lockstep, cmhughes, percusse, Mico Mar 12 '12 at 3:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer

up vote 26 down vote accepted

Use \multicolumn -- it also works for single cells. Note that you have to specify any vertical rules also in the second argument of \multicolumn.

\documentclass{article}

\begin{document}

\begin{table}
    \begin{tabular}{|l|r|}
        \hline
        Header1 & HeaderX \\ \hline
        Item1   & X1      \\ 
        Item2   & X2      \\ 
        \multicolumn{1}{|r|}{Item3}   & X3      \\
        \hline
    \end{tabular}
\end{table}

\end{document}

enter image description here

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.