1

I am trying to adapt the code from this post to allow for matlab style syntax for matrices in latex. In the MWE example, the alignment of the \vdots is incorrect (should be centered)...

misalignment issues

My MWE is...

\documentclass{article}
\usepackage{mathtools}

\makeatletter \renewcommand\env@matrix[1][r]{\hskip -\arraycolsep% \let@ifnextchar\new@ifnextchar \array{\c@MaxMatrixCols #1}} \makeatother \usepackage{nicematrix} \renewcommand\matrix[1]{% \begin{bNiceMatrix}[r][light-syntax] #1 \end{bNiceMatrix}% }

\begin{document}

\begin{equation} \matrix{\vec{x}^{(1)};\vec{x}^{(2)};\vdots;\vec{x}^{(m)}}^{T} \end{equation}

\end{document}

How can I fix this?

UPDATE

I tried the solution from @F. Pantigny. It worked for \vdots, but for \cdots and \ldots it causes there to be extra dots between the different elements of the matrix, ie...

\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}
\renewcommand\matrix[1]{%
    \begin{bNiceMatrix}[r,light-syntax,renew-dots,xdots/shorten=6pt]
        #1
    \end{bNiceMatrix}%
}
\begin{document}
\begin{equation*}
\matrix{\vec{x}^{(1)};\vec{x}^{(2)};\vdots;\vec{x}^{(m)}}^{T} = \matrix{\vec{x}^{(1)} \vec{x}^{(2)}\cdots \vec{x}^{(n)}}
\end{equation*}
\end{document}

gives...

bad dots still

user41177
  • 375

1 Answers1

2
\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}


\renewcommand\matrix[1]{%
    \begin{bNiceMatrix}[r,light-syntax,renew-dots,xdots/shorten=6pt]
        #1
    \end{bNiceMatrix}%
}

\begin{document}

\begin{equation*}
\matrix{\vec{x}^{(1)};\vec{x}^{(2)};\vdots;\vec{x}^{(m)}}^{T}
\end{equation*}

\end{document}

Output of the above code

F. Pantigny
  • 40,250
  • Thank you. That works to fix the alignment of the vertical dots, but for \cdots and \ldots it causes significant issues. – user41177 Sep 24 '23 at 17:48
  • You should try without the key renew-dots but with, in the matrix, \Vdots (provided by nicematrix) instead of \vdots. – F. Pantigny Sep 24 '23 at 18:16