I would like to represent the construction of a house of cards, probably in tikz. Before creating my own, has anyone done anything similar?
[Tex/LaTex] How to represent a house of cards
cardstikz-pgf
Related Solutions
How about this 15-minute mockup (it's far from perfect, but quite ready to be turned into a reusable command):
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pifont}
\begin{document}
\pgfmathsetmacro{\cardwidth}{5}
\pgfmathsetmacro{\cardheight}{8}
\newcommand{\stripcolor}{lime}
\pgfmathsetmacro{\stripwidth}{0.7}
\pgfmathsetmacro{\strippadding}{0.1}
\newcommand{\striptext}{INTER ARMA \ding{74}}
\pgfmathsetmacro{\textpadding}{0.3}
\newcommand{\topcaption}{LATIN}
\newcommand{\topcontent}{\textit{''Inter Arma Enim Silent Leges''}}
\newcommand{\bottomcaption}{Inter Arma}
\newcommand{\bottomcontent}{In times of war, the law falls silent.\\ \tikz{\fill[even odd rule] (0,0) circle (0.3) (-0.2,-0.2) rectangle (0.2,0.2);}}
\pgfmathsetmacro{\ruleheight}{0.3}
\begin{tikzpicture}
\draw[rounded corners=0.2cm] (0,0) rectangle (\cardwidth,\cardheight);
\fill[\stripcolor,rounded corners=0.1cm] (\strippadding,\strippadding) rectangle (\strippadding+\stripwidth,\cardheight-\strippadding) node[rotate=90,above left,black,font=\LARGE] {\striptext};
\node[text width=(\cardwidth-\strippadding-\stripwidth-2*\textpadding)*1cm,below right] at (\strippadding+\stripwidth+\textpadding,\cardheight-\textpadding)
{\LARGE \topcaption}\\
\topcontent\\
\tikz{\fill (0,0) rectangle (\cardwidth-\strippadding-\stripwidth-2*\textpadding,\ruleheight);}\\
{\LARGE \bottomcaption}\\
\bottomcontent\\
};
\end{tikzpicture}
\end{document}
I used the pifont
package for the star symbol (\ding{74}
). It has also the other symbols depicted in your photograph, have a look here.
Edit 1: Now with a rotated symbol, and more options are set with keys:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pifont}
\usepackage{graphicx}
\begin{document}
\pgfmathsetmacro{\cardroundingradius}{4mm}
\pgfmathsetmacro{\striproundingradius}{3mm}
\pgfmathsetmacro{\cardwidth}{5}
\pgfmathsetmacro{\cardheight}{8}
\newcommand{\stripcolor}{cyan}
\pgfmathsetmacro{\stripwidth}{1.2}
\pgfmathsetmacro{\strippadding}{0.1}
\newcommand{\striptext}{INTER ARMA \rotatebox[origin=c]{-90}{\ding{49}}}
\pgfmathsetmacro{\textpadding}{0.3}
\newcommand{\topcaption}{LATIN}
\newcommand{\topcontent}{\textit{''Inter Arma Enim Silent Leges''}}
\newcommand{\bottomcaption}{Inter Arma}
\newcommand{\bottomcontent}{In times of war, the law falls silent.\\ \tikz{\fill[even odd rule] (0,0) circle (0.3) (-0.2,-0.2) rectangle (0.2,0.2);}}
\pgfmathsetmacro{\ruleheight}{0.1}
\newcommand{\stripfontsize}{\Huge}
\newcommand{\captionfontsize}{\LARGE}
\newcommand{\textfontsize}{\large}
\begin{tikzpicture}
\draw[rounded corners=\cardroundingradius] (0,0) rectangle (\cardwidth,\cardheight);
\fill[\stripcolor,rounded corners=\striproundingradius] (\strippadding,\strippadding) rectangle (\strippadding+\stripwidth,\cardheight-\strippadding) node[rotate=90,above left,black,font=\stripfontsize] {\striptext};
\node[text width=(\cardwidth-\strippadding-\stripwidth-2*\textpadding)*1cm,below right,inner sep=0] at (\strippadding+\stripwidth+\textpadding,\cardheight-\textpadding)
{ {\captionfontsize \topcaption}\\
{\textfontsize \topcontent}\\
\tikz{\fill (0,0) rectangle (\cardwidth-\strippadding-\stripwidth-2*\textpadding,\ruleheight);}\\
{\captionfontsize \bottomcaption}\\
{\textfontsize \bottomcontent}\\
};
\end{tikzpicture}
\end{document}
If the rotated symbol is too big, you may add some "don't size" modifier like \large
inside the rotatebox
before the \ding{n}
.
Pgfplots has a couple of helper methods which do the job - and these methods are mostly independent of any axis. The only required things are the text labels and the styles for the individual images.
Here is a short draft which might do what you want:
\documentclass{article}
\usepackage{pgfplots}
% argument #1: any options
\newenvironment{customlegend}[1][]{%
\begingroup
% inits/clears the lists (which might be populated from previous
% axes):
\csname pgfplots@init@cleared@structures\endcsname
\pgfplotsset{#1}%
}{%
% draws the legend:
\csname pgfplots@createlegend\endcsname
\endgroup
}%
% makes \addlegendimage available (typically only available within an
% axis environment):
\def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\begin{customlegend}[legend entries={$a$,$e^x$,C,$d$}]
\addlegendimage{red,fill=black!50!red,area legend}
\addlegendimage{red,fill=black!50!red,sharp plot}
\addlegendimage{red,fill=black!50!red,mark=*,sharp plot}
\addlegendimage{red,fill=black!50!red,ybar,ybar legend}
\end{customlegend}
\end{tikzpicture}
\end{document}
The different \addlegendimage
styles are a little bit ... inconsistent, but I wanted to experiment if they work. I guess that mesh legend
might produce problems, so stick to the simpler ones...
Best Answer
Here is a version (more faithful to the original post) without lines at the bottom and much more. You only need to say
See the examples in
What could this be good for? Oh, of course!