3

I am trying to add a small, empty line in a NiceTabular environment. The NiceMatrix manual states (Section 5.1.1 The vertical rules):

In the environments of nicematrix, the vertical rules specified by | in the preambles of the environments are never broken, even by an incomplete row or by a double horizontal rule specified by \hline\hline

Which means that the empty line here shows the vertical rules:

\begin{table}[h]
    \small
    \centering
    \begin{NiceTabularX}{\textwidth}{ll}[hvlines]
        \textit{Year}
        &
        \textit{Fruit}
    \\ \hline \hline
        2022
        &
        Apple
    \\
    \end{NiceTabularX}
\end{table}

enter image description here

A quick attempt at a block gave a full-height line that still included the outermost (=border) vertical rules.

\begin{table}[h]
    \small
    \centering
    \begin{NiceTabularX}{\textwidth}{ll}[hvlines]
        \textit{Year}
        &
        \textit{Fruit}
    \\ \Block{1-2}{\hline \hline} \\
        2022
        &
        Apple
    \\
    \end{NiceTabularX}
\end{table}

enter image description here

How can I get a small empty line between rows without any vertical rules?

0

1 Answer 1

5

You can use the rules of the classical {tabular} (of the package array which is loaded by nicematrix).

That means that:

  • you use the classical command \hline (and \hline\hline for the double rule);
  • you have to define a column type with the behavior of the classical | of array (that classical | of array has been overwritten by nicematrix): \newcolumntype{I}{!{\vrule}} will do the job.
\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\newcolumntype{I}{!{\vrule}}

\begin{table}[h]
\small
\centering
\begin{NiceTabular}{IlIlI}
    \hline
    \textit{Year}
    &
    \textit{Fruit} \\
    \hline\hline
    2022
    &
    Apple \\
    \hline
\end{NiceTabular}
\end{table}

\end{document}

Of course, in that example, there is no point using {NiceTabular} (I would use {tabular}) but you probably want to use other features provided by nicematrix in your real tabular).

Output of the above code


On the other hand, remember that the main feature of nicematrix is to insert PGF/Tikz nodes under the cells, columns and rows of a classical {tabular}. That means that it's always possible to draw whatever rule you want with Tikz by using those nodes.


\begin{table}[h]
\small
\centering
\renewcommand{\arraystretch}{1.4}
\begin{NiceTabular}{ll}[hvlines]
    \textit{Year}
    &
    \textit{Fruit} \\
    2022
    &
    Apple \\
\CodeAfter
    \tikz \draw [line width = 2 \pgflinewidth] (2-|1) -- (2-|last) ; 
    \tikz \draw [white, shorten > = -1 pt, shorten <= -1 pt] (2-|1) -- (2-|last) ; 
\end{NiceTabular}
\end{table}

\end{document}

Output of the second code

You must log in to answer this question.

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