当每个节点的标签不同时定义节点样式

当每个节点的标签不同时定义节点样式

有没有办法减少我必须为以下图形编写的 TikZ 代码量?除了特定的标签文本及其定位外,每个节点都有相同的参数,所以我一开始就想到定义一个通用的节点样式。但是,我不确定它如何与我需要用于放置标签的特定命令配合使用。

在此处输入图片描述

\documentclass[12pt,ngerman]{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=2]

    \draw[dashed, color=cyan!50] (0,0) circle (1cm);
    \node[align=center, scale=1.5] (tmp) at (0,0) {Bildungs-\\standards};

    \node[circle, inner sep=1pt, draw=blue, fill=white, fill=orange] (A) at (1,0) {};
    \node[circle, inner sep=1pt, draw=blue, fill=white, fill=orange] (B) at ({cos(60)},{sin(60)}) {};
    \node[circle, inner sep=1pt, draw=blue, fill=white, fill=orange] (C) at ({cos(120)},{sin(120)}) {};
    \node[circle, inner sep=1pt, draw=blue, fill=white, fill=orange] (D) at ({cos(180)},{sin(180)}) {};
    \node[circle, inner sep=1pt, draw=blue, fill=white, fill=orange] (E) at ({cos(240)},{sin(240)}) {};
    \node[circle, inner sep=1pt, draw=blue, fill=white, fill=orange] (F) at ({cos(300)},{sin(300)}) {};
    \draw[blue!50!black!50] (A)--(B)--(C)--(D)--(E)--(F)--(A);

    \node[label={[label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20]0: K1: Mathematisch\\ argumentieren}] (a) at (1,0) {};
    \node[label={[label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20]60: K2: Probleme\\ mathematisch l\"osen}] (b) at ({cos(60)},{sin(60)}) {};
    \node[label={[label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20]120: K3: Mathematisch\\ modellieren}] (c) at ({cos(120)},{sin(120)}) {};
    \node[label={[label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20]180: K4: Mathematische.\\ Darst. verwenden}] (d) at ({cos(180)},{sin(180)}) {};
    \node[label={[label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20]-120: K5: Mit symbolischen\\ Elementen umgehen}] (e) at ({cos(240)},{sin(240)}) {};
    \node[label={[label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20]-60: K6: Mathematisch\\kommunizieren}] (f) at ({cos(300)},{sin(300)}) {};

    \end{tikzpicture}

\end{document}

答案1

当然可以。第一步是定义节点和标签的样式,例如

\documentclass[12pt,ngerman]{article}
\usepackage{tikz}
\begin{document}
 \begin{tikzpicture}[scale=2,
    bullet/.style={circle, inner sep=1pt, draw=blue, fill=white, fill=orange},
    every label/.style={label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20}
    ]

    \draw[dashed, color=cyan!50] (0,0) circle (1cm);
    \node[align=center, scale=1.5] (tmp) at (0,0) {Bildungs-\\standards};

    \node[bullet,label={0:K1: Mathematisch\\ argumentieren}] (A) at (0:1) {};
    \node[bullet,label={60:K2: Probleme\\ mathematisch l\"osen}] (B) at (60:1) {};
    \node[bullet,label={120:K3: Mathematisch\\ modellieren}] (C) at (120:1) {};
    \node[bullet,label={180:K4: Mathematische.\\ Darst. verwenden}] (D) at (180:1) {};
    \node[bullet,label={240:K5: Mit symbolischen\\ Elementen umgehen}] (E) at (240:1) {};
    \node[bullet,label={300:K6: Mathematisch\\kommunizieren}] (F) at (300:1) {};
    \draw[blue!50!black!50] (A)--(B)--(C)--(D)--(E)--(F)--(A);
 \end{tikzpicture}

\end{document}

在此处输入图片描述

但是您可以使用库中的循环和六边形进一步简化它shapes.geometric

\documentclass[12pt,ngerman]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
 \begin{tikzpicture}[scale=2,
    bullet/.style={circle, inner sep=1pt, draw=blue, fill=white, fill=orange},
    every label/.style={label distance=.1cm, align=left, rectangle, draw=blue!50!black!50, fill=blue!20}
    ]
   \draw[dashed, color=cyan!50] (0,0) circle[radius=1cm];       
   \node[regular polygon,regular polygon sides=6,draw=blue!50!black!50,
    minimum width=4cm,align=center, shape border uses incircle,
    shape border rotate=-60] (6gon){Bildungs-\\standards};
   \foreach \Text [count=\X] in {{Mathematisch\\ argumentieren},
   {Probleme\\ mathematisch l\"osen},
   {Mathematisch\\ modellieren},
   {Mathematische.\\ Darst.\ verwenden},
   {Mit symbolischen\\ Elementen umgehen},
   {Mathematisch\\kommunizieren}}
   {\node[bullet,label=-60+60*\X:K\X\space:\Text] at (6gon.corner \X) {};}
 \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容