I've created matrices with some diagonal lines and some tweaking on \vdots. (based on these posts: diagonal line within matrix and How to vertically center the \vdots in this node? )
The result is exactly what I want, but when I copy the code from my test/trial&error file to my main file I encounter a problem. After some searching I've located the issue: without the tikzexternal command everything works fine.
However, my main file is rather large so I cant really go without the tikzexternal command.
Can someone fix this for me? (and explain what the problem is?) Just uncomment the 3 tikzexternalize lines to reproduce the error.
(maybe relevant: with the tikzexternalize enabled I get different errors in each document, let me know if you need the actual error messages)
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
%\usepgfplotslibrary{external} %use with --shell-escape
%\tikzexternalize[prefix=Tikzplots/]
%\pgfplotsset{compat=newest}
\makeatletter %vdots without extra space on top
\DeclareRobustCommand{\rvdots}{%
\vbox{
\baselineskip4\p@\lineskiplimit\z@
\kern-\p@
\hbox{.}\hbox{.}\hbox{.}
}}
\makeatother
\newcommand\tikzmark[1]{% %nodes in matrix for lines
\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {};}
\newcommand\MyLine[3][]{% %draw lines between the nodes^
\begin{tikzpicture}[overlay,remember picture]
\draw[#1] (#2.north west) -- (#3.east);
\end{tikzpicture}}
\begin{document}
\[
\begin{bmatrix}
Y[1]\\
\phantom{0}\\
\rvdots\\
\rvdots\\
\phantom{0}\\
Y[k]
\end{bmatrix}
=
\begin{bmatrix}
\phantom{0}\tikzmark{a} & \phantom{0}& \phantom{0}& \phantom{0}&\phantom{0}& \phantom{0} \\
\\
\\
\\
\\
& & & & & \tikzmark{b}\phantom{0}
\end{bmatrix}
\cdot
\begin{bmatrix}
X[1]\\
\phantom{0}\\
\rvdots\\
\rvdots\\
\phantom{0}\\
X[k]
\end{bmatrix}
\]
\[
\begin{bmatrix}
Y[1]\\
\phantom{0}\\
\rvdots\\
\rvdots\\
\phantom{0}\\
Y[k]
\end{bmatrix}
=
\begin{bmatrix}
\phantom{0}\tikzmark{c} & \phantom{0} &\phantom{0}\tikzmark{e} &\phantom{0} & \phantom{0}\tikzmark{g}& \phantom{0}\\
& & & & &\tikzmark{h}\phantom{0}\\
\phantom{0}\tikzmark{i}& & & & &\\
& & & & & \tikzmark{f}\phantom{0} \\
\phantom{0}\tikzmark{k}& & & & &\\
&\tikzmark{l}\phantom{0} & &\tikzmark{j}\phantom{0} & & \tikzmark{d}\phantom{0}\\
\end{bmatrix}
\cdot
\begin{bmatrix}
X[1]\\
\phantom{0}\\
\rvdots\\
\rvdots\\
\phantom{0}\\
X[k]
\end{bmatrix}
\]
\MyLine[thick]{a}{b}
\MyLine[red,thick]{c}{d}
\MyLine[thick]{e}{f}
\MyLine[thick]{g}{h}
\MyLine[thick]{i}{j}
\MyLine[thick]{k}{l}
\end{document}
\tikzexternaldisable
and\tikzexternalenable
to both commands