Is there a simple way to draw a straight line from one coffin handle to another?

The following code supports macros to draw horizontal and vertical rules placed at coffin poles. This is not exactly what you asked for, but, in some cases, it can do the job you might want to do so I hope that it is worth posting.

The code provides two new user commands for use with a coffin, \MyCoffin:

\CoffinRuleH*\MyCoffin[<main coffin pole>,<main coffin pole>][<rule pole>,<rule pole>](<x offset>,<y offset>)[<rule width>][<rule thickness>][<colour>]
\CoffinRuleV*\MyCoffin[<main coffin pole>,<main coffin pole>][<rule pole>,<rule pole>](<x offset>,<y offset>)[<rule height>][<rule thickness>][<colour>]

\CoffinRuleH is intended for horizontal rules and \CoffinRuleV for vertical.

By default, the main coffin handle used is at b,l; the rule handle is defined to match the main coffin handle; the offsets are both zero; the height is the total height of the coffin or the width is the width (as applicable); the rule thickness is .4pt; and the colour is black.

The starred versions may change the size of the coffin to which the rule is added. The unstarred versions never do this.

Code for the new commands:

\ExplSyntaxOn
\dim_new:N \l_hm_rule_dim
\dim_set:Nn \l_hm_rule_dim { .4pt }
\tl_new:N \l_hm_colour_tl
\tl_set:Nn \l_hm_colour_tl { black }
\tl_new:N \l_hm_tmpa_tl
\tl_new:N \l_hm_tmpb_tl
\tl_new:N \l_hm_tmpc_tl
\tl_new:N \l_hm_tmpd_tl
\cs_new_protected:Nn \coffin_attach_rule:Nnnnnnnnn
{
  \vcoffin_set:Nnn \l_tmpa_coffin { #8 }
  {
    \dim_zero:N \parindent
    \color { \l_hm_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_hm_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_hm_rule_dim } o }
{
  \IfValueT { #8 }
  {
    \tl_set:Nn \l_hm_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_hm_tmpa_tl
  \clist_pop:NN \l_tmpa_clist \l_hm_tmpb_tl
  \IfNoValueTF { #4 }
  {
    \tl_set:NV \l_hm_tmpc_tl \l_hm_tmpa_tl
    \tl_set:NV \l_hm_tmpd_tl \l_hm_tmpb_tl
  }
  {
    \clist_set:Nn \l_tmpa_clist { #3 }
    \clist_pop:NN \l_tmpa_clist \l_hm_tmpc_tl
    \clist_pop:NN \l_tmpa_clist \l_hm_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_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_tmpd_tl \l_tmpb_dim \l_tmpc_dim \l_tmpa_dim { #7 }
  }
  {
    \coffin_attach_rule:NVVVVVVVn #2 \l_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_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_hm_rule_dim } o }
{
  \IfValueT { #8 }
  {
    \tl_set:Nn \l_hm_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_hm_tmpa_tl
  \clist_pop:NN \l_tmpa_clist \l_hm_tmpb_tl
  \IfNoValueTF { #4 }
  {
    \tl_set:NV \l_hm_tmpc_tl \l_hm_tmpa_tl
    \tl_set:NV \l_hm_tmpd_tl \l_hm_tmpb_tl
  }
  {
    \clist_set:Nn \l_tmpa_clist { #3 }
    \clist_pop:NN \l_tmpa_clist \l_hm_tmpc_tl
    \clist_pop:NN \l_tmpa_clist \l_hm_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_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_tmpd_tl \l_tmpb_dim \l_tmpc_dim { #7 } \l_tmpa_dim
  }
  {
    \coffin_attach_rule:NVVVVVVnV #2 \l_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_tmpd_tl \l_tmpb_dim \l_tmpc_dim { #7 } \l_tmpa_dim
  }
}
\ExplSyntaxOff

The example below is modified from my answer to another question. All the rules are drawn with the commands above, and the construction is just a combination of coffins.

example

A key-value syntax might be preferable, but I wanted to stay as close as possible to the interface provided by xcoffins, which ruled that out.

Complete code:

\documentclass{article}
\usepackage{xcoffins}
\ExplSyntaxOn
\dim_new:N \l_hm_rule_dim
\dim_set:Nn \l_hm_rule_dim { .4pt }
\tl_new:N \l_hm_colour_tl
\tl_set:Nn \l_hm_colour_tl { black }
\tl_new:N \l_hm_tmpa_tl
\tl_new:N \l_hm_tmpb_tl
\tl_new:N \l_hm_tmpc_tl
\tl_new:N \l_hm_tmpd_tl
\cs_new_protected:Nn \coffin_attach_rule:Nnnnnnnnn
{
  \vcoffin_set:Nnn \l_tmpa_coffin { #8 }
  {
    \dim_zero:N \parindent
    \color { \l_hm_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_hm_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_hm_rule_dim } o }
{
  \IfValueT { #8 }
  {
    \tl_set:Nn \l_hm_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_hm_tmpa_tl
  \clist_pop:NN \l_tmpa_clist \l_hm_tmpb_tl
  \IfNoValueTF { #4 }
  {
    \tl_set:NV \l_hm_tmpc_tl \l_hm_tmpa_tl
    \tl_set:NV \l_hm_tmpd_tl \l_hm_tmpb_tl
  }
  {
    \clist_set:Nn \l_tmpa_clist { #3 }
    \clist_pop:NN \l_tmpa_clist \l_hm_tmpc_tl
    \clist_pop:NN \l_tmpa_clist \l_hm_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_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_tmpd_tl \l_tmpb_dim \l_tmpc_dim \l_tmpa_dim { #7 }
  }
  {
    \coffin_attach_rule:NVVVVVVVn #2 \l_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_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_hm_rule_dim } o }
{
  \IfValueT { #8 }
  {
    \tl_set:Nn \l_hm_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_hm_tmpa_tl
  \clist_pop:NN \l_tmpa_clist \l_hm_tmpb_tl
  \IfNoValueTF { #4 }
  {
    \tl_set:NV \l_hm_tmpc_tl \l_hm_tmpa_tl
    \tl_set:NV \l_hm_tmpd_tl \l_hm_tmpb_tl
  }
  {
    \clist_set:Nn \l_tmpa_clist { #3 }
    \clist_pop:NN \l_tmpa_clist \l_hm_tmpc_tl
    \clist_pop:NN \l_tmpa_clist \l_hm_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_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_tmpd_tl \l_tmpb_dim \l_tmpc_dim { #7 } \l_tmpa_dim
  }
  {
    \coffin_attach_rule:NVVVVVVnV #2 \l_hm_tmpa_tl \l_hm_tmpb_tl \l_hm_tmpc_tl \l_hm_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 hm separate collection
}
\SetVerticalCoffin\nextcoffin{.6\mytotalwidth}
{%
  \centering Mixed household hm,\\household hm similar\\to commercial hm,\\bulky hm\\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 hm & 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)
\CoffinRuleV\maincoffin[b,l]
\CoffinRuleV\maincoffin[b,r]

\noindent\TypesetCoffin\maincoffin

\end{document}

To get this question unanswered I provided this cw

At the moment there isn't such a feature.

Tags:

Xcoffins