
다소 간단한 질문이 있습니다.
다음 코드를 적용하는 간단한 방법이 있습니까?
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[red, line width = 1mm] (2, 0) -- (-2, 0);
\draw[blue, line width = 1mm] (0, 2) -- (0, -2);
\end{tikzpicture}
\end{document}
빨간색 선이 파란색 선 앞에 있고 파란색 선의 교차점에 "구멍"이 있습니다. 그려지는 순서를 변경하지 않고(예: 빨간색을 먼저) 교차점을 정확히 알지 못합니까? 기본적으로 최종 제품은 다음과 같아야 합니다.
답변1
간단한 경우 tikz 옵션은 double=<color>
tikz double distance=<dimen>
라이브러리와 함께 유용합니다 background
. 다음 예를 참조하세요.
복잡한 경우에는 다음이 필요할 수 있습니다.knots
복잡한 경우에는 @Sebastiano가 제안한 것처럼 패키지가질문 댓글.
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\draw[white, double=red, double distance=1mm, line width=1mm](2, 0) -- (-2, 0);
\scoped[on background layer]
\draw[blue, line width = 1mm] (0, 2) -- (0, -2);
\end{tikzpicture}
\end{document}
답변2
다음은 몇 가지 방법입니다. 모두 간단합니다.
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{every path/.style={line width=1mm}}
\begin{tikzpicture}
\path
(-1,-1) coordinate (A)
(1,1) coordinate (B)
(-1,1) coordinate (C)
(1,-1) coordinate (D);
\draw[blue] (A)--(B);
\draw[white,line width=2mm] (C)--(D);
\draw[red] (C)--(D);
\end{tikzpicture}
\begin{tikzpicture}
\draw[teal] (A)--(B);
\draw[orange,preaction={draw,line width=2mm,white}] (C)--(D);
\end{tikzpicture}
\begin{tikzpicture}
\path (intersection of A--B and C--D) coordinate (I);
\draw[brown] (A)--(B);
\draw[magenta,shorten >=1mm] (C)--(I);
\draw[magenta,shorten >=1mm] (D)--(I);
\end{tikzpicture}
\begin{tikzpicture}
\path (intersection of A--B and C--D) coordinate (I);
\draw[magenta] (C)--(D);
\path (C)--(I) node[pos=1,sloped,fill=white]{};
\draw[brown] (A)--(B);
\end{tikzpicture}
\begin{tikzpicture} % page 178, PGF manual
\draw[cyan] (A)--(B);
\draw[white,double=red,double distance=1mm] (C)--(D);
\end{tikzpicture}
\end{document}