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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having a few problems with a table which uses \multicolumn and the booktabs package.

This is what I've done:

\documentclass[12pt]{article}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

\begin{center}

  \begin{tabular}{*{7}{c}}
    \toprule
    & \multicolumn{2}{c}{\textsc{sg}} &
\multicolumn{2}{c}{\textsc{du}} & \multicolumn{2}{c}{\textsc{pl}} \\
    \cmidrule(lr){2-3}
    \cmidrule(lr){4-5}
    \cmidrule(lr){6-7}
    & \textsc{m} & \textsc{n} & \textsc{m} & \textsc{n} & \textsc{m} &
\textsc{n} \\
    \midrule
    \textsc{nom} & \textit{s} & \textit{m} \\
    \textsc{acc} & \multicolumn{2}{c}{\textit{m}} \\
    \textsc{ins} & \multicolumn{2}{c}{\textit{-a} $\to$ \textit{ena}} \\
    \multirow{2}{*}{\textsc{dat}} & \multicolumn{2}{c}{\textit{aya}} \\
    & \multicolumn{2}{c}{\textit{-a} $\to$ \textit{\={a}ya}} \\
    \textsc{abl} & \multicolumn{2}{c}{\textit{t} (\textit{-a} $\to$ \textit{\={a}})} \\
    \textsc{gen} & \multicolumn{2}{c}{\textit{sya}} \\
    \multirow{2}{*}{\textsc{loc}} & \multicolumn{2}{c}{\textit{i}} \\
    & \multicolumn{2}{c}{\textit{-a} $\to$ \textit{e}} \\
    \bottomrule
  \end{tabular}

\end{center}

\end{document}

enter image description here

I think it's pretty clear that the horizontal centring is off where I've used \multicolumn. The M and N beneath SG are not equidistant from SG, the m in the ACC row seems to be nicely centred under SG but is woefully out of alignment with the s and m of the NOM row above.

share|improve this question
    
Your third column is much larger than your second, which explains the strange-looking centering in rows 2 and 3. (The other rows are centred across columns 2 and 3. Relying on centering like this is not worth the hassle. What about something like: c >{\centering}m{1cm} >{\centering}m{1cm} *{4}{c}}? As an aside: it is a bad practice (in my opinion) to kill your table rows with the \\ when not all cells have been specified. – jon Feb 27 at 6:32
    
Note my earlier comment would also need to load the array package as in Zarko's (+1) answer.... – jon Feb 27 at 6:44
up vote 10 down vote accepted

Contents in your table is still perfectly centered, however, their width is changed according to width of \multicolumn{2}{c}{... cells. If it is wider than your "normal" column, than additional width is added to the second column. This you can see, if you add the vertical lines to your table.

One of possible solutions is the following. Lets assume, that multicolumn cells width is not larger than 6em. Than you can solve your problem with:

\documentclass[12pt]{article}
    \usepackage[a4paper,margin=1.8cm]{geometry}
    \usepackage[parfill]{parskip}
    \usepackage{array,booktabs,multirow}

\begin{document}
\begin{center}
  \begin{tabular}{>{\scshape}r*{6}{>{\centering\arraybackslash}p{3em}}}
    \toprule
    & \multicolumn{2}{c}{\textsc{sg}} &
\multicolumn{2}{c}{\textsc{du}} & \multicolumn{2}{c}{\textsc{pl}} \\
    \cmidrule(lr){2-3}
    \cmidrule(lr){4-5}
    \cmidrule(lr){6-7}
    & \textsc{m} & \textsc{n} & \textsc{m} & \textsc{n} & \textsc{m} &
\textsc{n} \\
    \midrule
nom & \textit{s} & \textit{m} \\
acc & \multicolumn{2}{c}{\textit{m}} \\
ins & \multicolumn{2}{c}{\textit{-a} $\to$ \textit{ena}} \\
\multirow{2}{*}{dat} 
    & \multicolumn{2}{c}{\textit{aya}} \\
    & \multicolumn{2}{c}{\textit{-a} $\to$ \textit{\={a}ya}} \\
abl & \multicolumn{2}{c}{\textit{t} (\textit{-a} $\to$ \textit{\={a}})} \\
gen & \multicolumn{2}{c}{\textit{sya}} \\
\multirow{2}{*}{loc} 
    & \multicolumn{2}{c}{\textit{i}} \\
    & \multicolumn{2}{c}{\textit{-a} $\to$ \textit{e}} \\
    \bottomrule
    \end{tabular}
\end{center}
\end{document}

I little bit optimize your code (see difference in the first column). That code can works, I add package array.

enter image description here

share|improve this answer

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.