1

I'd like to create the attached picture using TikZ, or any other vector graphics package. However, I have no idea how to draw the arrows and align the text.

Would really appreciate your help :)

Picture I'd like to create in Latex

  • In order to get things to line up you should measure the height of the corresponding \parbox and tabulars first. – John Kormylo Jun 5 '16 at 15:06
4

This should get you started.

I was getting unexpected results from [text height] and [minimum height] so I put both fields into saveboxes.

It should be noted that for rectangles one can simply use \node[draw]. Also, when computing the width of multiple nodes don't forget to account for inner sep=.333em (default).

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\newsavebox{\boxA}
\newsavebox{\boxB}

\begin{document}

\savebox{\boxA}{\begin{tabular}{@{}lr@{}}
\multicolumn{2}{c}{Recycling}\\
\multicolumn{2}{c}{25.0 Mil Mg}\\
Bio waste & 3.8\\
Garden Residues & 3.9\\
Glass & 3.6\\
Paper & 7.9\\
Plastics & 4.6
\end{tabular}}%

\savebox{\boxB}{\parbox[c][\dimexpr \ht\boxA+\dp\boxA][t]{1.5cm}%
{\centering\strut Landfill 4.0\\ Mil Mg}}%

\begin{tikzpicture}
\node (A) {\usebox{\boxA}};
\draw (A.north west) -- (A.south west) -- ($(A.south)+(0,-1)$) -- (A.south east) -- (A.north east) -- cycle;
\node (B) [right] at (A.east) {\usebox{\boxB}};
\draw (B.north west) -- (B.south west) -- ($(B.south)+(0,-1)$) -- (B.south east) -- (B.north east) -- cycle;
\end{tikzpicture}

\end{document}

demo

0

There is no good reason to use this method. I post it as an intellectual curiosity. That is, it is an experiment with coffins.

The code is as long as it is because there is, as far as I can tell, no built in way to draw rules around or within coffins, making use of their handles, alignment and so on.

The result is pretty good, I think, but the code is excessive in the extreme.

coffin waste

