有没有简单的方法可以从一个棺材把手到另一个棺材把手画一条直线?

有没有简单的方法可以从一个棺材把手到另一个棺材把手画一条直线?

我想知道是否有一种简单的方法可以从一个棺材把手到另一个棺材把手画一条直线。

答案1

为了解决这个问题,我提供了这个 cw

目前还没有这样的功能。

答案2

以下代码支持宏来绘制放置在棺材杆上的水平和垂直规则。这并非您所要求的,但在某些情况下,它可以完成您可能想要完成的工作,因此我希望它值得发布。

该代码提供了两个用于棺材的新用户命令\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适用于水平规则和\CoffinRuleV垂直规则。

默认情况下,使用的主棺材手柄位于b,l;规则手柄定义为与主棺材手柄匹配;偏移量均为零;高度是棺材的总高度或宽度是宽度(如适用);规则厚度为.4pt;颜色为黑色。

带星号的版本可能会改变添加规则的棺材的尺寸。无星号的版本永远不会发生这种情况。

新命令的代码:

\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

下面的例子修改自我对另一个问题的回答。所有规则都是用上面的命令绘制的,建造只是棺材的组合。

例子

键值语法可能更可取,但我想尽可能接近提供的接口xcoffins,所以排除了这种可能性。

完整代码:

\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}

相关内容