1
\documentclass[times,twocolumn,final,authoryear]{elsarticle}
\usepackage{framed,multirow}
\begin{document}
\begin{table}
\begin{tabular}{|p{1.5cm}|p{1.5cm}|p{2.5cm}|p{2.5cm}|}
\hline
S & & XXXX & RRRR \\
\hline
S1 & P \multirow{3}{*}{}  & \multicolumn{1}{l}{1} & \multicolumn{1}{l}{2} \\
\cline{2-3}
 & & \multicolumn{1}{l}{3} & \multicolumn{1}{l}{4} \\ \cline{2-3}
 & & \multicolumn{1}{l}{5} & \multicolumn{1}{l}{6} \\ \cline{2-3}
\hline
\end{tabular}
\end{table}
\end{document}

I wanted to create a table like that in figure. I tried using multi-rows, but I do not get the line bordering. How can I create a table with full bordering and grouping?

Required Table

2
  • Welcome to TeX.SE. Please show us also the document in which you tried \multirows etc.
    – user31729
    Mar 3, 2017 at 14:47
  • If you could provide a minimal (not) working example (including only the main file and the table) where you point out the places that you couldn't solve it would be easier to help.
    – Timm
    Mar 3, 2017 at 14:47

2 Answers 2

1

In LaTeX use multirow and \cline.

\documentclass{article}
\pagestyle{empty}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|}
  \hline
  \multicolumn{2}{|c|}{S} & XX   & RRRR \\\hline
  \multirow{3}{*}{S1} & P & 1    & 0.8  \\\cline{2-4}
                      & R & 0.8  & 0.3  \\\cline{2-4}
                      & F & 0.1  & 0.7  \\\hline
  \multirow{3}{*}{S2} & P & 0.6  & 0.5  \\\cline{2-4}
                      & R & 0.6  & 0.2  \\\cline{2-4}
                      & F & 0.71 & 0.7  \\\hline
\end{tabular}

\end{document}

enter image description here

For fixed width columns, it is best to use the array package and declare a new column type.

\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{tabular}{|C{1.5cm}|C{1.5cm}|C{2.5cm}|C{2.5cm}|}
  \hline
  \multicolumn{2}{|c|}{S} & XX   & RRRR \\\hline
  \multirow{3}{*}{S1} & P & 1    & 0.8  \\\cline{2-4}
                      & R & 0.8  & 0.3  \\\cline{2-4}
                      & F & 0.1  & 0.7  \\\hline
  \multirow{3}{*}{S2} & P & 0.6  & 0.5  \\\cline{2-4}
                      & R & 0.6  & 0.2  \\\cline{2-4}
                      & F & 0.71 & 0.7  \\\hline
\end{tabular}

\end{document}

enter image description here

3
  • Thank you so much.....I got the exact result...Thanks once again Mar 3, 2017 at 15:17
  • @SubethaThankaraj If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and marking it as accepted answer (by clicking on the checkmark ✓). Mar 3, 2017 at 15:17
  • Yeah sure.....I am new to this form ....I hope i have accepted and upvote the answer Mar 3, 2017 at 15:22
1

That is very easy to achieve with ConTeXt MKIV and Natural Tables.

\starttext

\startsetups table:multirows
  \setupTABLE[align={middle,lohi}]
  \setupTABLE[column][each][loffset=.5em,roffset=.5em]
\stopsetups
\startTABLE[setups={table:multirows}]
  \NC[nx=2] S        \NC XX   \NC RRRR \NC\NR
  \NC[ny=3] S1 \NC P \NC 1    \NC 0.8  \NC\NR
               \NC R \NC 0.8  \NC 0.3  \NC\NR
               \NC F \NC 0.1  \NC 0.7  \NC\NR
  \NC[ny=3] S2 \NC P \NC 0.6  \NC 0.5  \NC\NR
               \NC R \NC 0.6  \NC 0.2  \NC\NR
               \NC F \NC 0.71 \NC 0.7  \NC\NR
\stopTABLE

\stoptext

enter image description here

2
  • Hi...Thank you so much for your reply.. I am using this table in my journal and i am getting error for the above code when i run... Mar 3, 2017 at 15:14
  • @SubethaThankaraj You are most probably not using ConTeXt if you want to submit to a journal. See my other answer for a LaTeX solution. Mar 3, 2017 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .