1

After lots of attempts, I've been unable to get a table exactly as the one below. I don't know if somebody could give me some advice. enter image description here.

I took the code of another table and managed to get this:

\begin{longtable}[c]{|c|c|c|c|c|c|}
\cline{3-6}
\multicolumn{2}{c|}{}& \multicolumn{3}{c|}{X} \\
\cline{3-6}
\multicolumn{1}{c}{}& & 1& 2& 3\\
\hline \multirow{2}{*}{$Y$}
& 1& 0.23 & 1 & 232.23 \\
\cline{2-6}
& 2& 0  & -21 & 0\\
\cline{2-6}
\hline
\end{longtable}
\end{document}

But the result is far from what I want. Besides, when I try to compile the whole document, not just the table, I got some errors related to the longtable package.

Many thanks! C.

3
  • 1
    Welcome to TeX.SX! I can understand you need this table. It's difficult to reproduce in LaTeX because it's a very badly shaped table, I hope you agree. ;-) – egreg May 27 '15 at 18:17
  • I agree it is difficult. Otherwise, I could have done it. – Carol May 27 '15 at 18:35
  • 1
    What have you managed to do so far? Please share a base code. – anderstood May 27 '15 at 18:48
1

Here's an implementation with low level commands

\documentclass{article}

\newcommand{\thickhrulefill}{%
 \leavevmode\leaders\hrule height.4pt depth.6pt\hfill\kern 0pt
}


\begin{document}

\begingroup\sffamily\offinterlineskip
\tabskip=0pt
\halign{%
  #&
  \vrule#\hfil &
  \kern0.8pt \vrule#&
  \makebox[.25in]{#}&
  \vrule#\hfil &
  \makebox[1in]{\strut#}&
  \hfil\vrule#\hfil &
  \makebox[1in]{\strut#}&
  \hfil\vrule#\hfil &
  \makebox[1in]{\strut#}&
  \hfil\vrule#\hfil
\cr
\multispan{4}&\multispan{7}\hfil\strut X\hfil\cr
\multispan{4}&\multispan{7}\hrulefill\cr
\multispan{4}& height .8pt &\multispan{5}&\cr
\multispan{4}&\multispan{7}\hrulefill\cr
\multispan{4}&&1&&2&&3&\cr
\omit & height.4pt depth .6pt &\omit\hrulefill\vrule depth.6pt &\hrulefill &\multispan{7}\thickhrulefill\cr
\smash{\lower.6\normalbaselineskip\hbox{Y }}&&&1& width 1pt &0.23&&1&&232.23&\cr
\omit&&&\multispan{8}\hrulefill\cr
&&&2& width 1pt &0&&--21&&0&\cr
\omit&\multispan{10}\hrulefill\cr
}
\endgroup
\end{document}

enter image description here

And now a perhaps preferable rendering

\documentclass{article}
\usepackage{booktabs,array}

\begin{document}

\begingroup\sffamily
\begin{tabular}{
  >{\centering}p{.25in}
  >{\centering}p{1in}
  >{\centering}p{1in}
  >{\centering\arraybackslash}p{1in}
}
\toprule
Y & \multicolumn{3}{c}{X} \\
\cmidrule(lr){1-1}\cmidrule(lr){2-4}
& 1 & 2 & 3 \\
\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}
1 & 0.23 & 1 & 232.23 \\
2 & 0 & --21 & 0 \\
\bottomrule
\end{tabular}
\endgroup

\end{document}

enter image description here

1
  • Thanks a lot, egreg! This is exactly what I wanted to get. Many thanks for your help! C. – Carol Jun 3 '15 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.