5 如何用nicematrix里用tikz打出如下公式

发布于 2026-03-23 23:03:08
关注者
0
被浏览
62
Sagittarius Rover
Sagittarius Rover 7小时前
这家伙很懒,什么也没写!

Just refer the manual in texdoc nicematrix and a little bit in texdoc tikz:

\documentclass{article}
\usepackage{fourier}
\usepackage{nicematrix,tikz}
\usepackage{lipsum}
\usetikzlibrary{arrows.meta}
\begin{document}

\lipsum[2][1-3]

\[  
\renewcommand{\arraystretch}{1.5}%
\begin{pNiceArray}{ccc;ccc}[margin] % new feature `;' in nicematrix v7.7
\CodeBefore%
\tikz{%
    \draw[-Stealth] ([xshift=-1cm,yshift=.05cm]1.5|-2) node[above] {$(-2)$} |- ([xshift=-.5cm]1.5|-2.5);
    \draw[-Stealth] ([xshift=-1.75cm,yshift=.05cm]1.5|-2) node[above] {$(-1)$} |- ([xshift=-.5cm]1.5|-3.5);
}
\Body
1 & 2 & 3 & 1 & 0 & 0 \\
2 & 1 & 2 & 0 & 1 & 0 \\
3 & 2 & 1 & 0 & 0 & 1 \\
\end{pNiceArray}
\]

\lipsum[2][1-3]

\end{document}

image.png

3 个回答
myhsia
myhsia 7小时前
PhD Student in Cond-Matt Physics at Westlake University

如图,

image.png

代码如下,

\documentclass{article}

\usepackage{amsmath, tikz, nicematrix, arydshln}
\usetikzlibrary{tikzmark}
\tikzset{> = latex}

\begin{document}

\[
  \renewcommand{\arraystretch}{1.5}
  \begin{pNiceArray}{ccc|[tikz = dashed]ccc}
    1 & 2 & 3 & 1 & 0 & 0\\
    \tikzmarknode{row2}{2} & 1 & 2 & 0 & 1 & 0\\
    \tikzmarknode{row3}{2} & 3 & 4 & 0 & 0 & 1
    \CodeAfter
    \tikz{%
      \draw [<-] ([xshift = -1em]row2.west) --++ (-.5,0) --++ (0,.5)
       coordinate (row2destination)
       node [above] {$(-2)$};
      \draw [<-] ([xshift = -1em]row3.west) --++ (-1.5,0) -|
      ([xshift = -1cm]row2destination)
       node [above] {$(-1)$};
    }
  \end{pNiceArray}
  \to
\]

\end{document}
shadow
shadow 7小时前
这个人懒得不得了,竟然啥也没写

给个用tikz的笨办法

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\[
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,
    nodes={minimum width=6.5mm, minimum height=6.5mm, anchor=center},
    left delimiter=(,
    right delimiter=)
]{
1 & 2 & 3 & 1 & 0 & 0 \\
2 & 1 & 2 & 0 & 1 & 0 \\
1 & 3 & 4 & 0 & 0 & 1 \\
};

\draw[dashed]
([shift={(0,0.4)}]m-1-3.east) -- ([shift={(0,-0.45)}]m-3-3.east);
\node[inner sep =1pt](a) at([shift={(-2.1,0)}]m-1-1){$(-1)$};
\node[inner sep =1pt](b) at([shift={(-1.3,0)}]m-1-1){$(-2)$};
\draw[-latex,line width=0.4pt] (a)|-(-2.4,-0.65);
\draw[-latex,line width=0.4pt] (b)|-(-2.4,0);
\node at (2.8,0){$\longrightarrow$};
\end{tikzpicture}
\]

\end{document}

image.png

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览