명령 뒤에 추가할 때 \tikzlastnode의 선 스타일과 색상을 사용합니다.

명령 뒤에 추가할 때 \tikzlastnode의 선 스타일과 색상을 사용합니다.

나는 아래의 원자 기호 색상과 스타일을 둘러싸는 노드 스타일과 동일하게 만들고 싶습니다. 어떻게 해야 하나요? 의 선 스타일을 참조할 수 있는 방법이 있습니까 \tikzlastnode?

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\begin{document}
\title{science symbol}
\begin{tikzpicture}[>=latex,
  font=\sffamily,
  atom/.style = {circle, minimum size=#1,
    append after command={%
      \pgfextra{ 
        \foreach \ang in {0,120,240}
        \draw[rotate around={\ang:(0,0)}] (\tikzlastnode.center) ellipse (0.45*#1 and 0.15*#1); 
        \fill (\tikzlastnode.center) circle (0.05*#1);
      }
    }
  }
]

\node[draw, atom=10mm] (C1) at (0,0){};
\node[draw, very thin, red, atom=10mm] (C2) at (2cm,0){};
\node[draw, thick, green, atom=10mm] (C3) at (2cm,2cm){};
\draw[->] (C1) -- (C2);
\draw[->] (C1) -- (C3);

\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변1

\pgfdeclareshape나는 이 문제 를 다시 헤쳐나가며 append after command. (왜 이런 짓을 하면 항상 괴로운 승리처럼 느껴지나요???) 제가 사용한 다른 참고 질문은 다음과 같습니다.

\pgfdeclareshape하지만 그것은 기본적으로 모양 에서 작업하는 데 사용하는 방법이었습니다 circle. 참조https://svn.ssec.wisc.edu/repos/geoffc/LaTeX/beamerposter_UW-SSEC/pgfmoduleshapes.code.tex소스 코드용.

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\begin{document}
\title{science symbol}
\pgfdeclareshape{atomshape}{%
  \inheritsavedanchors[from=circle]%
  \inheritanchorborder[from=circle]%
  \inheritanchor[from=circle]{center}%
  %
  \backgroundpath{%
    \pgfpathcircle{\pgfpointorigin}{0.1*\radius}
    \pgfusepath{fill}
    \pgfpathcircle{\pgfpointorigin}{\radius}%
    \foreach\ang in {0,120,240}{
      \pgftransformrotate{\ang}
      \pgfpathellipse{\pgfpointorigin} 
                 {\pgfpoint{0.9*\radius}{0cm}} 
                 {\pgfpoint{0cm}{0.3*\radius}}
    }
  }%
}
\begin{tikzpicture}[>=latex,
  font=\sffamily,
  atom/.style = {atomshape, minimum size=#1}
]

\node[draw, atom=10mm] (C1) at (0,0){};
\node[draw, very thin, red, atom=10mm] (C2) at (2cm,0){};
\node[draw, thick, green, atom=10mm] (C3) at (2cm,2cm){};
\draw[->] (C1) -- (C2);
\draw[->] (C1) -- (C3);

\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보