tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

Is that possible to extend the dash style with tabularray?

Open Explorer-cc opened this issue 6 months ago • 1 comments

I think this is a feature request but not questions, the x-post is at TeX.SE in bounty for days.

In brief, I want to use \NewTblrDashStyle to define a new style like dot dash.

Image

But in the following unseuccessful attempt, get stuck by the box and glue of \__tblr_dash_style_make_boxes:nnn and \NewTblrDashStyle:

\documentclass{article}
\usepackage{tabularray}
\ExplSyntaxOn
 
\NewDocumentCommand \ljhNewTblrDashStyle { m m }
{
  \seq_set_split:Nnn \l_tmpa_seq { ~ } {#2}
 
  \tl_set:Ne \l__tblr_a_tl { \seq_item:Nn \l_tmpa_seq {1} } %
  \tl_set:Ne \l__tblr_b_tl { \seq_item:Nn \l_tmpa_seq {2} } % 
  \tl_set:Ne \l__tblr_c_tl { \seq_item:Nn \l_tmpa_seq {3} } % 
  \tl_set:Ne \l__tblr_d_tl { \seq_item:Nn \l_tmpa_seq {4} } % 
  \tl_set:Ne \l__tblr_e_tl { \seq_item:Nn \l_tmpa_seq {5} } % 
  \tl_set:Ne \l__tblr_f_tl { \seq_item:Nn \l_tmpa_seq {6} } % 
  \tl_set:Ne \l__tblr_g_tl { \seq_item:Nn \l_tmpa_seq {7} } % 
  \tl_set:Ne \l__tblr_h_tl { \seq_item:Nn \l_tmpa_seq {8} } % 

  \tl_if_eq:NnT \l__tblr_a_tl { on }
  {
    \tl_if_eq:NnT \l__tblr_c_tl { off }
    {
      \tl_if_eq:NnT \l__tblr_e_tl { on }
      {
        \tl_if_eq:NnT \l__tblr_g_tl { off }
        {
          \__tblr_dash_style_make_boxes:neeee {#1}
            { \dim_eval:n {\l__tblr_b_tl} }
            { \dim_eval:n {\l__tblr_d_tl} }
            { \dim_eval:n {\l__tblr_f_tl} }
            { \dim_eval:n {\l__tblr_h_tl} }
        }
      }
    }
  }
}
 
\cs_new_protected:Npn \__tblr_dash_style_make_boxes:nnnnn #1 #2 #3 #4 #5
{   
  \dim_set:Nn \l_tmpa_dim { #2 + #3 + #4 + #5 }
 
  \tl_set:Nn \l__tblr_h_tl { \hbox_to_wd:nn }
  \tl_put_right:Ne \l__tblr_h_tl { { \dim_use:N \l_tmpa_dim } }
  \tl_put_right:Nn \l__tblr_h_tl
  {
    {
      \hss
      \vbox:n
      {
        \hbox_to_wd:nn {#2} {} \hrule height \lTblrDefaultHruleWidthDim
      }
      \hss
      \vbox:n
      {
        \hbox_to_wd:nn {#3} {}
      }
      \hss
      \vbox:n
      {
        \hbox_to_wd:nn {#4} {} \hrule height \lTblrDefaultHruleWidthDim
      }
      \hss
      \vbox:n
      {
        \hbox_to_wd:nn {#5} {}
      }
      \hss
    }
  }
  \prop_gput:NnV \g__tblr_defined_hdash_styles_prop {#1} \l__tblr_h_tl

  \tl_set:Nn \l__tblr_v_tl { \vbox_to_ht:nn }
  \tl_put_right:Ne \l__tblr_v_tl { { \dim_use:N \l_tmpa_dim } }
  \tl_put_right:Nn \l__tblr_v_tl
  {
    {
      \vss
      \hbox:n
      {
        \vbox_to_ht:nn {#2} {} \vrule width \lTblrDefaultVruleWidthDim
      }
      \vss
      \hbox:n
      {
        \vbox_to_ht:nn {#3} {}
      }
      \vss
      \hbox:n
      {
        \vbox_to_ht:nn {#4} {} \vrule width \lTblrDefaultVruleWidthDim
      }
      \vss
      \hbox:n
      {
        \vbox_to_ht:nn {#5} {}
      }
      \vss
    }
  }
  \prop_gput:NnV \g__tblr_defined_vdash_styles_prop {#1} \l__tblr_v_tl
}
\cs_generate_variant:Nn \__tblr_dash_style_make_boxes:nnnnn { neeee }
 
\ljhNewTblrDashStyle{dotdash}{on ~ .5pt ~ off ~ 1pt ~ on ~ 2pt ~ off ~ 1pt}
 
\ExplSyntaxOff

\begin{document}
 
\begin{table}[ht]
\centering
\caption{\textbf{????}}
\begin{tblr}{colspec = {c|c|[dotdash]c|c}}
\hline
\textbf{???} & \SetCell[c=2]{c}\textbf{???} && \textbf{??}\\
\hline
?? & ?? & ?? & ??\\
\hline
\SetCell[r=3]{c}?? & ?? & ?? & \SetCell[r=3]{c}?? \\
\hline
& ?? & ?? & \\
\hline
& ?? & ?? & \\
\hline
\end{tblr}
\end{table}
\end{document}

It failed with:

Image

Explorer-cc avatar May 26 '25 10:05 Explorer-cc

I do think this should be implemented in the next package update.

Possible solution here: https://tex.stackexchange.com/a/745317/322482

Explorer-cc avatar May 28 '25 04:05 Explorer-cc