在矩阵中创建节点(2)

在矩阵中创建节点(2)

我之前问过一个问题但我删错了。我需要知道如何移动矩阵中的节点。节点目前位于右侧,但我想自由移动它们以显示列操作。我无法从代码中弄清楚如何移动它们。谢谢!

编辑:每次我复制代码时,它都会粘连在一起,而不是像在我的文档中那样自行对齐。请在此处找到链接: https://www.sharelatex.com/read/djqkprqvrfys

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz} 
\usetikzlibrary{calc,chains,matrix,shadows}
\begin{document}

\begin{tikzpicture}[
>=stealth,
every left delimiter/.style={xshift=1em},
every right delimiter/.style={xshift=-1em}
]
\matrix (gauss) [
matrix of math nodes,
nodes={minimum width=5em},
left delimiter=[,
right delimiter={]},
row sep=0.5em,
]{
1 & 1 & 1 & 3a \\
1 & 2 & (a+2) & a \\
1 & -(a+1) & -1 & 0 \\
};
\draw (gauss-1-3.north east) -- (gauss-3-3.south east);
\node[drop shadow,fill=orange,draw,rounded corners,draw,rectangle,minimum size=1.5em,inner sep=0pt,node distance=1em,right=of gauss-1-4] (m1) {-1};
\node[drop shadow,fill=orange,draw,rounded corners,draw,rectangle,minimum size=1.5em,inner sep=0pt,node distance=0.5em,right=of m1] (m2) {-1};
\draw[->] (m1) |- ($(gauss-2-4)+(3em,0)$) node[midway,right] {$$};
\draw[->] (m2) |- ($(gauss-3-4)+(3em,0)$) node[midway,right] {$$};
\end{tikzpicture}
\end{document}

答案1

这是一个节点移动的例子。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz} 
\usetikzlibrary{calc,chains,matrix,shadows,positioning} %<- added positioning
\begin{document}

\begin{tikzpicture}[
>=stealth,
every left delimiter/.style={xshift=1em},
every right delimiter/.style={xshift=-1em}
]
\matrix (gauss) [
matrix of math nodes,
nodes={minimum width=5em},
left delimiter=[,
right delimiter={]},
row sep=0.5em,
]{
1 & 1 & 1 & 3a \\
1 & 2 & (a+2) & a \\
1 & -(a+1) & -1 & 0 \\
};
\draw (gauss-1-3.north east) -- (gauss-3-3.south east);
% changed the positions in the two nodes below (also using the features of positioning
\node[above=2pt of gauss-1-1,drop shadow,fill=orange,draw,rounded corners,draw,rectangle,minimum size=1.5em,inner sep=0pt] (m1) {-1};
\node[below=2pt of gauss-3-3,drop shadow,fill=orange,draw,rounded corners,draw,rectangle,minimum size=1.5em,inner sep=0pt] (m2) {-1};
\draw[->] (m1) -| ($(gauss-3-2.60)+(0,2pt)$); %<- removed  node[midway,right] {$$} because it wasn't used
\draw[->] (m2) -| ($(gauss-3-4.south)-(0,2pt)$); %<-
\end{tikzpicture}
\end{document}

在此处输入图片描述

修订:在我最初的回答中,我忘记删除node distance=指令。

相关内容