3

I'm getting some little problems when using \multirow:

Here is my code:

\documentclass[a4paper,10pt]{article} % Default font size and paper size \usepackage{multirow} \begin{document} \begin{tabular}{ |l| c| c| } \hline \textbf{1} & \textbf{2} & \textbf{3} \\ \hline \multirow{4}{*}{A} & 1 & 1 \\ & 2 & 2 \\ & 3 & 3 \\ \hline \multirow{4}{*}{B} & 1 & 1 \\ & 2 & 2 \\ \hline \end{tabular} \end{document} 

Here is the preview:

enter image description here

Problems:

  1. As you can see, in cell (2,1), the B is not properly positioned in the middle of the cell
  2. How is it possible to separate only multirows in Row 1?
2
  • 5
    The first argument to \multirow is the number of rows spanned: it should be 3 in the first case, 2 in the second case. The second question is not clear. Commented Oct 27, 2013 at 13:28
  • I just want an \hline between all rows in Column 2 and 3 Commented Oct 27, 2013 at 14:04

2 Answers 2

3

You probably want an output like this:

enter image description here

MWE:

\documentclass[a4paper,10pt]{article} % Default font size and paper size \usepackage{multirow} \begin{document} \begin{tabular}{|l|c|c|} \hline \textbf{1} & \textbf{2} & \textbf{3} \\ \hline \multirow{3}{*}{A} & 1 & 1 \\ \cline{2-3} & 2 & 2 \\ \cline{2-3} & 3 & 3 \\ \hline \multirow{2}{*}{B} & 1 & 1 \\ \cline{2-3} & 2 & 2 \\ \hline \end{tabular} \end{document} 
  1. Use the right number of rows when using \multirow.
  2. Use \cline{<start column>-<end column>} to get partial horizontal lines.
1

For information, here is a way to create that tabular with {NiceTabular} of nicematrix. In that environment, the key hvlines draws all the rules, except in the blocks, created by the built-in command \Block.

\documentclass[a4paper,10pt]{article} \usepackage{nicematrix} \begin{document} \begin{NiceTabular}{ccc}[hvlines] \RowStyle{\bfseries} 1 & 2 & 3 \\ \Block{3-1}{A} & 1 & 1 \\ & 2 & 2 \\ & 3 & 3 \\ \Block{2-1}{B} & 1 & 1 \\ & 2 & 2 \end{NiceTabular} \end{document} 

Output of the above code

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.