3

I want to create the table below and I am not sure how to do it.

I also want the lines that say, "Long line of text really long" to be wrapped, and take up 2 instead of 1 so that the table isn't as long. I want this table to fit in a column of a 2 column paper.

I included an arrow in the picture because I want that first vertical line to be thick also and I don't know how to do it.

I also want the horizontal line below the columns 2-9 to be bold.

Thank you!

enter image description here

4

One possibility:

\documentclass[twocolumn]{article}
\usepackage{tabularx}
\usepackage{array}
\usepackage{rotating}
\usepackage{lipsum}

\renewcommand\tabularxcolumn[1]{>{\small}m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand\RotText[1]{\rotatebox{90}{\parbox{2cm}{\centering#1}}}

\newlength{\arrayrulewidthOriginal}
\newcommand{\Cline}[2]{%
  \noalign{\global\setlength{\arrayrulewidthOriginal}{\arrayrulewidth}}%
  \noalign{\global\setlength{\arrayrulewidth}{#1}}\cline{#2}%
  \noalign{\global\setlength{\arrayrulewidth}{\arrayrulewidthOriginal}}}

\begin{document}

{
\setlength\tabcolsep{1pt}
\noindent\begin{tabularx}{\columnwidth}{|Y!{\vrule width 1pt}Y|Y|Y|Y|Y!{\vrule width 1pt}Y|Y|Y|Y|}
\cline{2-10}
\multicolumn{1}{c!{\vrule width 1pt}}{} & \multicolumn{5}{c!{\vrule width 1pt}}{Some text}  & \multicolumn{4}{c|}{Some text} \\
\cline{2-10}
\multicolumn{1}{c!{\vrule width 1pt}}{} & \RotText{Some really long text} & \RotText{Some really long text}
  & \RotText{Some really long text} & \RotText{Some really long text} 
  & \RotText{Some really long text} & \RotText{Some really long text} 
  & \RotText{Some really long text} & \RotText{Some really long text} 
  & \RotText{Some really long text} \\
\noalign{\hrule height 1pt}
some text & 11 & 44 & 11 & 54 & 34 & 54 & 23 & 11 & 12 \\
\hline
\end{tabularx}
}

\lipsum[1-10]

\end{document}

enter image description here

A close-up to the table:

enter image description here

Some explanatory comments:

  • You can produce vertical rules of the desired thickness using !{\vrule width 1pt} instead of | (change 1pt to the desired value).

  • You can produce horizontal rules (similar to \hline) of the desired thickness using \noalign{\hrule height 1pt} instead of \hline (change 1pt to the desired value).

  • The \Cline command is similar to \cline, but has a mandatory argument allowing to specify the rule thicknes: \Cline{<length>}{<column1>-<column2>}; for example \Cline{2pt}{2-4} draws a horizontal rule 2pt thick spanning columns 2 to 4.

  • The tabularx package was used to guarantee that the table width equals \columnwidth. A new column type was defined with centered contents; \tabularxcolumn was also redefined to obtain m{...} type columns.

  • The rotated text was produced using a \parbox inside a \rotatebox.

Notice, however, that your table goes against some rules of typography: vertical rules can be avoided and rotated text is not a good practice (thinking on the reader). Perhaps you could try reformulating the layout?

Here's a possibility without vertical rules and with the features provided by booktabs:

\documentclass[twocolumn]{article}
\usepackage{tabularx}
\usepackage{array}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{lipsum}

\renewcommand\tabularxcolumn[1]{>{\small}m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand\RotText[1]{\rotatebox{90}{\parbox{2cm}{\raggedright#1}}}
\begin{document}

{
\setlength\tabcolsep{1pt}
\noindent\begin{tabularx}{\columnwidth}{YYYYYYYYYY}
\cmidrule[1pt]{2-10}
\multicolumn{1}{c}{} & \multicolumn{5}{c}{Some text}  & \multicolumn{4}{c}{Some text} \\
\cmidrule(r){2-2}\cmidrule(r){3-3}\cmidrule(r){4-4}\cmidrule(r){5-5}
\cmidrule(r){6-6}\cmidrule(r){7-7}\cmidrule(r){8-8}\cmidrule(r){9-9}\cmidrule{10-10}
\multicolumn{1}{c}{} & \RotText{Some really long text} & \RotText{Some really long text}
  & \RotText{Some really long text} & \RotText{Some really long text} 
  & \RotText{Some really long text} & \RotText{Some really long text} 
  & \RotText{Some really long text} & \RotText{Some really long text} 
  & \RotText{Some really long text} \\
\cmidrule[1pt](r){1-1}\cmidrule[1pt](r){2-6}\cmidrule[1pt]{7-10}
some text & 11 & 44 & 11 & 54 & 34 & 54 & 23 & 11 & 12 \\
some text & 11 & 44 & 11 & 54 & 34 & 54 & 23 & 11 & 12 \\
\bottomrule[1pt]
\end{tabularx}
}

\lipsum[1-10]
\end{document}

enter image description here

  • Is it possible to do the following?: I want that first vertical line to be thick also and I don't know how to do it. I also want the horizontal line below the columns 2-9 to be bold. – Veridian Aug 11 '13 at 1:34
  • @sphere please see my updated answer. Is it something like that what you want? – Gonzalo Medina Aug 11 '13 at 1:50
  • Thank you, but I wanted the horizontal border above the far left column to be normal, not thick, how do you do that? Also, I wanted the text centered please. – Veridian Aug 11 '13 at 17:31
  • @sphere which text should be centered? – Gonzalo Medina Aug 11 '13 at 17:45
  • 1
    @sphere yes, I did it. I also thinks it looks better this way. – Gonzalo Medina Aug 11 '13 at 18:33

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.