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.

I want to align a picture in a cell of a table. Following works as I want for the text in the top left cell and the picture is already vertically aligned, but not horizontally:

\begin{tabular}{m{0.04\textwidth}|m{0.325\textwidth}|m{0.6\textwidth}}
 \toprule
  \centering{a} & b & \includegraphics[draft]{test}\\ \midrule
  d             & e & f\\
 \bottomrule
\end{tabular}

However placing \includegraphics{test} into a \centering{} results in following error message:

! Misplaced \noalign.
\midrule ->\noalign 
                {\ifnum 0=`}\fi \@aboverulesep =\aboverulesep \global \@...
l.338 ...test}}\\ \midrule
? 
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.339   d &
            e & f\\
share|improve this question

1 Answer 1

up vote 4 down vote accepted

\centering does not take an argument, making \centering{a} be no different from \centering a. Also, \centering used in your instance has no effect within a tabular. Horizontal \centering is obtained using

\hfill\includegraphics[..]{...}\hfill\null

Alternatively, if you want the entire column to use \centering, you can use

>{\centering\arraybackslash}m{..}

as the column type (the above support is also provided by array).

share|improve this answer
1  
Thank you. I've just found a tex-faq discussing the problem of “misplaced \noalign” complaints when using \centering, \raggedright, \raggedleft in a table. –  Hotschke Apr 12 '12 at 8:41

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.