TikZ:创建一个节点(PSE 单元)

TikZ:创建一个节点(PSE 单元)

创造的最佳方式是什么TikZ-node 像这样吗?

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\pgfmathsetlengthmacro\cellwidth{12mm}

\begin{document}
\begin{tikzpicture}[
Cell/.style={align=center, inner sep=0pt, 
text width=\cellwidth,
minimum height=\cellwidth,
draw=black, fill=purple, 
font=\sffamily
},
]

\node[Cell]{Ba};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

labels也可以写在里面nodes

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\newcommand{\cell}[7][]{
    \node[minimum size=7em, draw, font=\huge, 
        label={[anchor=north west]north west:#4},
        label={[anchor=north east]north east:#5},
        label={[anchor=south west]south west:#6},
        label={[anchor=south east]south east:#7},
        label={[anchor=south,yshift=3.5ex, font=\small]south:#3},
    #1] (#2) {#2};
}

\begin{tikzpicture}
\cell[fill=purple]{Ba}{Barium}{137.328}{56}{3.59}{0.89}
\cell[fill=red!30, below=0pt of Ba]{Li}{Litium}{137.328}{56}{3.59}{0.89}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

像这样

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}

\pgfmathsetlengthmacro\cellwidth{12mm}

\begin{document}

\newcommand{\cell}[6]{
\node[minimum size=7em,draw,fill=purple] (symb) {\huge #1};
\node[below =0.5em of symb.center]{\small #2};
\node[below left=0em of symb.north east](mass){#3};
\node[below right=0em of symb.north west](nb){#4};
\node[above left=0em of symb.south east](n5){#5};
\node[above right=0em of symb.south west](n6){#6};
}

\begin{tikzpicture}
\cell{Ba}{Barium}{137,328}{56}{3,59}{0,89}


\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容