
Tengo una pregunta bastante simple:
¿Existe una forma sencilla de adaptar el siguiente código?
\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}
de modo que la línea roja esté delante de la azul y la azul tenga un "agujero" en la intersección. ¿Sin cambiar el orden en que están dibujados (por ejemplo, el rojo primero) y sin conocer exactamente el punto de intersección? Básicamente, el producto final debería verse así:
Respuesta1
En casos simples, las opciones de tikz double=<color>
son double distance=<dimen>
útiles, acompañadas de la biblioteca de tikz background
. Vea el siguiente ejemplo.
En casos complejos, es posible que necesite knots
un paquete, como sugirió @Sebastiano encomentario de pregunta.
\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}
Respuesta2
A continuación se muestran algunas formas. Todos son simples.
\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}