Search code examples
visual-studio-codematrixpackagelatexamsmath

VSCode LaTeX nicematrix


I want to use the package "nicematrix" in VSCode, but it's not working the way I tried.

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{mathtools,halloweenmath}
\usepackage{stackengine}
\usepackage{nicematrix}
\begin{document}
\begin{vNiceMatrix}[first-row,last-row,first-col,last-col]
(I)&&x-&y+2z=1 \\
(II)-2x-5y+7z=0 & +2 \cdot (I)\\
(III)&5x+&y-3z=-11 & (-5) \cdot (I)
\end{vNiceMatrix}
\end{document}

The output should look like in this image, but it can't generate an pdf-file. enter image description here

I get the following error:

Fatal Package nicematrix: Outside math mode. LaTeX [line 1, column 1]
(nicematrix) The environment {vNiceMatrix} can be used
(nicematrix) only in math mode (and not in \vcenter).
(nicematrix) This error is fatal.

The next big problem is, that a pdf can't be created:

Emergency stop LaTeX [line 256, column 1] 
:256: ==> Fatal error occurred, no output PDF file produced!Latexmk: Getting log file 'ombplus.log' Latexmk: Examining 'ombplus.fls 
Latexmk: Examining 'ombplus.log 
Latexmk: Errors, so I did not complete making targets 
Collected error summary (may duplicate other messages):

If I click on the problem with line 256, I get this message:

The Editor couldn't be open due to an unexpected error: The file "..." can't be read (Unknown (FileSystemError): TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received 'file(...)/\x00'). Button: Try Again

How I can use the package "nicematrix" in VSCode?

I want to use the package "nicematrix", but VSCode doesn't recognise the package "nicematrix". I downloaded it with the MikTeX-program: "miktex-pdftex" and this opens automically a "package-installer", if I include a new package in VSCode. Then I tried it with a download of this package in CTAN. It's not working this way.


Solution

  • The error is caused by the missing math environment around your nicematrix, add for example \[...\] for an unnumbered equation.

    I also think with NiceArray you'll get better alignment:

    \documentclass{article}
    \usepackage{xcolor}
    \usepackage{graphicx}
    \usepackage{amsmath}
    \usepackage{mathtools,halloweenmath}
    \usepackage{stackengine}
    \usepackage{nicematrix}
    \begin{document}
    \[
    \begin{NiceArray}{l|rlll|l}
      \text{(I)}   &x    &-y   &+2z  &=1   & \\
      \text{(II)}  &-2x  &-5y  &+7z  &=0   & +2 \cdot \text{(I)}\\
      \text{(III)} &5x   &+y    &-3z  &=-11 & (-5) \cdot \text{(I)}
    \end{NiceArray}
    \]
    \end{document}
    

    enter image description here