\documentclass{article}
\usepackage{xcoffins,tikz}
\usetikzlibrary{tikzmark,calc}
\ExplSyntaxOn
\dim_new:N \l_waste_rule_dim
\dim_set:Nn \l_waste_rule_dim { .4pt }
\tl_new:N \l_waste_colour_tl
\tl_set:Nn \l_waste_colour_tl { black }
\tl_new:N \l_waste_tmpa_tl
\tl_new:N \l_waste_tmpb_tl
\tl_new:N \l_waste_tmpc_tl
\tl_new:N \l_waste_tmpd_tl
\cs_new_protected:Nn \coffin_attach_rule:Nnnnnnnnn
{
  \vcoffin_set:Nnn \l_tmpa_coffin { #8 }
  {
    \dim_zero:N \parindent
    \color { \l_waste_colour_tl }
    \rule { #8 } { #9 }
  }
  \coffin_attach:NnnNnnnn #1 { #2 } { #3 } \l_tmpa_coffin { #4 } { #5 } { #6 } { #7 }
}
\cs_new_protected:Nn \coffin_join_rule:Nnnnnnnnn
{
  \vcoffin_set:Nnn \l_tmpa_coffin { #8 }
  {
    \dim_zero:N \parindent
    \color { \l_waste_colour_tl }
    \rule { #8 } { #9 }
  }
  \coffin_join:NnnNnnnn #1 { #2 } { #3 } \l_tmpa_coffin { #4 } { #5 } { #6 } { #7 }
}
\cs_generate_variant:Nn \coffin_attach_rule:Nnnnnnnnn { NVVVVVVVn , NVVVVVVnV }
\cs_generate_variant:Nn \coffin_join_rule:Nnnnnnnnn { NVVVVVVVn , NVVVVVVnV }
\NewDocumentCommand \CoffinRuleH { s m O { b , l } o D () { 0pt, 0pt } o O { \l_waste_rule_dim } o }
{
  \IfValueT { #8 }
  {
    \tl_set:Nn \l_waste_colour_tl { #8 }
  }
  \IfNoValueTF { #6 }
  {
    \dim_set:Nn \l_tmpa_dim { \coffin_wd:N #2 }
  }
  {
    \dim_set:Nn \l_tmpa_dim { #6 }
  }
  \clist_set:Nn \l_tmpa_clist { #3 }
  \clist_pop:NN \l_tmpa_clist \l_waste_tmpa_tl
  \clist_pop:NN \l_tmpa_clist \l_waste_tmpb_tl
  \IfNoValueTF { #4 }
  {
    \tl_set:NV \l_waste_tmpc_tl \l_waste_tmpa_tl
    \tl_set:NV \l_waste_tmpd_tl \l_waste_tmpb_tl
  }
  {
    \clist_set:Nn \l_tmpa_clist { #3 }
    \clist_pop:NN \l_tmpa_clist \l_waste_tmpc_tl
    \clist_pop:NN \l_tmpa_clist \l_waste_tmpd_tl
  }
  \clist_set:Nn \l_tmpa_clist { #5 }
  \clist_pop:NN \l_tmpa_clist \l_tmpb_dim
  \clist_pop:NN \l_tmpa_clist \l_tmpc_dim
  \IfBooleanTF { #1 }
  {
    \coffin_join_rule:NVVVVVVVn #2 \l_waste_tmpa_tl \l_waste_tmpb_tl \l_waste_tmpc_tl \l_waste_tmpd_tl \l_tmpb_dim \l_tmpc_dim \l_tmpa_dim { #7 }
  }
  {
    \coffin_attach_rule:NVVVVVVVn #2 \l_waste_tmpa_tl \l_waste_tmpb_tl \l_waste_tmpc_tl \l_waste_tmpd_tl \l_tmpb_dim \l_tmpc_dim \l_tmpa_dim { #7 }
  }
}
\NewDocumentCommand \CoffinRuleV { s m O { b , l } o D () { 0pt, 0pt } o O { \l_waste_rule_dim } o }
{
  \IfValueT { #8 }
  {
    \tl_set:Nn \l_waste_colour_tl { #8 }
  }
  \IfNoValueTF { #6 }
  {
    \dim_set:Nn \l_tmpa_dim { \coffin_ht:N #2 + \coffin_dp:N #2 }
  }
  {
    \dim_set:Nn \l_tmpa_dim { #6 }
  }
  \clist_set:Nn \l_tmpa_clist { #3 }
  \clist_pop:NN \l_tmpa_clist \l_waste_tmpa_tl
  \clist_pop:NN \l_tmpa_clist \l_waste_tmpb_tl
  \IfNoValueTF { #4 }
  {
    \tl_set:NV \l_waste_tmpc_tl \l_waste_tmpa_tl
    \tl_set:NV \l_waste_tmpd_tl \l_waste_tmpb_tl
  }
  {
    \clist_set:Nn \l_tmpa_clist { #3 }
    \clist_pop:NN \l_tmpa_clist \l_waste_tmpc_tl
    \clist_pop:NN \l_tmpa_clist \l_waste_tmpd_tl
  }
  \clist_set:Nn \l_tmpa_clist { #5 }
  \clist_pop:NN \l_tmpa_clist \l_tmpb_dim
  \clist_pop:NN \l_tmpa_clist \l_tmpc_dim
  \IfBooleanTF { #1 }
  {
    \coffin_join_rule:NVVVVVVnV #2 \l_waste_tmpa_tl \l_waste_tmpb_tl \l_waste_tmpc_tl \l_waste_tmpd_tl \l_tmpb_dim \l_tmpc_dim { #7 } \l_tmpa_dim
  }
  {
    \coffin_attach_rule:NVVVVVVnV #2 \l_waste_tmpa_tl \l_waste_tmpb_tl \l_waste_tmpc_tl \l_waste_tmpd_tl \l_tmpb_dim \l_tmpc_dim { #7 } \l_tmpa_dim
  }
}
\ExplSyntaxOff
\newlength\mytotalwidth
\setlength\mytotalwidth{\linewidth}
\NewCoffin\maincoffin
\NewCoffin\nextcoffin
\NewCoffin\holdcoffin
\begin{document}
\SetVerticalCoffin\maincoffin{.6\mytotalwidth}
{%
  \centering Municipal Solid Waste\par 46.5 Mil.\ Mg
}
\CoffinRuleH*\maincoffin[t,hc](.1\mytotalwidth,\baselineskip)[\mytotalwidth]
\CoffinRuleH*\maincoffin[b,hc](0pt,-\baselineskip)[\mytotalwidth]
\SetVerticalCoffin\holdcoffin{.4\mytotalwidth}
{%
  \centering Household waste separate collection
}
\SetVerticalCoffin\nextcoffin{.6\mytotalwidth}
{%
  \centering Mixed household waste,\\household waste similar\\to commercial waste,\\bulky waste\\21.2 Mil.\ Mg
}
\CoffinRuleV\nextcoffin[b,l](-.2pt,-\baselineskip)[\CoffinTotalHeight\nextcoffin+2\baselineskip]
\JoinCoffins\holdcoffin [vc,r] \nextcoffin [vc,l]
\JoinCoffins\maincoffin[B,hc]\holdcoffin[t,hc](0pt,-\baselineskip)
\CoffinRuleH*\maincoffin[b,hc](0pt,-\baselineskip)
\SetVerticalCoffin\holdcoffin{.4\mytotalwidth}
{%
  \centering Recycling \par 25.0 Mil.\ Mg \par
  \begin{tabular}{lr}
    Bio waste & 3.8\\
    Garden Residues & 3.9\\
    Glass & 3.6\\
    Paper & 7.9\\
    Plastics & 4.6
  \end{tabular}%
}
\CoffinRuleV\holdcoffin[b,r](.2pt,-\baselineskip)[\CoffinTotalHeight\holdcoffin+2\baselineskip]
\SetVerticalCoffin\nextcoffin{.175\mytotalwidth}
{%
  \centering Landfill \par 4.0 Mil.\ Mg
}
\JoinCoffins \holdcoffin [t,r] \nextcoffin [t,l]
\CoffinRuleV\holdcoffin[b,r](.2pt,-\baselineskip)[\CoffinTotalHeight\holdcoffin+2\baselineskip]
\SetVerticalCoffin\nextcoffin{.175\mytotalwidth}
{%
  \centering Treatment \par 4.2 Mil.\ Mg
}
\JoinCoffins \holdcoffin [t,r] \nextcoffin [t,l]
\CoffinRuleV\holdcoffin[b,r](.2pt,-\baselineskip)[\CoffinTotalHeight\holdcoffin+2\baselineskip]
\SetVerticalCoffin\nextcoffin{.25\mytotalwidth}
{%
  \centering Waste incineration\par 12.8 Mil.\ Mg\
}
\JoinCoffins \holdcoffin [t,r] \nextcoffin [t,l]

\JoinCoffins \maincoffin [b,l] \holdcoffin [t,l](0pt,-\baselineskip)

\CoffinRuleH*\maincoffin[b,hc](0pt,-\baselineskip)[\mytotalwidth][0pt]
\CoffinRuleV\maincoffin[b,l]
\CoffinRuleV\maincoffin[b,r]

\noindent\TypesetCoffin\maincoffin

\noindent\tikzmark{a}

\begin{tikzpicture}[remember picture,overlay]
  \coordinate (a) at ({pic cs:a});
  \path (a) ++(.4\mytotalwidth,0) coordinate (b) ++(.175\mytotalwidth,0) coordinate (c)  ++(.175\mytotalwidth,0) coordinate (d)  ++(.25\mytotalwidth,0) coordinate (e);
  \foreach \i/\j/\k in {a/b/.2,b/c/.0875,c/d/.0875,d/e/.125}
  \draw (\i) --  ($(\j)!.5!(\i) + (0,-\k*\mytotalwidth)$) -- (\j);
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.