如何更改 tikzposter 中单个块的框架颜色?

如何更改 tikzposter 中单个块的框架颜色?

使用 时,block可以更改framecolor单个 周围线条的颜色吗?blocktikzposter

如果是的话,怎么办?我没找到。

的背景颜色blockblockbodybgcolor很简单单独改变,所以感觉奇怪,framecolor应该是不同的。

先感谢您!

答案1

这取决于使用的块样式,请参阅文件tikzposterBlockstyles.tex。在某些样式中,您会发现color=framecolor,在其他样式中color=blocktitlebgcolor。在Envelope它的中blocktitlebgcolor,所以你需要

\colorlet{blocktitlebgcolor}{<colour spec>}

答案2

我认为发生的情况是框架的默认线宽太窄而看不到颜色变化。

用 定义一个blockstyle\blockstyle{blockstylename}我使用了\blockstyle{myblockstyle}。为此blockstyle,将 添加到\draw命令中line width = x pt,其中x pt是块框架的所需线宽。我添加了line width=10pt。用 设置后面的块的样式。然后,在用 给出块规范之前,立即\useblockstyle{myblockstyle}用 声明所需的framecolor,比如洋红色。\colorlet{framecolor}{magenta}\block

我从@Torbjørn T. 对你上一个问题的回答中借用了代码,tikzposter 中的不同块高度,制作 MWE。它给出了以下结果,创建一个带有洋红色框架的块,另一个带有青色框架的块。

enter image description here

这是代码:

%From https://tex.stackexchange.com/a/443206/
\documentclass[
  usenames,
  dvipsnames,
  a2paper,
  subcolspace = 3 mm,
  colspace = 3 mm,
  landscape,
  innermargin = 3 mm,
  margin = 7 mm,
%  blockhorizontalspace = 5 mm, % this is not a valid option, doesn't do anything
  blockverticalspace = 5 mm,
  25 pt]{tikzposter}


\usetheme{Envelope} % See Section 5 (Rätt okej!)
\usecolorstyle[colorPalette=BrownBlueOrange]{Germany}

\tikzposterlatexaffectionproofoff

\begin{document}

\makeatletter
    \setlength{\TP@blocktop}{.495\textheight}
\makeatother

\settitle{ }
\colorlet{blockbodybgcolor}{MidnightBlue!100}
\colorlet{blockbodyfgcolor}{white} % color of text, no need for \color{white} everywhere


\defineblockstyle{myblockstyle}{
titlewidthscale=0.9, bodywidthscale=1,titleleft,
titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0mm, bodyoffsety=15mm,
bodyverticalshift=10mm, roundedcorners=5,
titleinnersep=6mm, bodyinnersep=1cm
}{
\draw[color=framecolor, fill=blockbodybgcolor, line width=10pt,  %<- added line width=10pt
rounded corners=\blockroundedcorners] (blockbody.south west)
rectangle (blockbody.north east);
\ifBlockHasTitle
\draw[color=framecolor, fill=blocktitlebgcolor, line width=10pt,  %<- added line width=10pt
rounded corners=\blockroundedcorners] (blocktitle.south west)
rectangle (blocktitle.north east);
\fi
}

\useblockstyle{myblockstyle}
\begin{columns}
    \column{0.5}
    \colorlet{framecolor}{magenta}                                %<- declare the frame color
    \block[bodyoffsetx = 0 mm,
           bodyoffsety=-2cm,
           bodyverticalshift = 0 mm,
           bodyinnersep = 3 mm,
           linewidth=10pt,        %<- need this for spacing between test2a and test2b blocks 
           titleinnersep = 0em,
           roundedcorners=0]{}{\raggedright\fontsize{60pt}{60pt}\selectfont Test1a}

    \column{0.5}
    \colorlet{framecolor}{cyan}                                    %<- declare the frame color
    \block[bodyoffsetx = 0 mm,
           bodyoffsety=-2cm,
           bodyverticalshift = 0 mm,
           bodyinnersep = 3 mm,
           titleinnersep = 0em,
           roundedcorners=0]{}{\raggedright \fontsize{60pt}{60pt}\selectfont Test1b}
\end{columns}

\end{document} 

相关内容