![带颜色节点的 Tikz 矩阵(交通灯)](https://linux22.com/image/480764/%E5%B8%A6%E9%A2%9C%E8%89%B2%E8%8A%82%E7%82%B9%E7%9A%84%20Tikz%20%E7%9F%A9%E9%98%B5%EF%BC%88%E4%BA%A4%E9%80%9A%E7%81%AF%EF%BC%89.png)
我正在尝试调整交通灯命令(从之前问题的一些答案中找到),使得节点(圆圈)的边框变为黑色(draw = black!100
里面的线nodes
),但似乎draw = black!100
没有任何改变。
\documentclass[a4paper,fontsize=12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit, matrix, positioning}
\newcommand\trafficlight[3]
{
\begin{tikzpicture}[baseline=-1.5mm]
\matrix (m) [matrix of nodes,
ampersand replacement = \&,
rounded corners,
draw = blue!100,
% fill = blue!30,
column sep = 1.5mm,
nodes = {circle, draw = black!100, fill = #1, minimum size = 5mm, inner sep = 0mm,
anchor = center},
]
{
|[#1]| \& |[#2]| \& |[#3]| \\
};
\end{tikzpicture}
}
\begin{document}
\trafficlight{red}{yellow}{green}
\end{document}
我将非常感激任何帮助!
答案1
|[#1]|
设置绘制和填充颜色。尝试:
\documentclass[a4paper,fontsize=12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit, matrix, positioning}
\newcommand\trafficlight[3]
{
\begin{tikzpicture}[baseline=-1.5mm]
\matrix (m) [matrix of nodes,
ampersand replacement = \&,
rounded corners,
draw = blue,
% fill = blue!30,
column sep = 1.5mm,
nodes = {circle, draw = black, fill = #1, minimum size = 5mm, inner sep = 0mm,
anchor = center},
]
{
|[fill=#1]| \& |[fill=#2]| \& |[fill=#3]| \\
};
\end{tikzpicture}
}
\begin{document}
\trafficlight{red}{yellow}{green}
\end{document}
顺便说一句,fontsize
不是一个有效的选项(12pt
是),并且black!100
与 相同black
。此外,您的宏在 周围添加了几个空格...