3

I have a table made in MS Office and I'd like to recreate it using LaTeX.

enter image description here

I've attempted a number of solutions using Table+Tabular (using this as a template); this has worked until I try to implement multirow, and then it all goes haywire. In particular, I'm not including a MWE because I can't get any example even remotely illustrating what I'm trying to do to work....

Can anyone help? I'm a little table-dumb in TeX anyway, so this is well beyond the scope of my expertise.

PS: The little legend on the side isn't necessary. If someone's clever enough to get it included, super-kudos, but I'm really only concerned with the body of the table itself.

Edit: Here's a table I built that has the data in it sans formatting. Sorry for coming off as nonchalant.

\usepackage{multirow}

\begin{document}    
\begin{table}[ht]
\centering
    \begin{tabular}{|c|c|c|c|}
        \hline
        & 
        Day 1 &
        Day 2 &
        Day 3 \\
        \hline
        \multirow{3}{*}{Subject 1}&
            A & C & B\\
            \cline{2-4}
            &B & A & C\\
            \cline{2-4}
            &C & B & A\\
        \hline
        \multirow{3}{*}{Subject 2}&
        B & A & C\\
        \cline{2-4}
        &C & B & A\\
        \cline{2-4}
        &A & C & B\\
        \hline
        \multirow{3}{*}{Subject 3}&
        C & B & A\\
        \cline{2-4}
        &A & C & B\\
        \cline{2-4}
        &B & A & C\\
        \hline
    \end{tabular}
\end{table}
\end{document}

Edit 2: In the attached image, the row headings ("Subject 1", "Subject 2",...) should be vertically centered. That is included in the TeX example I've attached above. Sorry for the lack of oversight.

  • 1
    In the very least, include a table that has the information you provide in the image. It'll at least show that you... care. – Werner Nov 21 '15 at 5:38
  • @Werner - Indeed, that would have been a good first step on my part. Very sorry for not thinking to include it. – cstover Nov 21 '15 at 5:41
  • Are the white lines between the cells required, or can you make do without them? – Mico Nov 21 '15 at 9:20
  • @Mico - They would be very helpful on my end though I could consider an answer without them. They needn't necessarily be white, however, if that helps? Standard black table lines would suffice. I'd be appreciative of whatever you could do, but some sort of horizontal line would be great. – cstover Nov 21 '15 at 12:44
3

Here's an attempt to replicate the table in the screenshot you posted. A comment: Given that you want to use colors, I would do away with all interior lines of the table. (I've already omitted all exterior lines.)

enter image description here

\documentclass{article}
\usepackage[table,svgnames]{xcolor}
\begin{document} 

\begin{table}[ht]
\arrayrulecolor{white}
\centering
\begin{tabular}{>{\columncolor{MediumSpringGreen}}c|c|c|c}
\rowcolor{MediumSpringGreen}  & Day 1 & Day 2 & Day 3 \\
\hline
Subject 1&
\cellcolor{PeachPuff}A & \cellcolor{PeachPuff}C & \cellcolor{PeachPuff}B\\
\cline{2-4}
&\cellcolor{Honeydew}B & \cellcolor{Honeydew}A & \cellcolor{Honeydew}C\\
\cline{2-4}
&\cellcolor{PowderBlue}C & \cellcolor{PowderBlue}B & \cellcolor{PowderBlue}A\\
\hline
Subject 2&
\cellcolor{PeachPuff}B & \cellcolor{PeachPuff}A & \cellcolor{PeachPuff}C\\
\cline{2-4}
&\cellcolor{Honeydew}C & \cellcolor{Honeydew}B & \cellcolor{Honeydew}A\\
\cline{2-4}
&\cellcolor{PowderBlue}A & \cellcolor{PowderBlue}C & \cellcolor{PowderBlue}B\\
\hline
Subject 3&
\cellcolor{PeachPuff}C & \cellcolor{PeachPuff}B & \cellcolor{PeachPuff}A\\
\cline{2-4}
&\cellcolor{Honeydew}A & \cellcolor{Honeydew}C & \cellcolor{Honeydew}B\\
\cline{2-4}
&\cellcolor{PowderBlue}B & \cellcolor{PowderBlue}A & \cellcolor{PowderBlue}C\\
\end{tabular}
\end{table}
\end{document}
  • Excellent response! I modified your work some as posted below. Thank you so much for taking the time to help; your methods have really taught me a lot! – cstover Nov 21 '15 at 15:17
