마지막 "현재 좌표"를 참조하는 TikZ 좌표

Nov 29 2020

TikZ 경로 내에서 "현재 좌표"를 다른 좌표로 참조 할 수 있습니까?

내가 원하는 것을 명확히하기 위해이 예를 살펴보면, 내가 더 잘 알지 못하기 때문에 종종 수행하게됩니다.

\documentclass[tikz,margin=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\coordinate (origin) at (0,0);
% suppose the "1,1" is a very complicate (possibly unknown) coordinate
% that I would love not to repeat in the code:
\draw (origin) -| (1,1) coordinate (THIS) -- (THIS-|origin);
% This is what I would like to do:
% \draw (origin) -| (1,1) -- (THIS-|origin);
\end{tikzpicture}
\end{document}

내가하는 일은 :

\draw (origin) -| (1,1) coordinate (THIS) -- (THIS-|origin);

나는 현재 지점에서 다른 지점에 수직 인 지점까지 직선을 그리고 싶기 때문입니다. 그러나 항상 타이핑 하는 것은 고통스럽고coordinate (THIS) , 제가 ​​할 수있는 마법의 내부 좌표가 있는지 알고 싶습니다.

\draw (origin) -| (1,1) -- (THIS-|origin);

그리고 THIS그것이 의미한다는 것을 알 것입니다 1,1.

합니까는 THIS존재, 또는 무엇을 내가 뭘하는 것은 내가 할 수있는 최선인가?

답변

2 Noname Nov 29 2020 at 07:18

to대신 사용하려는 경우 --마지막 좌표가에 저장되며 \tikztostart사용하는 것과 동일한 방식으로 사용할 수 있습니다 THIS.

\documentclass[tikz,margin=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\coordinate (origin) at (0,0);
% suppose the "1,1" is a very complicate (possibly unknown) coordinate
% that I would love not to repeat in the code:
% This is what I would like to do:
% \draw (origin) -| (1,1) -- (THIS-|origin);
 \draw (origin) -| (1,1)  to (\tikztostart-|origin);
\end{tikzpicture}
\end{document}

물론 \THIS.

\documentclass[tikz,margin=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\coordinate (origin) at (0,0);
\def\THIS{\tikztostart}
% suppose the "1,1" is a very complicate (possibly unknown) coordinate
% that I would love not to repeat in the code:
 \draw (origin) -| (1,1)  to (\THIS-|origin);
% This is what I would like to do:
% \draw (origin) -| (1,1) -- (THIS-|origin);
\end{tikzpicture}
\end{document}