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.

The following is a minimal example of a table I am defining. The first row ($v_1$ and $v_2$) are not centered, but the subsequent rows are. What am I doing wrong?

\documentclass{article}
\usepackage{array}

\begin{document}
    \begin{tabular}{| m{1cm} | m{1cm} |} 
        \multicolumn{2}{c}{\footnotesize Subgraph Matches} \\ \hline
        $v_{1}$ & $v_{2}$ \\ \hline
        \{005\} & \{006\} \\ \hline
        \{007\} & \{008\} \\ \hline
    \end{tabular}
\end{document}
share|improve this question
    
You can accept your own answers in your previous questions which would increase your accept rate. –  percusse Oct 6 '12 at 0:58

1 Answer 1

up vote 5 down vote accepted

Centering in tabular is done with the c column type. The m column type is used for vertical centering, not horizontal centering which is what this table needs:

enter image description here

However, you should really consider the booktabs package which produces more professional looking tables:

enter image description here

Code:

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}

\begin{document}
    \begin{tabular}{| c | c |} 
        \multicolumn{2}{c}{\footnotesize Subgraph Matches} \\ \hline
        $v_{1}$ & $v_{2}$ \\ \hline
        \{005\} & \{006\} \\ \hline
        \{007\} & \{008\} \\ \hline
    \end{tabular}

    \bigskip\bigskip
    \begin{tabular}{ c  c } 
        \multicolumn{2}{c}{\footnotesize Subgraph Matches} \\ \toprule
        $v_{1}$ & $v_{2}$ \\ \cmidrule(lr){1-2}
        \{005\} & \{006\} \\ %\cmidrule(lr){1-2}
        \{007\} & \{008\} \\ \bottomrule
    \end{tabular}
\end{document}
share|improve this answer
    
Arrghh, elementary Mr. Watson... Thanks much; I should just go to bed... –  ozsu Oct 6 '12 at 1:03

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.