6

I encountered a problem with the horizontal dashed line created by the nicematrix package in LaTeX. The line is a little close to the bottom of the matrix, overlapping with the elements of the second row. Is there any simple and default solution in nicematrix to adjust the dashed line position which don't need to tweak detailed parameters? Strange dashed line position

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{amsmath, amsthm, amssymb, bm, color, framed, graphicx, hyperref, mathrsfs}
\usepackage{xcolor}


\begin{document}

$\begin{bNiceArray}{c|[tikz=dashed,color=red]c}
    {\widetilde{\bm{\Sigma}}_{11}} & {\widetilde{\bm{\Sigma}}_{12}}\\
    \Hline[tikz=dashed,color=red]
    {\widetilde{\bm{\Sigma}}_{21}} & {\widetilde{\bm{\Sigma}}_{22}}
\end{bNiceArray}$

\end{document}
New contributor
Prince Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 1
    Welcome to TeX.SX! Try to enlarge the space between cells with something like cell-space-limits = 2pt.
    – jlab
    May 15 at 8:44

2 Answers 2

5

As said by jlab in comment, you can use the key cell-space-top-limit (or the key cell-space-limits which fixes both cell-space-top-limit and cell-space-bottom-limit).

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{amsmath, amsthm, amssymb, bm, color, framed, graphicx, hyperref, mathrsfs}
\usepackage{xcolor}


\begin{document}

$\begin{bNiceArray}{c|[tikz=dashed,color=red]c}[cell-space-top-limit=2pt]
    {\widetilde{\bm{\Sigma}}_{11}} & {\widetilde{\bm{\Sigma}}_{12}}\\
    \Hline[tikz=dashed,color=red]
    {\widetilde{\bm{\Sigma}}_{21}} & {\widetilde{\bm{\Sigma}}_{22}}
\end{bNiceArray}$

\end{document}

Output of the first code

If you prefer, you can apply that parameter to the second row only by using the key cell-space-top-limit of the command \RowStyle:

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{amsmath, amsthm, amssymb, bm, color, framed, graphicx, hyperref, mathrsfs}
\usepackage{xcolor}


\begin{document}

$\begin{bNiceArray}{c|[tikz=dashed,color=red]c}
    {\widetilde{\bm{\Sigma}}_{11}} & {\widetilde{\bm{\Sigma}}_{12}}\\
    \Hline[tikz=dashed,color=red]
\RowStyle[cell-space-top-limit=2pt]{}
    {\widetilde{\bm{\Sigma}}_{21}} & {\widetilde{\bm{\Sigma}}_{22}}
\end{bNiceArray}$

\end{document}

Output of the second code

4

Try to add \NiceMatrixOptions{cell-space-limits=2pt} (as suggested @ jlab in his comment) and option [margin=2pt]:

\documentclass[margin=3mm, preview]{standalone}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath, amssymb, bm}

\begin{document}
$
\NiceMatrixOptions{cell-space-limits=2pt} % <---
\begin{bNiceArray}{c|[tikz=dashed,color=red]c}[margin=2pt]% <---
    {\widetilde{\bm{\Sigma}}_{11}} & {\widetilde{\bm{\Sigma}}_{12}}\\
    \Hline[tikz=dashed,color=red]
    {\widetilde{\bm{\Sigma}}_{21}} & {\widetilde{\bm{\Sigma}}_{22}}
\end{bNiceArray}
$
\end{document}

After three compilation the result is the following:

enter image description here

You must log in to answer this question.

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