0

is there a way to move the bolded bar to the left a little? (the one before the last 0). Also, could someone help me fix the slant of the last arrow to make it straight? Thanks! My code looks like this right now:

\begin{tikzpicture}
\matrix[matrix of nodes,column sep=0pt,
nodes={anchor=base east,inner xsep=6pt,inner ysep=6pt}] (M) {
& 1 & 5 & 4 & 20\\[-3pt]
-5 &   & -5 & -5  & -20\\[3pt]
& 1 & 0 & 4 & 0\\
};
\draw (M-2-1.south west) -- (M-2-6.south east);
\draw (M-1-2.north west) -- (M-3-2.south west);
\draw[line width=3pt] (M-2-6.south west) -- ++(0pt,-20pt);

\begin{scope}[->, shorten >=-4pt, shorten <=-4pt]
\draw (M-1-2) -- (M-3-2);
\draw (M-3-2) -- (M-2-3);
\draw (M-2-3) -- (M-3-3);
\draw (M-3-3) -- (M-2-4);
\draw (M-2-4) -- (M-3-4);
\draw (M-3-4) -- (M-2-5);
\draw (M-2-5) -- (M-3-5);
\end{scope}
\end{tikzpicture}
  • 1
    Hi, welcome. That code cannot work, your matrix has five columns, so M-2-6 doesn't exist. Can you turn your snippet into a complete example that does work? (By complete, I mean add a \documentclass -- article is probably fine -- the necessary packages and tikzlibraries, and a document environment. That just makes it a little bit easier for those who want to help.) – Torbjørn T. Oct 1 '17 at 7:50
  • This should be an edit to your previous question, not a new one. See also my answer to it. – CarLaTeX Oct 1 '17 at 8:32
2

like this?

enter image description here

  • first you need correct errors in your code snippet
  • second, please always provide complete small document beginning with \documentclass{...} and ending with \end{document}. help us to help you ... (is not fun write missing parts of your code, that we can test it)
  • bar can be moved with xshift{...}
  • nodes are not equal width, so you need to change start coordinates of perpendicular arrows

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,column sep=0pt,
        nodes={anchor=base east,inner sep=6pt}] (M) {
   & 1 & 5  & 4  &  20\\[-3pt]
-5 &   & -5 & -5 & -20\\[3pt]
   & 1 & 0  & 4  &   0\\
};
\draw (M-2-1.south west) -- (M-2-5.south east);
\draw (M-1-2.north west) -- (M-3-2.south west);
\draw[line width=3pt, semitransparent] ([xshift=-1mm] M-2-5.south west) -- ++(0pt,-20pt);

\begin{scope}[->, shorten >=-4pt, shorten <=-4pt]
\draw (M-1-2) -- (M-3-2);
\draw (M-3-2) -- (M-2-3);
\draw (M-2-3.south -| M-3-3) -- (M-3-3);
\draw (M-3-3) -- (M-2-4);
\draw (M-2-4.south -| M-3-4) -- (M-3-4);
\draw (M-3-4) -- (M-2-5);
\draw (M-2-5.south -| M-3-5) -- (M-3-5);
\end{scope}
\end{tikzpicture}
\end{document}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.