2

Is there an equivalent of arydshln's cdashline in nicematrix package?

I am aware of \hdottedline, but I need to add dotted horizontal lines in some columns.

2 Answers 2

3

You can draw the lines between nodes using with the \CodeAfter

a

\documentclass{article}

\usepackage{nicematrix}
\usepackage{tikz}% needed <<<<<<<<<<<

\begin{document}
    
    \begin{NiceTabular}{ccccc}[cell-space-limits=5pt] % expand the cells
        A&B&C&D&E\\
        F&G&H&I&J\\
        K&L&M&N&O\\
        P&Q&R&S&T
        \CodeAfter 
        \tikz \draw [dotted] (1-|1) -- (1-|4); 
        \tikz \draw [dotted] (3-|1) -- (3-|4); 
        \tikz \draw [dashed] (2-|4) -- (2-|6); 
        \tikz \draw [dashed] (1-|1) -- (6-|1); 
        \tikz \draw [dotted] (1-|4) -- (6-|4); 
        \tikz \draw [dashed] (5-|4) -- (5-|6); 
        \tikz \draw  (2-|6) -- (5-|6); 
    \end{NiceTabular}
\end{document}
3

I have added a command \cdotteline in the latest version of nicematrix (6.11 of 2022/07/16).

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{ccc}
champignon & crayon & pays \\
\cdottedline{2-3}
chypre & monde & bike \\
rien & bateau & pain
\end{NiceTabular}

\end{document}

Output of the above code


If you are stuck with an older version of nicematrix, you can program a command \cdottedline as follows (however, the dotted line is a dotted line of Tikz, with square dots).

\documentclass{article}
\usepackage{nicematrix,tikz}

\ExplSyntaxOn
\NewDocumentCommand { \cdottedline } { m }
  { \__schardong:w #1 \q_stop }

\cs_new_protected:Npn \__schardong:w #1-#2 \q_stop 
  {
    \tl_gput_right:Nx \g_nicematrix_code_after_tl 
      { \__schardong_i:nnn { \int_use:c { c@iRow } } { #1 } { \int_eval:n { #2 + 1 } } }
  }

\cs_new_protected:Npn \__schardong_i:nnn #1 #2 #3 
  { \tikz \draw [dotted] (#1-|#2) -- (#1-|#3) ; }

\ExplSyntaxOff

\begin{document}

\begin{NiceTabular}{ccc}
champignon & crayon & pays \\
\cdottedline{2-3}
chypre & monde & bike \\
rien & bateau & pain
\end{NiceTabular}

\end{document}

As usual with nicematrix, you need several compilations.

Output of the second code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .