使用 baposter 的表格颜色不好

使用 baposter 的表格颜色不好

我正在尝试为海报 (baposter) 中的表格单元格分配特定颜色。不幸的是,它们在 pdf 中重现不同。由于它们必须与我的图表的颜色相匹配,所以我需要精确指定的颜色。在我的演示文稿 (beamer 类) 中,使用相同的代码可以很好地重现颜色。因此,我认为表格和 \cellcolor 的使用没有问题。

请参阅下面的工作示例:

\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

\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{Comfortable}\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}

此测试示例中的颜色应为黑色、白色、红色、绿色、蓝色。虽然白色在 PDF 中似乎保持白色,但黑色呈灰色,红色、绿色和蓝色太暗。它们似乎在编译期间发生了变化。

我还尝试使用 RGB 而不是 HTML 来指定测试颜色。由于这对 pdf 中的颜色没有影响(完全是同样的错误),我猜它们指定正确(此外它们在 beamer 类中运行良好)。似乎只有使用 baposter 时才会发生一些奇怪的事情,从而改变我的颜色……

为了让您对改变的颜色有所了解,我使用 gimp 中的颜色选择器测量了 pdf 中的颜色,它返回 RGB 值(在 LaTeX 中称为 HTML)并将它们作为注释添加到应用规范的后面。

任何想法都值得赞赏!

答案1

可以通过确保在序言中明确声明颜色模型来纠正这个问题,使用\setcolormodel{HTML}

虽然在本例中似乎没有什么区别,但xcolor手册(表 2,第 10 页)明确指示colortbl应将作为选项传递给xcolor。但是,由于该类基于,因此baposter会加载,因此必须在声明文档类之前使用。在下面修改后的 MWE 中,我扩展了它以提供使用和定义的颜色名称,因此:。xcolorpgf\PassOptionsToPackage{table}{xcolor}baposterdvipsnamessvgnames\PassOptionsToPackage{table,dvipsnames,svgnames}{xcolor}

这两个小修改提供了正确的颜色,以及使用扩展颜色定义范围的机会 - 无需破解类baposter

在此处输入图片描述

代码如下:

\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}

几个简短的题外话:自 2011 年以来\headerbox已被 取代\posterbox,尽管向后兼容性仍然允许使用它。我在测试中惊讶地发现,即使颜色是在 HTML 中指定的, 也能启用正确的颜色。我猜这与将 HTML 转换为 rgb\selectcolormodel{rgb}有关。xcolor

答案2

(注意:这是不好的做法,所以不要这样做,但如果您正在进一步调查问题,这可能会有所帮助。)

我也遇到过这个问题。即使我选择用 CMYK 表示颜色,颜色也会出现问题。为了解决这个问题,我替换了以下行

\RequirePackage[cmyk]{xcolor}

与线

\RequirePackage[usenames,dvipsnames]{xcolor}

在 baposter.cls 文件中,颜色恢复正常(现在我可以使用更多颜色名称)。

相关内容