我已经定义了命令
\newcommand{\tikzmark}[2]{%
\tikz[overlay,remember picture,baseline] \node[anchor=base] (#1) {$#2$};
}
\newcommand{\DrawVLine}[3][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[shorten <=0.3ex, thick, #1] (#2.north) -- (#3.south);
\end{tikzpicture}
}
\newcommand{\DrawHLine}[3]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[shorten <=0.2em, thick, #1] (#2.west) -- (#3.east);
\end{tikzpicture}
}
我将它们用作
\begin{equation}
\bordermatrix{
& (A) & (B) & (C) & (D) & (E) \cr
(1) & 6 & 4 & 3 & \tikzmark{topD}{2} & \tikzmark{topA}{0} \cr
(2) & 5 & 4 & 3 & 5 & 0 \cr
(3) & 3 & 7 & 3 & 0 & 0 \cr
(4) & \tikzmark{leftB}{1} & 0 & 0 & 4 & \tikzmark{rightB}{0} \cr
(5) & \tikzmark{leftC}{0} & 0 & 6 & \tikzmark{bottomD}{4} & \tikzmark{bottomA}{0}
}
\DrawVLine[color=red]{topA}{bottomA}
\DrawHLine[color=blue]{leftC}{bottomA}
\DrawVLine[color=green]{topD}{bottomD}
\DrawHLine[color=orange]{leftB}{rightB}
\end{equation}
我得到了错误
我究竟做错了什么?
编辑
一个完整的例子
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{fit}
\usetikzlibrary{chains}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\newcommand{\tikzmark}[2]{%
\tikz[overlay,remember picture,baseline] \node[anchor=base] (#1) {#2};
}
\newcommand{\DrawVLine}[3][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[shorten <=0.3ex, thick, #1] (#2.north) -- (#3.south);
\end{tikzpicture}
}
\newcommand{\DrawHLine}[3]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[shorten <=0.2em, thick, #1] (#2.west) -- (#3.east);
\end{tikzpicture}
}
\begin{document}
\begin{equation}
\bordermatrix{
& (A) & (B) & (C) & (D) & (E) \cr
(1) & 6 & 4 & 3 & \tikzmark{topD}{2} & \tikzmark{topA}{0} \cr
(2) & 5 & 4 & 3 & 5 & 0 \cr
(3) & 3 & 7 & 3 & 0 & 0 \cr
(4) & \tikzmark{leftB}{1} & 0 & 0 & 4 & \tikzmark{rightB}{0} \cr
(5) & \tikzmark{leftC}{0} & 0 & 6 & \tikzmark{bottomD}{4} & \tikzmark{bottomA}{0}
}
\DrawVLine[color=red]{topA}{bottomA}
\DrawHLine[color=blue]{leftC}{bottomA}
\DrawVLine[color=green]{topD}{bottomD}
\DrawHLine[color=orange]{leftB}{rightB}
\end{equation}
\end{document}