1

I accepted @Mico's answer as best because his provided me a template to get exactly what I wanted with very little added work. In particular, I tinkered with the colors, the vertical alignment of the row heads, and created a nice little legend thing with minipage.

\documentclass{article}
\usepackage[table,svgnames]{xcolor}
\usepackage{textcomp}%..............allows \textdegree
\usepackage{tikz}
\usepackage{minibox}

\newcommand{\degreeF}{\textdegree F\,}

\begin{document} 
\begin{center}
    \begin{minipage}[b][][t]{.5\linewidth}
        \vspace{0pt}
        \renewcommand{\arraystretch}{1.2}
        \arrayrulecolor{white}
        \centering
        \begin{tabular}{>{\columncolor{PaleGreen}}c|c|c|c}
        \rowcolor{PaleGreen}  & \textbf{Day 1} & \textbf{Day 2} & \textbf{Day 3} \\
        \hline
        &\cellcolor{Orange}A & \cellcolor{Orange}C & \cellcolor{Orange}B\\
        \cline{2-4}
        \textbf{Subject 1}&\cellcolor{WhiteSmoke}B & \cellcolor{WhiteSmoke}A & \cellcolor{WhiteSmoke}C\\
        \cline{2-4}
        &\cellcolor{Turquoise}C & \cellcolor{Turquoise}B & \cellcolor{Turquoise}A\\
        \hline
        &\cellcolor{Orange}B & \cellcolor{Orange}A & \cellcolor{Orange}C\\
        \cline{2-4}
        \textbf{Subject 2}&\cellcolor{WhiteSmoke}C & \cellcolor{WhiteSmoke}B & \cellcolor{WhiteSmoke}A\\
        \cline{2-4}
        &\cellcolor{Turquoise}A & \cellcolor{Turquoise}C & \cellcolor{Turquoise}B\\
        \hline
        &\cellcolor{Orange}C & \cellcolor{Orange}B & \cellcolor{Orange}A\\
        \cline{2-4}
        \textbf{Subject 3}&\cellcolor{WhiteSmoke}A & \cellcolor{WhiteSmoke}C & \cellcolor{WhiteSmoke}B\\
        \cline{2-4}
        &\cellcolor{Turquoise}B & \cellcolor{Turquoise}A & \cellcolor{Turquoise}C\\
        \end{tabular}
        \end{minipage}%
        \begin{minipage}[b][][t]{.25\linewidth}
        \vspace{0pt}
        \centering
        \framebox{
            \minibox{
            \\[-3mm]
            \tikz \draw [fill=Orange,draw=Black] (0,0) rectangle (3mm,3mm); 80\degreeF\\
            \tikz \draw [fill=WhiteSmoke,draw=Black] (0,0) rectangle (3mm,3mm); 72\degreeF\\
            \tikz \draw [fill=Turquoise,draw=Black] (0,0) rectangle (3mm,3mm); 80\degreeF}}
        \end{minipage}%
   \end{center}
   \end{document}

This yielded the output:

enter image description here

Many thanks, @Mico!

PS: I know the above is probably clumsy and not the best way at all, so anyone who wants to chime in and help me become a better TeXnician will earn an eternal debt from me. :)

  • ...modulo the typo in the legend, which I've since fixed. ^_^ – cstover Nov 21 '15 at 15:13
  • I knew my color choices were merely a rough guess. Glad you found some colors that suit your needs better! – Mico Nov 21 '15 at 15:27
  • @Mico - Au contraire! My wife (who the table is for) used the colors in the original screenshot and she agrees that your selection was more akin to what she'd originally put! Truthfully, the legend was the main reason for boldening the colors: It was harder to differentiate the colors among the legend when they were paler and so - when able - I erred on the side of bold. Nevertheless, I never would have known about the color names, etc., had it not been for your example, so I really can't thank you enough! – cstover Nov 21 '15 at 16:01

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.