我可以用图像填充 tikzposter 块吗?

\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass[a2paper,blockverticalspace=1cm,innermargin=9mm, colspace=9mm]{tikzposter}
\geometry{paperwidth=11in,paperheight=15in}

\begin{document}

\begin{columns}
 % FIRST column
\column{0.335}

\column{0.335}

\useblockstyle{TornOut}

\block[titleoffsety=3in,bodyoffsety=3in]{\textcolor{black}{Image inside}}{\includegraphics[width=3in]{flag}}

\block{\textcolor{black}{Image overrun}}{\includegraphics[width=5in]{flag}}

\end{columns}

\end{document}

在此处输入图片描述

答案1

是的,这是可能的。MWE 结合了来自不同地方的提示和一些努力。

\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass[a2paper,blockverticalspace=1cm,innermargin=9mm, colspace=9mm]{tikzposter}
\geometry{paperwidth=11in,paperheight=15in}

\newcommand*{\ClipSep}{0.4cm}%
\newbox\tmpbox

\newlength{\myhh}
\newlength{\myww}

\makeatletter
\tikzset{
    block filldraw/.style={% only the fill and draw styles
        draw, fill=yellow!20},
    block rect/.style={% fill, draw + rectangle (without measurements)
        block filldraw, rectangle},
    block/.style={% fill, draw, rectangle + minimum measurements
        block rect, minimum height=0.8cm, minimum width=6em},
    from/.style args={#1 to #2}{% without transformations
        above right={0cm of #1},% needs positioning library
        /utils/exec=\pgfpointdiff
            {\tikz@scan@one@point\pgfutil@firstofone(#1)\relax}
            {\tikz@scan@one@point\pgfutil@firstofone(#2)\relax},
        minimum width/.expanded=\the\pgf@x,
        minimum height/.expanded=\the\pgf@y}}
\makeatother

\defineblockstyle{TornPaper}{
    titlewidthscale=1, bodywidthscale=1, titlecenter,
    titleoffsetx=0pt, titleoffsety=0pt, bodyoffsetx=0pt, bodyoffsety=0pt,
    bodyverticalshift=-1.2cm, roundedcorners=0, linewidth=1.2pt,
    titleinnersep=1cm, bodyinnersep=1cm
}{
    \ifBlockHasTitle%
        \coordinate (topright) at (blocktitle.north east);
    \else
        \coordinate (topright) at (blockbody.north east);
    \fi%
    \settoheight{\myhh}{\usebox{\tmpbox}}
    \settowidth{\myww}{\usebox{\tmpbox}}
    \node[block rect, color=brown!!ivory, fill=brown!20,%
        line width=\blocklinewidth, drop shadow={shadow xshift=0.2cm, shadow yshift=-0.2cm,opacity=0.3}, %
        decorate, decoration={random steps,segment length=1.5cm,amplitude=0.1cm},
        path picture={\node at ([yshift=-.5\myhh,xshift=-.03\myww]blockbody.south) {\box\tmpbox};},
        fit={(blockbody.south west)(topright)}]  {\phantom{\copy\tmpbox}};%
}

\begin{document}

\begin{columns}
 % FIRST column - this is just for spacing to get my screenshot 
\column{0.335}

\column{0.335}% Width set relative to text width

\setbox\tmpbox=\hbox{\includegraphics[width=.639\textwidth]{flag}}

\useblockstyle{TornPaper}

\block[titleoffsety=3in,bodyoffsety=3in]{Testing}{\textcolor{white}{\textbf{This works}}}

\setbox\tmpbox=\hbox{\includegraphics[width=.939\textwidth]{lamp-down-low}}

\block{Testing}{\textcolor{white}{\huge\textbf{Wow!}}}

\end{columns}

\end{document}

在此处输入图片描述

相关内容