0

I have a table like this:

\begin{table}[h]
\begin{center}
\begin{tabular}{|l|c|c|c|}
\hline
M & G1 & G2 & G3 \\
\hline\hline
A   & 1 & 2 & 3 \\
B   & 4 & 5 & 6 \\
C   & 7 & 8 & 9 \\
\hline
\multicolumn{1}{|l|}{R} & \multicolumn{3}{c|}{text} \ \multicolumn{1}{c|}{text} \\
\hline
\end{tabular}
\end{center}
\end{table}

I want to achieve this: requiredTable

I am so close but I am at my wits end trying to get this to be correct. Please help? Thank you!

1
  • Please do not add external pictures, but include them using our editor's feature. In addition it would be really nice to post a MWE instead of adding a code fragment. What for do you use the first multicolumn of your last row and how does your last line work in general?
    – TeXnician
    Feb 24, 2017 at 9:59

2 Answers 2

5

This is a possibility, but a “real world” sample would be necessary for fine tuning it.

\documentclass{article}

\begin{document}

\begin{tabular}{|l|c|c|c|}
\hline
M & G1 & G2 & G3 \\
\hline
A   & 1 & 2 & 3 \\
B   & 4 & 5 & 6 \\
C   & 7 & 8 & 9 \\
\hline
R & \multicolumn{3}{c|}{%
  \hspace*{0pt}%
  \hfill T\hfill
  \hspace{\tabcolsep}\vline\hspace{\tabcolsep}%
  \hfill T\hfill
  \hspace*{0pt}%
} \\
\hline
\end{tabular}

\end{document}

enter image description here

1

enter image description here

let instead split one cell to two merge two cells into one :):

\documentclass{article}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcommand\mca[1]{\multicolumn{2}{P{\dimexpr22mm-2\tabcolsep\relax}|}{#1}}
\newcommand\mcb[1]{\multicolumn{2}{P{33mm}|}{#1}}

\begin{document}

\begin{tabular}{|p{22mm}|P{22mm}| P{11mm} P{11mm} |P{22mm}|}
\hline
M   & G1 & \mca{G2} & G3 \\
\hline
A   & 1  & \mca{2}  & 3 \\
B   & 4  & \mca{5}  & 6 \\
C   & 7  & \mca{8}  & 9 \\
\hline
R   & \mcb{T} & \mcb{T} \\
\hline
\end{tabular}

\end{document}

You must log in to answer this question.

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