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.

Here is some simple table - I cannot upload, because I'm just a guest.

I want to merge 4 cells. I mean I want to combine three "this" area in this table. I thought I have to use multirow and multicolum at same time. However, I could not find how to use it. I'm newbie for LaTeX.

If possible, can you modify this into what I want? Also if you are possible, could you post modified LaTeX source code?

My LaTeX code:

\begin{table}[ph]
\begin{center}
\begin{tabular}{c|c|c|c|c}
\hline
\multirow{2}{*}{Raaa (k)} & \multicolumn{4}{c}{C ()} \\
\hhline{~----}
 & 3.3 & 2.5 & 1 & 0.5 \\
\hline
\multirow{2}{*}{Raaa (k)} & \multirow{2}{*}{this} & this & 0.5 & 0.6\\
\hhline{~~~--}            &                       & this & 0.7 & 1.2 \\
\hline
\end{tabular}
\caption{R, C ripple size}
\label{T:peak}
\end{center}
\end{table}
share|improve this question
    
Welcome to TeX.sx! Next time you ask a question, please add a full minimal working example (MWE). As you just posted the table, Werner had to find out that you're using the packages multirow and hhline in order to solve your problem. That's just unnecessary work. Also, it'd be nice if you added a picture to this question, now as you have some reputation points and the new user restrictions have been removed from your account. –  doncherry Nov 17 '11 at 13:42

2 Answers 2

Both rows should contain a \multicolumn{2}{c|}{...}, and the first row should contain a nested \multirow{2}{*}{...}:

enter image description here

\documentclass{article} 
\usepackage{multirow}% http://ctan.org/pkg/multirow
\usepackage{hhline}% http://ctan.org/pkg/hhline
\begin{document}
\begin{table}[ph]
  \centering
  \begin{tabular}{c|c|c|c|c}
    \hline
    \multirow{2}{*}{Raaa (k)} & \multicolumn{4}{c}{C ()} \\
    \hhline{~----}
    & 3.3 & 2.5 & 1 & 0.5 \\
    \hline
    \multirow{2}{*}{Raaa (k)} & \multicolumn{2}{c|}{\multirow{2}{*}{this}} & 0.5 & 0.6\\
    \hhline{~~~--}            & \multicolumn{2}{c|}{}                      & 0.7 & 1.2 \\
    \hline
  \end{tabular}
  \caption{R, C ripple size}
  \label{T:peak}
\end{table}
\end{document}

Since \multicolumn overrides any of the set column alignments (including the vertical rules), you have to respecify everything. Hence the use of c| to center the contents and end it with a vertical rule.

Also note how I used \centering instead of the center environment (\begin{center} ... \end{center}). This allows for better vertical spacing around elements in your document. Consider reading the following post: Should I use center or centering for figures?

share|improve this answer

Vertical lines burn my eyes. Tables almost always look better without them. Here's a version that uses booktabs for nice horizontal lines.

\documentclass{article} 
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}

\begin{table}[ht]
\centering
\begin{tabular}{ccccc}
  \toprule
    \multirow{2}{*}{Raaa (k)} & \multicolumn{4}{c}{C ()} \\
    \cmidrule{2-5} & 3.3 & 2.5 & 1 & 0.5 \\
  \midrule
    \multirow{2}{*}{Raaa (k)} & \multicolumn{2}{c}{\multirow{2}{*}{this}} & 0.5 & 0.6 \\
    \cmidrule{4-5}            & \multicolumn{2}{c}{}                      & 0.7 & 1.2 \\
  \bottomrule
\end{tabular}
\caption{R, C ripple size}
\end{table}

\end{document}

Which gives you this:

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.