
좋은 예제 코드를 하나 찾았습니다여기let
, 명령 으로 다시 포맷 하고 newcommand
쉽게 사용할 수 있도록 정의해 보세요.
다음은 내 초안 버전이지만 컴파일을 통과할 수 없습니다.
\documentclass[border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows, calc}
\newcommand{\dbarr}[4] {
\path (#1) -- (#2)
let
\p1=($(#1) - $(#2)),
\n{height}={veclen(\x1,\y1)},
\n{angle}={atan2(\y1,\x1)} in
node[midway, single arrow, draw=black,
minimum width=15mm, minimum height=\n{height},
inner sep=0mm, single arrow head extend=1mm, double arrow head extend=1mm,
fill=cyan!20,double arrow,rotate=\n{angle}] (#3) {#4};
}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2,2);
\dbarr{A}{B}{C}{from A to B};
\end{tikzpicture}
\end{document}
오류:
Runaway argument?
$(B)), \n {height}={veclen(\x 1,\y 1)}, \n {angle}={atan2(\y 1,\x 1)}\ETC.
! File ended while scanning use of \tikz@cc@parse@factor.
<inserted text>
\par
<*> a.tex
? x
No pages of output
이 오류는 어디에서 오류가 발생했는지 이해하기 어렵습니다. 누구든지 나를 도와주시면 감사하겠습니다!
답변1
\p1=($(#1) - $(#2))
가 다음으로 대체 되면 코드가 컴파일됩니다 \p1=($(#1) - (#2)$)
( 의 위치 참고 $
).