I am definitely unfamiliar with both beamer
and tikz
(do not quite get what the \only
are supposed to do) but perhaps this could go in the direction you want:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{chains}
\newcounter{count}
% helper macro:
\long\def\GobToSemiColon #1;{}
\newcommand\myPicture{
\begin{tikzpicture}
\begin{scope}[start chain = going below]
\ifnum\value{count}<1 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>3 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is between
1 and 3};
\ifnum\value{count}>-1 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only when counter is
negative};
\ifnum\value{count}<100 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>200 \expandafter\GobToSemiColon\fi
\node[draw, rectangle, on chain] {display only if counter is between
100 and 200};
\ifnum\value{count}<3 \expandafter\GobToSemiColon\fi
\ifnum\value{count}>20 \expandafter\GobToSemiColon\fi
\node[draw, circle, on chain] {only when counter is in the range 3 to 20};
\end{scope}
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\only{\setcounter{count}{-3}\myPicture}
\only{\setcounter{count}{105}\myPicture}
\only{\setcounter{count}{39}\myPicture}
\only{\setcounter{count}{2}\myPicture}
\only{\setcounter{count}{5}\myPicture}
\end{frame}
\end{document}
This problem is corrected by ensuring that the colour model is explicitly declared in the preamble, using \setcolormodel{HTML}
.
Although it does not appear to make a difference in this instance, the xcolor
manual (table 2, p10) specifically instructs that colortbl
should be passed as an option to xcolor
. However, the baposter
class loads xcolor
, since it is based on pgf
, so it is necessary to use \PassOptionsToPackage{table}{xcolor}
before the declaration of the baposter
document class. In the modified MWE below, I extended this to make provision for using colour names defined using dvipsnames
and svgnames
, thus: \PassOptionsToPackage{table,dvipsnames,svgnames}{xcolor}
.
These two small modifications provide the correct colours, and the opportunity to use an extended range of color definitions - no need to hack the baposter
class.
The code is:
\PassOptionsToPackage{table,dvipsnames,svgnames}{xcolor} %<-- Pass colortbl and defined colours to xcolor
\documentclass[a0paper,portrait]{baposter}
\usepackage{relsize} % Used for making text smaller in some places
%\usepackage{color, colortbl} % define own fancy colours
\graphicspath{{figures/}} % Directory in which figures are stored
\selectcolormodel{HTML} %<-- Add colour model defintion
\definecolor{VeryCold}{HTML}{000000} % becomes 231F20 in the pdf
\definecolor{Cold}{HTML}{FFFFFF} % stays FFFFFF in the pdf
\definecolor{Cool}{HTML}{FF0000} % becomes ED1C24 in the pdf
\definecolor{SlightlyCool}{HTML}{00FF00} % becomes 00A650 in the pdf
\definecolor{Comfortable}{HTML}{0000FF} % becomes 2E3192 in the pdf
%\definecolor{Comfortable}{RGB}{00, 00, 255} % no difference so the method to define the colors should be fine
\begin{document}
\background{ % Set the background to an image (background.pdf)
\begin{tikzpicture}[remember picture,overlay]
\draw (current page.north west)+(-2em,2em) node[anchor=north west]
%{\includegraphics[height=0.0852\textheight, width=0.9842\textwidth]{backgroundBlau}}; % 0.968
{ };
\end{tikzpicture}
}
\begin{poster}{
grid=false,
borderColor=Cold, % Border color of content boxes
headerColorOne=Cold, % Background color for the header in the content boxes (left side)
headerColorTwo=Cold, % Background color for the header in the content boxes (right side)
headerFontColor=Comfortable, % Text color for the header text in the content boxes
boxColorOne=white, % Background color for the content in the content boxes
headerfont=\Large\sf\bf, % Font modifiers for the text in the content box headers
textborder=rectangle,
background=user,
headerborder=open, % Change to closed for a line under the content box headers
boxshade=plain
}
{}
%
{\sf\bf \textsmaller[1]{\textcolor{white}{ text }}} % Poster title
{\vspace{0.1em} text \\ % Author names
{\smaller text }} % Author email addresses
%{\includegraphics[scale=0.55]{Uni_Logo-Grundversion_E1_A4_CMYK}} % University/lab logo
\headerbox{Introduction}{name=introduction,column=0,row=0}{
\textsmaller[1]{
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
\rowcolor{Cold}\multicolumn{1}{|c|}{PET} & \multicolumn{1}{|c|}{eption} & \multicolumn{1}{|c|}{ Stress} & \multicolumn{1}{|c|}{Color} \\ \hline \hline
< 4 & ld & ress & \cellcolor{VeryCold}\\ \hline
4 - 8 & old & sts & \cellcolor{Cold} \\ \hline
8 - 13 & ol & ss & \cellcolor{Cool} \\ \hline
13 - 18 & ool & s & \cellcolor{SlightlyCool} \\ \hline
18 - 23 & e & st & \cellcolor{Comfortable} \\ \hline
\hline
\end{tabular}
\end{center}
}
}
\end{poster}
\end{document}
A couple of brief off-topic points: \headerbox
was replaced by \posterbox
since 2011, although backwards compatibility still allows it to be used. I was surprised to discover in my testing that the correct colours were also enabled by \selectcolormodel{rgb}
, even when the colours were specified in HTML. I guess this is related to xcolor
converting HTML to rgb.
Best Answer
Either use \leavevmode or \textcolor