[Tex/LaTex] How to color text and fill cells with color in a table/subtable environment

errorsposters

I have a question related to making posters using LaTeX. I am using the following website for the poster. Everything is OK, but I am stuck at a point where I want to insert 2 tables next to each other. After googling, I discovered how to do it (using subtables).

However, I get a bunch of errors (see below) when I compile it. I think that my table code is fine (see below), but I don't know why I get that error. I can live with these errors as they don't affect the final output.

(/usr/share/texmf-texlive/tex/latex/amsfonts/umsb.fd)
! Undefined control sequence.
<argument>  \subtable 
                      { \begin {tabular}{|c|c|c|} \par \multicolumn {3}{c}{\...
l.226  }

? 
! Missing $ inserted.
<inserted text> 
                $
l.226  }

? 
! Extra }, or forgotten $.
<template> \unskip \hfil }
                          \hskip \tabcolsep \hskip -.5\arrayrulewidth \vrule...
l.226  }

? 

! Missing $ inserted.
<inserted text> 
                $
l.226  }

? ! Missing } inserted.
<inserted text> 
                }
l.226  }

My main problem is after inserting the tables, I want to color the cells. To this end, I am using xcolor package, but somehow:

  • it fails to provide the colors
  • it gives me errors

Basically, I want to:

  • color letters
  • fill cells of tables with different colors

(I got the commands from the xcolor manual)

Can any one please help me with this?

Any pointers or help is greatly appreciated (I have inserted comments where I get errors, please see: \rowcolor right above the tabular environment).

Edit:

As @caramdir pointed out that my code was not well written I have hereby tried to make a reproducible example (it is still long because of some of the code already existing the sample poster). I hope this will help you understand my problem better. I have also included the package subfigure. But nothing changed, I still get error messages before. I am not sure what's going on because the table code is similar to what I use in writing papers.

The code does compile to .dvi, but with a lot of errors (I just press enter to skip them). But output dvi file is good. When I use xcolors and copy custom commands from the manual. They don't work either. (I get inline text instead of seeing the color)

Thanks again for helping me. I am sorry if something is missing. I am not a latex expert, but I am trying hard.

\documentclass[landscape,a0b,final]{a0poster}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pstricks,pst-grad}
\usepackage{amsmath, amsthm, amssymb}
\setlength{\columnsep}{3cm}
\setlength{\columnseprule}{2mm}
\setlength{\parindent}{0.0cm}

\newenvironment{poster}{
  \begin{center}
    \begin{minipage}[c]{0.98\textwidth}
}{
    \end{minipage} 
  \end{center}
}


\newenvironment{pcolumn}[1]{
  \begin{minipage}{#1\textwidth}
    \begin{center}
}{
    \end{center}
  \end{minipage}
}

\begin{document}

\begin{poster}
  \begin{center}
    \begin{pcolumn}{0.98}
      \Large
      \begin{center}
        \textbf{Parallels Table}
      \end{center}

      \vspace{0.5cm}
             {\Large
           \noindent\makebox[\textwidth]{
         \subtable{
           %\rowcolors{1}{LightBlue1}{DeepPink1} %Gives me errors

                   \begin{tabular}{|c|c|c|}    
                     \multicolumn{3}{c}{\textbf{$Data_1$}} \\
                 \hline
                     \textbf{ID} & \textbf{$Type_1$} & \textbf{$Type_2$} \\
             $1$ & $I_{11}$ & $I_{12}$ \\
                     \hline
           \end{tabular}
         }

                 \hspace{2cm}
         \subtable{
           %\rowcolors{1}{LightBlue}{DeepSkyBlue} %Gives me errors

                   \begin{tabular}{|c|c|c|}
                 \multicolumn{3}{c}{\textbf{$Data_2$}} \\
                     \hline
                     \textbf{ID} & \textbf{$Type_1$} & \textbf{$Type_2$} \\
             $G$ & $n_{G1}$ & $n_{G2}$ \\
                     \hline
           \end{tabular}
         }
               }
             }

    \end{pcolumn}
  \end{center}
\end{poster}
\end{document}

Best Answer

Here is your example as a running document. Coloring tables needs a \usepackage[table,<named color list(s)>]{xcolor}. Next time you shouldn't use the a0poster documentclass. It is easier to find errors with simple classes.

\documentclass[landscape,a0b,final]{a0poster}
\usepackage{subfig}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage[table,dvipsnames,svgnames,x11names]{xcolor}
\setlength{\columnsep}{3cm}
\setlength{\columnseprule}{2mm}
\setlength{\parindent}{0.0cm}

\newenvironment{poster}{%
  \begin{center}
    \begin{minipage}[c]{0.98\textwidth}
}{%
    \end{minipage} 
  \end{center}
}
\newenvironment{pcolumn}[1]{%
  \begin{minipage}{#1\textwidth}
    \begin{center}
}{%
    \end{center}
  \end{minipage}
}

\begin{document}

\begin{poster}
  \begin{center}
    \begin{pcolumn}{0.98}
      \Large
        \textbf{Parallels Table}

      \vspace{0.5cm}
        \rowcolors{1}{LightBlue1}{DeepPink1} %Gives me errors
        \begin{tabular}{|c|c|c|}    
          \multicolumn{3}{c}{\textbf{$Data_1$}} \\\hline
          \textbf{ID} & \textbf{$Type_1$} & \textbf{$Type_2$} \\
             $1$ & $I_{11}$ & $I_{12}$ \\\hline
        \end{tabular}
        \hspace{2cm}
        \rowcolors{1}{LightBlue}{DeepSkyBlue} %Gives me errors
        \begin{tabular}{|c|c|c|}
          \multicolumn{3}{c}{\textbf{$Data_2$}} \\\hline
          \textbf{ID} & \textbf{$Type_1$} & \textbf{$Type_2$} \\
           $G$ & $n_{G1}$ & $n_{G2}$ \\\hline
        \end{tabular}
    \end{pcolumn}
  \end{center}
\end{poster}

\end{document}

enter image description here

Related Question