fpantigny / nicematrix

The LaTeX package nicematrix
3 stars 1 forks source link

Adding margin to nicematrix does not add space around cells #2

Open Basmah1961 opened 4 months ago

Basmah1961 commented 4 months ago

image

As seen above, the underbrace does not extend. The expected output is as follows

image

which is achieved by adding padding using \hspace{1em} before and after one of the entries. I think it could be better to add a new option to nicematrix such as margin-in which refers to internal margin and adds specific space before and after all elements of the matrix.

@fpantigny mentions in Adding margin to nicematrix does not add space around cells that using {bNiceArray} with a preamble: {>{\hspace{1em}}c<{\hspace{1em}}} is a good workaround. This is correct, but adding too much code in the preamble of bNiceArray is too redundant and could be distracting when adding multiple columns. In the following example, it is possible to add an option as margin-in[1]=1em (adds padding for column 1 of 1em)

image

\documentclass[11pt, a4paper]{article}

\usepackage{nicematrix}

\begin{document}

\begin{equation*}
    \begin{bNiceMatrix}[margin=1em]
        V_{1}
        \\
        V_{2}
        \\
        V_{3}
        \\
        V_{4}
        \\
        \CodeAfter
        \UnderBrace{1-1}{4-1}{V_{\mathrm{buses}}}[yshift=3pt]
    \end{bNiceMatrix}
\end{equation*}

\vspace*{2\baselineskip}

\begin{equation*}
    \begin{bNiceMatrix}[margin=1em]
        \hspace{1em}
        V_{1}
        \hspace{1em}
        & I_{1}
        \\
        V_{2}
        & I_{2}
        \\
        V_{3}
        & I_{3}
        \\
        V_{4}
        & I_{4}
        \\
        \CodeAfter
        \UnderBrace{1-1}{4-1}{V_{\mathrm{buses}}}[yshift=3pt]
    \end{bNiceMatrix}
\end{equation*}

\end{document}