创造的最佳方式是什么一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}