如何更改 tikzposter 包中一个块的样式?

如何更改 tikzposter 包中一个块的样式?

我想只更改一个区块“目标”的样式,但同时我喜欢主题“沙漠”。我希望这个区块有黑色边框和背景颜色,就像我的海报标题一样。有什么想法可以管理它吗?!

\documentclass[25pt, a1papper, portrait]{tikzposter}
\usepackage[utf8]{inputenc}
\title{\parbox{\linewidth}{\centering dsfds sdfsfd}}
\author{fdssfa}
\date{\today}
\institute{fsdfs sdfdsfds}
\usepackage{blindtext}
\usepackage{comment}
\usetheme{Desert}

\begin{document}

\maketitle

\block{Introduction}
{
    \blindtext
}


\begin{columns}
    \column{0.4}
    {

     \colorlet{blocktitlebgcolor}{red}
    \colorlet{blockbodybgcolor}{blue}
     \colorlet{framecolor}{black}
    \useblockstyle{Basic}
    \block{Objectives}{\blindtext \vspace{2cm}

}}

    \column{0.6}{
    \block{Something else}{Here, \blindtext \vspace{4cm}}
    \note[
        targetoffsetx=-9cm,
        targetoffsety=-6.5cm,
        width=0.5\linewidth
        ]
        {e-mail \texttt{[email protected]}}}
\end{columns}

\begin{columns}
    \column{0.5}
    \block{A figure}
    {
        \begin{tikzfigure}

        \end{tikzfigure}
    }
    \column{0.5}
    \block{Description of the figure}{\blindtext}
\end{columns}
\block[titleleft,titleoffsetx=2em,titleoffsety=1em,bodyoffsetx=2em,
bodyoffsety=1em,titlewidthscale=.6, bodywidthscale=.8, roundedcorners=14,
linewidth=8mm, bodyinnersep=4em, titleinnersep=2em]
{Sample Block}{Text\\Text\\Text Text}
\end{document} 

答案1

我不完全确定你想要什么,因为你的标题似乎没有黑色框架,但也许这可以让你入门。你可以使用 定义一个新的块样式\defineblockstyle,这允许你根据需要设置块的特性。然后我将这个新块包装在一个\myblock命令中,该命令可用于创建特定样式的单个块。默认情况下,它会以“MyBlock”样式创建块,但它可以用于任何样式:

\myblock{title}{content}%           a block in the "MyBlock" style
\myblock[Envelope]{title}{content}% a block in the "Envelope" style

其次,我定义了“MyBlock”样式来执行我认为您想要的操作。有了这个,您的 MWE 会产生:

在此处输入图片描述

完整代码如下:

\documentclass[25pt, a1papper, portrait]{tikzposter}
\usepackage[utf8]{inputenc}
\title{\parbox{\linewidth}{\centering dsfds sdfsfd}}
\author{fdssfa}
\date{\today}
\institute{fsdfs sdfdsfds}
\usepackage{blindtext}
\usepackage{comment}
\usetheme{Desert}

\defineblockstyle{MyBlock}{% define a custom style for a block
    titlewidthscale=0.8, bodywidthscale=1, titlecenter,
    titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0pt, bodyoffsety=15mm,
    bodyverticalshift=15mm, roundedcorners=22, linewidth=5pt,
    titleinnersep=8mm, bodyinnersep=8mm
}{
    \draw[rounded corners=\blockroundedcorners, inner sep=\blockbodyinnersep,
          line width=\blocklinewidth, color=black,
          top color=titlebgcolor!90, bottom color=titlebgcolor!20!white,
          %fill=blockbodybgcolor
          ]
      (blockbody.south west) rectangle (blockbody.north east); %
    \ifBlockHasTitle%
        \draw[rounded corners=\blockroundedcorners, inner sep=\blocktitleinnersep,
          top color=titlebgcolor!90, bottom color=titlebgcolor!20!white,
          line width=\blocklinewidth, color=black, %fill=blocktitlebgcolor
          ]
      (blocktitle.south west) rectangle (blocktitle.north east); %
    \fi%
}
\newcommand\myblock[3][MyBlock]{\useblockstyle{#1}\block{#2}{#3}\useblockstyle{Basic}}



\begin{document}
\useblockstyle{Basic}

\maketitle

\block{Introduction}
{
    \blindtext
}


\begin{columns}
    \column{0.4}
    \myblock{Objectives}{% use custom block to define the objectives
      \blindtext \vspace{2cm}
     }

    \column{0.6}{
    \block{Something else}{Here, \blindtext \vspace{4cm}}
    \note[
        targetoffsetx=-9cm,
        targetoffsety=-6.5cm,
        width=0.5\linewidth
        ]
        {e-mail \texttt{[email protected]}}}
\end{columns}

\begin{columns}
    \column{0.5}
    \block{A figure}
    {
        \begin{tikzfigure}

        \end{tikzfigure}
    }
    \column{0.5}
    \block{Description of the figure}{\blindtext}
\end{columns}
\block[titleleft,titleoffsetx=2em,titleoffsety=1em,bodyoffsetx=2em,
bodyoffsety=1em,titlewidthscale=.6, bodywidthscale=.8, roundedcorners=14,
linewidth=8mm, bodyinnersep=4em, titleinnersep=2em]
{Sample Block}{Text\\Text\\Text Text}
\end{document}

相关内容