我想复制这个图片使用 TikZ。元素 X 可以简单地使用矩形和“圆角”属性来制作。但 EPN 却将其角切掉(形成八边形)。是否有任何像圆角这样的简单命令可以做到这一点?
答案1
该形状chamfered rectangle
已存在于shapes.misc
库中:
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\begin{document}
\begin{tikzpicture}
\node[draw=red,chamfered rectangle,fill=red!30]
{some text};
\end{tikzpicture}
\end{document}
以及附加图像的一些代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,fit,positioning}
\begin{document}
\begin{tikzpicture}[line width=1pt]
\node[draw,rounded corners,minimum size=1cm]
(x) {X};
\node[draw,circle,below=2pt of x,minimum size=1cm]
(y) {Y};
\coordinate (aux) at ([xshift=-60pt]x);
\node[draw=red,chamfered rectangle,fit={(aux) (x) (y)}]
{};
\end{tikzpicture}
\end{document}
下面是图像其他组件的一些代码,使用 fit 库和一些层:
\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,fit,positioning}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{document}
\begin{tikzpicture}[
common/.style={
draw,
line width=1pt,
fill=yellow!30,
},
cal/.style={
common,
rounded corners,
minimum height=1.2cm
},
ca/.style={
common,
circle,
minimum height=1.2cm
},
conn/.style={
draw,
line width=1pt,
fill=green!70!black
},
frame/.style={
common,
draw=red,
chamfered rectangle
},
>=latex
]
\node[cal]
(call) {Calmodulin};
\node[conn,right=of call]
(gcon) {};
\coordinate[right=of gcon] (aux);
\node[cal,right=of aux]
(calr) {Calmodulin};
\node[ca,above=1.5cm of calr.east,anchor=east]
(car) {\ce{Ca^{2+}}};
\begin{pgfonlayer}{background}
\node[frame,fit={(aux) (calr) (car)}]
(frame) {};
\end{pgfonlayer}
\node[ca,above right=1cm and -10pt of call]
(cal) {\ce{Ca^{2+}}};
\draw[->]
(gcon) -- (call);
\draw[->]
(gcon) -- (frame.west|-calr.west);
\draw[->]
(gcon) to[bend left] (cal.south);
\end{tikzpicture}
\end{document}
使用pic
s 可以简化代码。