2

I am trying to draw a simple "array" data structure in Beamer using tabular. I would like to color some of the cells blue. Here is my M(N)WE.

\documentclass{beamer}

\usepackage[table]{xcolor}
\begin{document}

\begin{frame}
\frametitle{test}

\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\cellcolor{blue!25}A&
\cellcolor{blue!25}B&
\cellcolor{blue!25}C&
B&
A&
B&
C\\
\hline
\end{tabular}
\end{frame}

\end{document}

This doesn't compile. How should it be done?

The first problem is

! LaTeX Error: Option clash for package xcolor.

10

The "problem" is, that beamer automatically loads the xcolor-package. But luckily you can simply pass your desired option by using \documentclass[xcolor=table]{beamer}

enter image description here

\documentclass[xcolor=table]{beamer}

\begin{document}

\begin{frame}
\frametitle{test}

\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\cellcolor{blue!25}A&
\cellcolor{blue!25}B&
\cellcolor{blue!25}C&
B&
A&
B&
C\\
\hline
\end{tabular}
\end{frame}

\end{document}

reply to @felix's comment

Is it just an illusion or are the letter positions high in their cells? They don't seem to be in the middle.

I think that might be an illusion.

enter image description here

| improve this answer | |
  • Thanks! I now get only "LaTeX Font Warning: Font shape `OT1/cmss/m/n' in size <4> not available (Font) size <5> substituted on input line 18." – felix Jun 5 '14 at 16:36
  • Is it just an illusion or are the letter positions high in their cells? They don't seem to be in the middle. – felix Jun 5 '14 at 16:40
  • Concerning your font size problem: For me, this warning can be ignored, but if you want to get rid of it, have a look at texblog.net/latex-archive/uncategorized/beamer-warnings which basically suggest to include \let\Tiny=\tiny in the preamble – samcarter_is_at_topanswers.xyz Jun 5 '14 at 16:41
  • 1
    I am not sure it is an illusion in fact. I zoomed in a long way and there is clearly more space below than above the letters. – felix Jun 5 '14 at 16:52
  • care to post a screenshot? or even open a new question? – samcarter_is_at_topanswers.xyz Jun 5 '14 at 16:56

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.