我想要一个具有不同边框颜色的节点:一个用于上边框和左边框,一个用于下边框和右边框颜色。
这可能吗?从我找到的所有示例来看,似乎我只能整体设置颜色,而不能为每一侧设置颜色。
答案1
这应该可以让你入门了。还可以做更多的润色,但留作练习。
\documentclass{article}
\usepackage{tikz}
\tikzset{%
pics/.cd,
mynode/.style args={#1#2#3}{
code={\node (a) {#3};
\draw[thick,#1] (a.south west) |- (a.north east);
\draw[thick,#2] (a.south west) -| (a.north east);
}
},
}
\begin{document}
\begin{tikzpicture}
\pic {mynode={red}{blue}{Here}};
\pic at (4,0) {mynode={olive}{magenta}{Here comes another one}};
\end{tikzpicture}
\end{document}
\documentclass{article}
\usepackage{tikz}
\tikzset{%
pics/.cd,
mynode/.style args={#1#2#3}{
code={\node (a) {#3};
\draw[thick,#1,line cap=butt,shorten <= -0.5\pgflinewidth,shorten >= 0.5\pgflinewidth] (a.south west) |- (a.north east);
\draw[thick,#2,line cap=butt,shorten <= 0.5\pgflinewidth,shorten >= -0.5\pgflinewidth] (a.south west) -| (a.north east);
}
},
}
\begin{document}
\begin{tikzpicture}
\pic {mynode={red}{blue}{Here}};
\pic at (4,0) {mynode={olive}{magenta}{Here comes another one}};
\end{tikzpicture}
\end{document}