带遮阳篷的彩色盒子网格

带遮阳篷的彩色盒子网格

我怎样才能在 Latex 中重现这一现象?
在此处输入图片描述

答案1

虽然这不是一张海报,但也许这可以帮助您开始接近您想要的东西。这里并没有列出所有的细节。事实上,有些东西并不像您发布的图片中那样清晰(例如颜色名称在描述上方的对齐方式)。另外我是色盲;所以我对颜色设置的选择可能有点偏差。

\documentclass{article}
%% packages used for this MWE
\usepackage[margin=1in]{geometry}
\usepackage{tikz}
\usetikzlibrary{shadings}
%%----------------------------------------
\makeatletter
%% four macros to hold content material including the position.
\def\elsa@emo@title{}
\def\elsa@emo@attributes{}
\def\elsa@emo@research{}
\def\elsa@emo@position{(0,0)}
%% setting up keys:
\pgfkeys{/elsa/colorful/presentation/.cd,
  position/.code=\elsa@emo@position@code{#1},
  %%------------------------------
  color for background/.initial=black,
  color for title/.initial=black,
  color for attributes/.initial=black,
  color for research/.initial=black,
  %%------------------------------
  title/.store in=\elsa@emo@title,
  attributes/.store in=\elsa@emo@attributes,
  research/.store in=\elsa@emo@research,
}
%% a macro to access key values
\def\elsa@get#1{%%
  \pgfkeysvalueof{/elsa/colorful/presentation/#1}}

%% a boolean to control alignment of content in boxes
\newif\ifelsa@left@
%% a macro to examine the placement of the "card"
%% and accordingly set the alignment of the text 
%% which is in the "card"                        
\def\emo@extract@coordinates(#1,#2){%%
  \def\emo@x{#1}%%
  \def\emo@y{#2}}
%% determine the alignment of card content and position
%% of the node for the card.                           
\def\elsa@emo@position@code#1{%%
  \emo@extract@coordinates#1%%
  \ifnum\emo@x>0\relax
    \elsa@left@false
  \else
    \elsa@left@true
  \fi
  \def\elsa@emo@position{#1}%%
}

%% various paramenters to control placement
\newlength{\elsa@width}         \setlength{\elsa@width}{7.5cm}  
\newlength{\elsa@height}        \setlength{\elsa@height}{4cm} 
\newlength{\elsa@shadow@leg}    \setlength{\elsa@shadow@leg}{2.5cm}   
\newlength{\elsa@shadow@vertex} \setlength{\elsa@shadow@vertex}{.15cm}
\newlength{\elsa@hoffset}       \setlength{\elsa@hoffset}{2.0em}
\newlength{\elsa@voffset}       \setlength{\elsa@voffset}{1em}  

\def\emo@build@card@content{%%
  \def\emo@content{%%
    \begin{minipage}[t]{\dimexpr\elsa@width-\elsa@hoffset-1em}%%
      \ifelsa@left@
        \flushleft
      \else
        \flushright
      \fi
      \sffamily
      %% title
      \bgroup
        \color{\elsa@get{color for title}}%%
        \bfseries
        \scalebox{3.5}{\expandafter\uppercase\expandafter{\elsa@emo@title}}%%
      \egroup
      \par
      %% short
      \bgroup
        \color{\elsa@get{color for attributes}}%%
        \bfseries
        \expandafter\uppercase\expandafter{\elsa@emo@attributes}%%
      \egroup
      \par
      %% long
      \bgroup
        \color{\elsa@get{color for research}}%%
        \slshape\elsa@emo@research
      \egroup
    \end{minipage}}}

\def\emo@place@card@within@node{%%
  \node[inner sep=0pt,anchor=north west] at \elsa@emo@position {\emo@color@card};}

%%
\def\emo@color@card{%%
  \begin{tikzpicture}[anchor=center]
    \coordinate (lower left)  at (0,0);
    \coordinate (upper right) at (\elsa@width,\elsa@height);
    \useasboundingbox (lower left) rectangle (upper right);

    \coordinate (upper left)  at (lower left|-upper right);
    \coordinate (lower right) at (lower left-|upper right);

    \coordinate (up turned corner) at (\ifelsa@left@  \dimexpr\elsa@width-\elsa@shadow@vertex\relax  \else  \elsa@shadow@vertex  \fi, \elsa@shadow@vertex); 
    \coordinate (content anchor)   at (\ifelsa@left@  \dimexpr\elsa@hoffset\relax                    \else  \dimexpr\elsa@width-\elsa@hoffset\relax  \fi, \dimexpr\elsa@height-\elsa@voffset\relax);

    \coordinate (shadow base a)    at (\ifelsa@left@  \dimexpr\elsa@width-\elsa@shadow@leg\relax \else  \elsa@shadow@leg  \fi, 0);
    \coordinate (shadow base b)    at (\ifelsa@left@  \elsa@width \else 0 \fi, \elsa@shadow@leg);
    \coordinate (shadow vertex)    at (\ifelsa@left@  \dimexpr\elsa@width+\elsa@shadow@vertex\relax \else -\elsa@shadow@vertex\fi, -\elsa@shadow@vertex);
    \shadedraw[line width=-2pt,
               inner sep=0pt,
               outer sep=0pt,
               color=white,
               shading=bilinear interpolation,
               lower left=\ifelsa@left@  gray!90\else gray!05\fi,
               lower right=\ifelsa@left@ gray!05\else gray!90\fi,
               upper left=gray!90,
               upper right=gray!90,
               ] (shadow base a) -- (shadow base b) -- (shadow vertex) -- cycle;
    \fill[fill=\elsa@get{color for background}] (lower left) rectangle (upper right);
    \node[inner sep=0pt,
          anchor=\ifelsa@left@ north west\else north east\fi
         ] at (content anchor) {\emo@content};
  \end{tikzpicture}}

%%--------------------------------------------------------------------------------
%% macros for user interface:                                                     
%%--------------------------------------------------------------------------------
%% macro for placing individual color with attributes and research statement.     
\newcommand\emocard[1]{%%
  \pgfkeys{/elsa/colorful/presentation/.cd,#1}%%
  \emo@build@card@content
  \emo@place@card@within@node}

%% an environment to wrap all content.
\newenvironment{emofield}
  {%%'
    \begin{tikzpicture}[x=\dimexpr\elsa@width+0.5cm\relax,
                        y=\dimexpr\elsa@height+0.5cm\relax]
  }{%%'
    \end{tikzpicture}
  }

\makeatother
\setlength{\parindent}{0pt}
\pagestyle{empty}
\begin{document}

\begin{emofield}

  \emocard{%%
    position={(0,0)},
    color for background=red,
    color for title=red!50!black,
    color for attributes=red!60!black,
    color for research=red!70!black,
    title=red,
    attributes={Exciting, demands attention},
    research={Studies show that this color actually raises heart rate.},
    }

  \emocard{%%
    position={(1,0)},
    color for background=orange!70,
    color for title=orange!80!black,
    color for attributes=orange!60!black,
    color for research=orange!70!black,
    title=orange,
    attributes={Fun, ambition},
    research={Also an attention getter, this color is perfect for calls to action.},
    }

  \emocard{%%
    position={(0,-1)},
    color for background=yellow!60,
    color for title=yellow!90!black,
    color for attributes=yellow!60!black,
    color for research=yellow!70!black,
    title=yellow,
    attributes={happiness, optimism},
    research={Causes the release of serotonin.}
    }

  \emocard{%%
    position={(1,-1)},
    color for background=green,
    color for title=green!80!black,
    color for attributes=green!60!black,
    color for research=green!70!black,
    title=green,
    attributes={growth, nature},
    research={Also associated with money, this color is the easiest for the eye to process.}
    }

\end{emofield}

\end{document}

在此处输入图片描述

相关内容