
在解釋我的問題之前,很抱歉,如果這是一個重複的問題,但我無法找到一個與我的問題相同的已回答/提出的問題。
為了建立一個圖表,我定義了自己的函數,該函數繪製一個以先前定義的點為中心的矩形,並旋轉一個也作為參數傳遞的角度。代碼:
\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,automata,positioning,arrows}
\usetikzlibrary{patterns}
\usepackage{xcolor}
\newdimen\XCoord
\newdimen\YCoord
\newcommand*{\ExtractCoordinate}[1]{
\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};
}
\newcommand{\myrec}[5]{% #1: center, #2: horizontal edge, #3: vertical edge, #4 angle of rotation, #5: edge color
\ExtractCoordinate{$(#1)$};
\node (a) at (\XCoord,\YCoord) {};
\draw [solid,rotate=#4,draw=#5] let \p1=(a) in ($ (\x1,\y1) + 0.5*(-#2,#3) $) rectangle ($ (\x1,\y1) + 0.5*(#2,-#3) $);
}
\begin{document}
\begin{tikzpicture}
\node (Point) at (2,3) {Point};
\myrec{$(Point)$}{1.5}{2.2}{0}{blue};
\end{tikzpicture}
\end{document}
現在,我嘗試改進此功能,並添加選擇邊緣顏色的可能性。然而,儘管我以適合大多數人的方式做到了這一點,但我收到了錯誤:Package xcolor Error: Undefined color ';'
。關於如何正確傳遞顏色作為參數有什麼想法嗎?
編輯:
我還不明白為什麼,但重新啟動電腦解決了問題。