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.

Is it possible to change alignment for individual rows? Example:

+------------+--------------+--------------+
| Left       |    Center    |        Right |
+------------+--------------+--------------+
share|improve this question

1 Answer 1

up vote 15 down vote accepted

Use the \multicolumn command with 1 as first argument. You may also define a new command (say, \myalign) as a shortcut.

\documentclass{article}

\newcommand*{\myalign}[2]{\multicolumn{1}{#1}{#2}}

\begin{document}

\begin{tabular}{rll}
(right-aligned) & (left-aligned) & (left-aligned) \\
foo & foo & foo \\
foo & foo & foo \\
\myalign{l}{foo} & \myalign{c}{foo} & \myalign{r}{foo} \\
foo & foo & foo 
\end{tabular}

\end{document}
share|improve this answer
7  
I find it convenient to use \let\mc\multicolumn and to use it like \mc1l{foo} and \mc1c{foo} because single-character arguments don't need braces. –  Christian Lindig Jun 12 '11 at 11:46
3  
This solution seems a little inconvenient in case of long rows with many columns or when e.g. half of the table rows should have a different alignment. I would welcome a solution in which one command would change alignment of all the following table rows. Something like this: \newtabularalignment{rrcll}. –  Peter Bašista Jul 31 '12 at 7:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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