带键值的元素周期表命令

带键值的元素周期表命令

我想创建一个\TabPeriodique带有一些可选参数的命令来插入元素周期表。我从以下网址找到了元素周期表的代码这里

首先,有时我需要一个没有元素名称的元素周期表。我添加了一个布尔值ActivateName并自定义\CommonElementTextFormat命令来区分这两种情况。

其次,为了让表格适合页面,我想更改 Tikz 环境的比例因子。因此我添加了一个可选参数。

但要明确一点,我想更改这些功能,例如 pgf 键选项。因此我可以这样写

\TabPeriodique[ActivateName=true, scale=0.8]

代替

\setbool{ActivateName}{true}
\TabPeriodique[0.8]

我读过一些关于 pgf 密钥的主题(这里) 但我无法实现我的目标。如何在这样的表中包含一些可选命令的键?

这是一个 MWE(我试图使它变得最小,但我们需要所有节点来保持一致性......):

%%Extract from : http://www.texample.net/tikz/examples/periodic-table-of-chemical-elements/
%% Copyright 2009 Ivan Griffin
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Ivan Griffin
%
% This work consists of the files periodic_table.tex

%Description
%-----------
%periodic_table.tex - an example file illustrating the Periodic
%                     Table of Chemical Elements using TikZ

%Created 2009-12-08 by Ivan Griffin.  Last updated: 2010-01-11
%
%Thanks to Jerome
%-------------------------------------------------------------

\documentclass[landscape]{standalone}
\usepackage{ifpdf}
\usepackage[french]{babel}
\pagestyle{empty}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,calc}


\usepackage{etoolbox}
\newbool{ActivateName}
\setbool{ActivateName}{false}

\newcommand{\CommonElementTextFormat}[4]
{
    \ifbool{ActivateName}
    {%%%With Name
            \begin{minipage}{2.2cm}
                \centering
                {\textbf{#1} \hfill #2}%
                \linebreak \linebreak
                {\textbf{#3}}%
                \linebreak \linebreak
                {\large {#4}}
            \end{minipage}
    }
    {%%%Without Name
    \begin{minipage}{2.2cm}
        {\large\textbf{\fbox{#1}}}
        \begin{center}
            \textbf{#3}
        \end{center}
        {\large #2}
    \end{minipage}
    }
}

\newcommand{\NaturalElementTextFormat}[4]
{
    \CommonElementTextFormat{#1}{#2}{\LARGE {#3}}{#4}
}

\newcommand{\OutlineText}[1]
{
    \ifpdf
    % Couldn't find a nicer way of doing an outline font with TikZ
    % other than using pdfliteral 1 Tr
    %
    \pdfliteral direct {0.5 w 1 Tr}{#1}%
    \pdfliteral direct {1 w 0 Tr}%
    \else
    % pstricks can do this with \pscharpath from pstricks
    %
    \pscharpath[shadow=false,
    fillstyle=solid,
    fillcolor=white,
    linestyle=solid,
    linecolor=black,
    linewidth=.2pt]{#1} 
    \fi
}

\newcommand{\SyntheticElementTextFormat}[4]
{
    \ifpdf
    \CommonElementTextFormat{#1}{#2}{\OutlineText{\LARGE #3}}{#4}
    \else
    % pstricks approach results in slightly larger box
    % that doesn't break, so fudge here
    \CommonElementTextFormat{#1}{#2}{\OutlineText{\Large #3}}{#4}
    \fi
}

    \newcommand{\TabPeriodique}[1][0.55]{\begin{tikzpicture}[font=\sffamily, scale=#1, transform shape]

    %% Fill Color Styles
    \tikzstyle{ElementFill} = [fill=yellow!15]
    \tikzstyle{AlkaliMetalFill} = [fill=blue!55]
    \tikzstyle{AlkalineEarthMetalFill} = [fill=blue!40]
    \tikzstyle{MetalFill} = [fill=blue!25]
    \tikzstyle{MetalloidFill} = [fill=orange!25]
    \tikzstyle{NonmetalFill} = [fill=green!25]
    \tikzstyle{HalogenFill} = [fill=green!40]
    \tikzstyle{NobleGasFill} = [fill=green!55]
    \tikzstyle{LanthanideActinideFill} = [fill=purple!25]

    %% Element Styles
    \tikzstyle{Element} = [draw=black, ElementFill,
    minimum width=2.75cm, minimum height=2.75cm, node distance=2.75cm]
    \tikzstyle{AlkaliMetal} = [Element, AlkaliMetalFill]
    \tikzstyle{AlkalineEarthMetal} = [Element, AlkalineEarthMetalFill]
    \tikzstyle{Metal} = [Element, MetalFill]
    \tikzstyle{Metalloid} = [Element, MetalloidFill]
    \tikzstyle{Nonmetal} = [Element, NonmetalFill]
    \tikzstyle{Halogen} = [Element, HalogenFill]
    \tikzstyle{NobleGas} = [Element, NobleGasFill]
    \tikzstyle{LanthanideActinide} = [Element, LanthanideActinideFill]
    \tikzstyle{PeriodLabel} = [font={\sffamily\LARGE}, node distance=2.0cm]
    \tikzstyle{GroupLabel} = [font={\sffamily\LARGE}, minimum width=2.75cm, node distance=2.0cm]
    \tikzstyle{TitleLabel} = [font={\sffamily\Huge\bfseries}]

    %% Group 1 - IA
    \node[name=H, Element] {\NaturalElementTextFormat{1}{1.0079}{H}{Hydrogène}};
    \node[name=Li, below of=H, AlkaliMetal] {\NaturalElementTextFormat{3}{6.941}{Li}{Lithium}};
    \node[name=Na, below of=Li, AlkaliMetal] {\NaturalElementTextFormat{11}{22.990}{Na}{Sodium}};
    \node[name=K, below of=Na, AlkaliMetal] {\NaturalElementTextFormat{19}{39.098}{K}{Potassium}};
    \node[name=Rb, below of=K, AlkaliMetal] {\NaturalElementTextFormat{37}{85.468}{Rb}{Rubidium}};
    \node[name=Cs, below of=Rb, AlkaliMetal] {\NaturalElementTextFormat{55}{132.91}{Cs}{Césium}};
    \node[name=Fr, below of=Cs, AlkaliMetal] {\NaturalElementTextFormat{87}{223}{Fr}{Francium}};

    %% Group 2 - IIA
    \node[name=Be, right of=Li, AlkalineEarthMetal] {\NaturalElementTextFormat{4}{9.0122}{Be}{Beryllium}};
    \node[name=Mg, below of=Be, AlkalineEarthMetal] {\NaturalElementTextFormat{12}{24.305}{Mg}{Magnésium}};
    \node[name=Ca, below of=Mg, AlkalineEarthMetal] {\NaturalElementTextFormat{20}{40.078}{Ca}{Calcium}};
    \node[name=Sr, below of=Ca, AlkalineEarthMetal] {\NaturalElementTextFormat{38}{87.62}{Sr}{Strontium}};
    \node[name=Ba, below of=Sr, AlkalineEarthMetal] {\NaturalElementTextFormat{56}{137.33}{Ba}{Barium}};
    \node[name=Ra, below of=Ba, AlkalineEarthMetal] {\NaturalElementTextFormat{88}{226}{Ra}{Radium}};

    %% Group 3 - IIIB
    \node[name=Sc, right of=Ca, Metal] {\NaturalElementTextFormat{21}{44.956}{Sc}{Scandium}};
    \node[name=Y, below of=Sc, Metal] {\NaturalElementTextFormat{39}{88.906}{Y}{Yttrium}};
    \node[name=LaLu, below of=Y, LanthanideActinide] {\NaturalElementTextFormat{57-71}{}{La-Lu\ifbool{ActivateName}{}{\linebreak\linebreak}}{Lanthanide}};
    \node[name=AcLr, below of=LaLu, LanthanideActinide] {\NaturalElementTextFormat{89-103}{}{Ac-Lr\ifbool{ActivateName}{}{\linebreak\linebreak}}{Actinide}};

    %% Group 4 - IVB
    \node[name=Ti, right of=Sc, Metal] {\NaturalElementTextFormat{22}{47.867}{Ti}{Titane}};
    \node[name=Zr, below of=Ti, Metal] {\NaturalElementTextFormat{40}{91.224}{Zr}{Zirconium}};
    \node[name=Hf, below of=Zr, Metal] {\NaturalElementTextFormat{72}{178.49}{Hf}{Halfnium}};
    \node[name=Rf, below of=Hf, Metal] {\SyntheticElementTextFormat{104}{261}{Rf}{Rutherfordium}};

    %% Group 5 - VB
    \node[name=V, right of=Ti, Metal] {\NaturalElementTextFormat{23}{50.942}{V}{Vanadium}};
    \node[name=Nb, below of=V, Metal] {\NaturalElementTextFormat{41}{92.906}{Nb}{Niobium}};
    \node[name=Ta, below of=Nb, Metal] {\NaturalElementTextFormat{73}{180.95}{Ta}{Tantale}};
    \node[name=Db, below of=Ta, Metal] {\SyntheticElementTextFormat{105}{262}{Db}{Dubnium}};

    %% Group 6 - VIB
    \node[name=Cr, right of=V, Metal] {\NaturalElementTextFormat{24}{51.996}{Cr}{Chrome}};
    \node[name=Mo, below of=Cr, Metal] {\NaturalElementTextFormat{42}{95.94}{Mo}{Molybdène}};
    \node[name=W, below of=Mo, Metal] {\NaturalElementTextFormat{74}{183.84}{W}{Tungstène}};
    \node[name=Sg, below of=W, Metal] {\SyntheticElementTextFormat{106}{266}{Sg}{Seaborgium}};

    %% Group 7 - VIIB
    \node[name=Mn, right of=Cr, Metal] {\NaturalElementTextFormat{25}{54.938}{Mn}{Manganèse}};
    \node[name=Tc, below of=Mn, Metal] {\NaturalElementTextFormat{43}{96}{Tc}{Technétium}};
    \node[name=Re, below of=Tc, Metal] {\NaturalElementTextFormat{75}{186.21}{Re}{Rhénium}};
    \node[name=Bh, below of=Re, Metal] {\SyntheticElementTextFormat{107}{264}{Bh}{Bohrium}};

    %% Group 8 - VIIIB
    \node[name=Fe, right of=Mn, Metal] {\NaturalElementTextFormat{26}{55.845}{Fe}{Fer}};
    \node[name=Ru, below of=Fe, Metal] {\NaturalElementTextFormat{44}{101.07}{Ru}{Ruthénium}};
    \node[name=Os, below of=Ru, Metal] {\NaturalElementTextFormat{76}{190.23}{Os}{Osmium}};
    \node[name=Hs, below of=Os, Metal] {\SyntheticElementTextFormat{108}{277}{Hs}{Hassium}};

    %% Group 9 - VIIIB
    \node[name=Co, right of=Fe, Metal] {\NaturalElementTextFormat{27}{58.933}{Co}{Cobalt}};
    \node[name=Rh, below of=Co, Metal] {\NaturalElementTextFormat{45}{102.91}{Rh}{Rhodium}};
    \node[name=Ir, below of=Rh, Metal] {\NaturalElementTextFormat{77}{192.22}{Ir}{Iridium}};
    \node[name=Mt, below of=Ir, Metal] {\SyntheticElementTextFormat{109}{268}{Mt}{Meitnerium}};

    %% Group 10 - VIIIB
    \node[name=Ni, right of=Co, Metal] {\NaturalElementTextFormat{28}{58.693}{Ni}{Nickel}};
    \node[name=Pd, below of=Ni, Metal] {\NaturalElementTextFormat{46}{106.42}{Pd}{Palladium}};
    \node[name=Pt, below of=Pd, Metal] {\NaturalElementTextFormat{78}{195.08}{Pt}{Platine}};
    \node[name=Ds, below of=Pt, Metal] {\SyntheticElementTextFormat{110}{281}{Ds}{Darmstadtium}};

    %% Group 11 - IB
    \node[name=Cu, right of=Ni, Metal] {\NaturalElementTextFormat{29}{63.546}{Cu}{Cuivre}};
    \node[name=Ag, below of=Cu, Metal] {\NaturalElementTextFormat{47}{107.87}{Ag}{Argent}};
    \node[name=Au, below of=Ag, Metal] {\NaturalElementTextFormat{79}{196.97}{Au}{Or}};
    \node[name=Rg, below of=Au, Metal] {\SyntheticElementTextFormat{111}{280}{Rg}{Roentgenium}};

    %% Group 12 - IIB
    \node[name=Zn, right of=Cu, Metal] {\NaturalElementTextFormat{30}{65.39}{Zn}{Zinc}};
    \node[name=Cd, below of=Zn, Metal] {\NaturalElementTextFormat{48}{112.41}{Cd}{Cadmium}};
    \node[name=Hg, below of=Cd, Metal] {\NaturalElementTextFormat{80}{200.59}{Hg}{Mercure}};
    \node[name=Uub, below of=Hg, Metal] {\SyntheticElementTextFormat{112}{285}{Uub}{Ununbium}};

    %% Group 13 - IIIA
    \node[name=Ga, right of=Zn, Metal] {\NaturalElementTextFormat{31}{69.723}{Ga}{Gallium}};
    \node[name=Al, above of=Ga, Metal] {\NaturalElementTextFormat{13}{26.982}{Al}{Aluminium}};
    \node[name=B, above of=Al, Metalloid] {\NaturalElementTextFormat{5}{10.811}{B}{Bore}};
    \node[name=In, below of=Ga, Metal] {\NaturalElementTextFormat{49}{114.82}{In}{Indium}};
    \node[name=Tl, below of=In, Metal] {\NaturalElementTextFormat{81}{204.38}{Tl}{Thallium}};
    \node[name=Uut, below of=Tl, Metal] {\SyntheticElementTextFormat{113}{284}{Uut}{Ununtrium}};

    %% Group 14 - IVA
    \node[name=C, right of=B, Nonmetal] {\NaturalElementTextFormat{6}{12.011}{C}{Carbone}};
    \node[name=Si, below of=C, Metalloid] {\NaturalElementTextFormat{14}{28.086}{Si}{Silicium}};
    \node[name=Ge, below of=Si, Metalloid] {\NaturalElementTextFormat{32}{72.64}{Ge}{Germanium}};
    \node[name=Sn, below of=Ge, Metal] {\NaturalElementTextFormat{50}{118.71}{Sn}{Etain}};
    \node[name=Pb, below of=Sn, Metal] {\NaturalElementTextFormat{82}{207.2}{Pb}{Plomb}};
    \node[name=Uuq, below of=Pb, Metal] {\SyntheticElementTextFormat{114}{289}{Uuq}{Ununquadium}};

    %% Group 15 - VA
    \node[name=N, right of=C, Nonmetal] {\NaturalElementTextFormat{7}{14.007}{N}{Azote}};
    \node[name=P, below of=N, Nonmetal] {\NaturalElementTextFormat{15}{30.974}{P}{Phosphore}};
    \node[name=As, below of=P, Metalloid] {\NaturalElementTextFormat{33}{74.922}{As}{Arsenic}};
    \node[name=Sb, below of=As, Metalloid] {\NaturalElementTextFormat{51}{121.76}{Sb}{Antimoine}};
    \node[name=Bi, below of=Sb, Metal] {\NaturalElementTextFormat{83}{208.98}{Bi}{Bismuth}};
    \node[name=Uup, below of=Bi, Metal] {\SyntheticElementTextFormat{115}{288}{Uup}{Ununpentium}};

    %% Group 16 - VIA
    \node[name=O, right of=N, Nonmetal] {\NaturalElementTextFormat{8}{15.999}{O}{Oxygène}};
    \node[name=S, below of=O, Nonmetal] {\NaturalElementTextFormat{16}{32.065}{S}{Soufre}};
    \node[name=Se, below of=S, Nonmetal] {\NaturalElementTextFormat{34}{78.96}{Se}{Sélenium}};
    \node[name=Te, below of=Se, Metalloid] {\NaturalElementTextFormat{52}{127.6}{Te}{Tellure}};
    \node[name=Po, below of=Te, Metalloid] {\NaturalElementTextFormat{84}{209}{Po}{Polonium}};
    \node[name=Uuh, below of=Po, Metal] {\SyntheticElementTextFormat{116}{293}{Uuh}{Ununhexium}};

    %% Group 17 - VIIA
    \node[name=F, right of=O, Halogen] {\NaturalElementTextFormat{9}{18.998}{F}{Fluor}};
    \node[name=Cl, below of=F, Halogen] {\NaturalElementTextFormat{17}{35.453}{Cl}{Chlore}};
    \node[name=Br, below of=Cl, Halogen] {\NaturalElementTextFormat{35}{79.904}{Br}{Brome}};
    \node[name=I, below of=Br, Halogen] {\NaturalElementTextFormat{53}{126.9}{I}{Iode}};
    \node[name=At, below of=I, Halogen] {\NaturalElementTextFormat{85}{210}{At}{Astatine}};
    \node[name=Uus, below of=At, Element] {\SyntheticElementTextFormat{117}{292}{Uus}{Ununseptium}}; 

    %% Group 18 - VIIIA
    \node[name=Ne, right of=F, NobleGas] {\NaturalElementTextFormat{10}{20.180}{Ne}{Néon}};
    \node[name=He, above of=Ne, NobleGas] {\NaturalElementTextFormat{2}{4.0025}{He}{Hélium}};
    \node[name=Ar, below of=Ne, NobleGas] {\NaturalElementTextFormat{18}{39.948}{Ar}{Argon}};
    \node[name=Kr, below of=Ar, NobleGas] {\NaturalElementTextFormat{36}{83.8}{Kr}{Krypton}};
    \node[name=Xe, below of=Kr, NobleGas] {\NaturalElementTextFormat{54}{131.29}{Xe}{Xénon}};
    \node[name=Rn, below of=Xe, NobleGas] {\NaturalElementTextFormat{86}{222}{Rn}{Radon}};
    \node[name=Uuo, below of=Rn, Nonmetal] {\SyntheticElementTextFormat{118}{294}{Uuo}{Ununoctium}}; 

    %% Period
    \node[name=Period1, left of=H, PeriodLabel] {1};
    \node[name=Period2, left of=Li, PeriodLabel] {2};
    \node[name=Period3, left of=Na, PeriodLabel] {3}; 
    \node[name=Period4, left of=K, PeriodLabel] {4}; 
    \node[name=Period5, left of=Rb, PeriodLabel] {5};
    \node[name=Period6, left of=Cs, PeriodLabel] {6};
    \node[name=Period7, left of=Fr, PeriodLabel] {7};

    %% Group
    \node[name=Group1, above of=H, GroupLabel] {1 \hfill IA};
    \node[name=Group2, above of=Be, GroupLabel] {2 \hfill IIA};
    \node[name=Group3, above of=Sc, GroupLabel] {3 \hfill IIIA};
    \node[name=Group4, above of=Ti, GroupLabel] {4 \hfill IVB};
    \node[name=Group5, above of=V, GroupLabel] {5 \hfill VB};
    \node[name=Group6, above of=Cr, GroupLabel] {6 \hfill VIB};
    \node[name=Group7, above of=Mn, GroupLabel] {7 \hfill VIIB};
    \node[name=Group8, above of=Fe, GroupLabel] {8 \hfill VIIIB};
    \node[name=Group9, above of=Co, GroupLabel] {9 \hfill VIIIB};
    \node[name=Group10, above of=Ni, GroupLabel] {10 \hfill VIIIB};
    \node[name=Group11, above of=Cu, GroupLabel] {11 \hfill IB};
    \node[name=Group12, above of=Zn, GroupLabel] {12 \hfill IIB};
    \node[name=Group13, above of=B, GroupLabel] {13 \hfill IIIA};
    \node[name=Group14, above of=C, GroupLabel] {14 \hfill IVA};
    \node[name=Group15, above of=N, GroupLabel] {15 \hfill VA};
    \node[name=Group16, above of=O, GroupLabel] {16 \hfill VIA};
    \node[name=Group17, above of=F, GroupLabel] {17 \hfill VIIA};
    \node[name=Group18, above of=He, GroupLabel] {18 \hfill VIIIA};

    %% Lanthanide
    \node[name=La, below of=Rf, LanthanideActinide, yshift=-1cm] {\NaturalElementTextFormat{57}{138.91}{La}{Lanthanum}};
    \node[name=Ce, right of=La, LanthanideActinide] {\NaturalElementTextFormat{58}{140.12}{Ce}{Cerium}};
    \node[name=Pr, right of=Ce, LanthanideActinide] {\NaturalElementTextFormat{59}{140.91}{Pr}{Praseodymium}};
    \node[name=Nd, right of=Pr, LanthanideActinide] {\NaturalElementTextFormat{60}{144.24}{Nd}{Neodymium}};
    \node[name=Pm, right of=Nd, LanthanideActinide] {\NaturalElementTextFormat{61}{145}{Pm}{Promethium}};
    \node[name=Sm, right of=Pm, LanthanideActinide] {\NaturalElementTextFormat{62}{150.36}{Sm}{Samarium}};
    \node[name=Eu, right of=Sm, LanthanideActinide] {\NaturalElementTextFormat{63}{151.96}{Eu}{Europium}};
    \node[name=Gd, right of=Eu, LanthanideActinide] {\NaturalElementTextFormat{64}{157.25}{Gd}{Gadolinium}};
    \node[name=Tb, right of=Gd, LanthanideActinide] {\NaturalElementTextFormat{65}{158.93}{Tb}{Terbium}};
    \node[name=Dy, right of=Tb, LanthanideActinide] {\NaturalElementTextFormat{66}{162.50}{Dy}{Dysprosium}};
    \node[name=Ho, right of=Dy, LanthanideActinide] {\NaturalElementTextFormat{67}{164.93}{Ho}{Holmium}};
    \node[name=Er, right of=Ho, LanthanideActinide] {\NaturalElementTextFormat{68}{167.26}{Er}{Erbium}};
    \node[name=Tm, right of=Er, LanthanideActinide] {\NaturalElementTextFormat{69}{168.93}{Tm}{Thulium}};
    \node[name=Yb, right of=Tm, LanthanideActinide] {\NaturalElementTextFormat{70}{173.04}{Yb}{Ytterbium}};
    \node[name=Lu, right of=Yb, LanthanideActinide] {\NaturalElementTextFormat{71}{174.97}{Lu}{Lutetium}};

    %% Actinide
    \node[name=Ac, below of=La, LanthanideActinide, yshift=-1cm] {\NaturalElementTextFormat{89}{227}{Ac}{Actinium}};
    \node[name=Th, right of=Ac, LanthanideActinide] {\NaturalElementTextFormat{90}{232.04}{Th}{Thorium}};
    \node[name=Pa, right of=Th, LanthanideActinide] {\NaturalElementTextFormat{91}{231.04}{Pa}{Protactinium}};
    \node[name=U, right of=Pa, LanthanideActinide] {\NaturalElementTextFormat{92}{238.03}{U}{Uranium}};
    \node[name=Np, right of=U, LanthanideActinide] {\SyntheticElementTextFormat{93}{237}{Np}{Neptunium}};
    \node[name=Pu, right of=Np, LanthanideActinide] {\SyntheticElementTextFormat{94}{244}{Pu}{Plutonium}};
    \node[name=Am, right of=Pu, LanthanideActinide] {\SyntheticElementTextFormat{95}{243}{Am}{Americium}};
    \node[name=Cm, right of=Am, LanthanideActinide] {\SyntheticElementTextFormat{96}{247}{Cm}{Curium}};
    \node[name=Bk, right of=Cm, LanthanideActinide] {\SyntheticElementTextFormat{97}{247}{Bk}{Berkelium}};
    \node[name=Cf, right of=Bk, LanthanideActinide] {\SyntheticElementTextFormat{98}{251}{Cf}{Californium}};
    \node[name=Es, right of=Cf, LanthanideActinide] {\SyntheticElementTextFormat{99}{252}{Es}{Einsteinium}};
    \node[name=Fm, right of=Es, LanthanideActinide] {\SyntheticElementTextFormat{100}{257}{Fm}{Fermium}};
    \node[name=Md, right of=Fm, LanthanideActinide] {\SyntheticElementTextFormat{101}{258}{Md}{Mendelevium}};
    \node[name=No, right of=Md, LanthanideActinide] {\SyntheticElementTextFormat{102}{259}{No}{Nobelium}};
    \node[name=Lr, right of=No, LanthanideActinide] {\SyntheticElementTextFormat{103}{262}{Lr}{Lawrencium}};

    %% Draw dotted lines connecting Lanthanide breakout to main table
    \draw (LaLu.north west) edge[dotted] (La.north west)
%   (LaLu.north east) edge[dotted] (Lu.north east)
    (LaLu.south west) edge[dotted] (La.south west);
%   (LaLu.south east) edge[dotted] (Lu.south east);
    %% Draw dotted lines connecting Actinide breakout to main table
    \draw (AcLr.north west) edge[dotted] (Ac.north west)
%   (AcLr.north east) edge[dotted] (Lr.north east)
    (AcLr.south west) edge[dotted] (Ac.south west);
%   (AcLr.south east) edge[dotted] (Lr.south east);

    %% Legend
    \draw[black, AlkaliMetalFill] ($(La.north -| Fr.west) + (1em,-0.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Alcalins};
    \draw[black, AlkalineEarthMetalFill] ($(La.north -| Fr.west) + (1em,-1.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Alcalino-terreux};
    \draw[black, MetalFill] ($(La.north -| Fr.west) + (1em,-3.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Metal};
    \draw[black, MetalloidFill] ($(La.north -| Fr.west) + (1em,-4.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Métalloïde};
    \draw[black, NonmetalFill] ($(La.north -| Fr.west) + (1em,-6.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Non-métal};
    \draw[black, HalogenFill] ($(La.north -| Fr.west) + (1em,-7.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Halogène};
    \draw[black, NobleGasFill] ($(La.north -| Fr.west) + (1em,-9.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Gaz noble};
    \draw[black, LanthanideActinideFill] ($(La.north -| Fr.west) + (1em,-10.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Lanthanide/Actinide};

    \node at ($(La.north -| Fr.west) + (5em,-15em)$) [name=elementLegend, Element, fill=white]
    {\NaturalElementTextFormat{Z}{mass}{Symbole}{Name}};
    \node[Element, fill=white, right of=elementLegend, xshift=1em]
    {\SyntheticElementTextFormat{}{}{Artificiel}{}} ;

    %% Diagram Title
    \node at (H.west -| Fe.north) [name=diagramTitle, TitleLabel]
    {Tableau péridique des éléments};

    \end{tikzpicture}
}
\begin{document}
    \TabPeriodique
\end{document}

答案1

由于您只希望能够改变两个选项,即比例和名称,我建议有一个可选参数和一个可选参数,*以便您可以使用语法:

\TabPeriodique       % scale = 0.55 (the default) with    names
\TabPeriodique*      % scale = 0.55 (the default) without names
\TabPeriodique[0.5]  % scale = 0.5                with    names
\TabPeriodique*[0.5] % scale = 0.5                without names

而不是使用来自电子工具箱我发现使用 TeX 原始命令定义新开关更容易:

\newif\ifWithNames

然后你就可以编写相当可读的代码了:

\ifWithNames ...something with names \else something without\fi 

为了定义上述语法,我们\TabPeriodique使用\NewDocumentCommand解析

\NewDocumentCommand\TabPeriodique{ s O{0.55} }{
    \IfBooleanTF{#1}{\WithNamesfalse}{\WithNamestrue}
    ...
}

这里,s指定了,*并且O{0.55}定义了一个可选的第二个参数,该参数的默认值为0.55。在宏定义中,\IfBooleanTF{#1}检查是否为,#1*进行\WithNames相应设置。

完成这些之后,你的输出看起来将会像这样:

在此处输入图片描述

修改后的代码如下:

%%Extract from : http://www.texample.net/tikz/examples/periodic-table-of-chemical-elements/
%% Copyright 2009 Ivan Griffin
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Ivan Griffin
%
% This work consists of the files periodic_table.tex

%Description
%-----------
%periodic_table.tex - an example file illustrating the Periodic
%                     Table of Chemical Elements using TikZ

%Created 2009-12-08 by Ivan Griffin.  Last updated: 2010-01-11
%
%Thanks to Jerome
%-------------------------------------------------------------

\documentclass[landscape]{article}
\usepackage[landscape, margin=5mm]{geometry}
\usepackage{ifpdf}
\usepackage[french]{babel}
\pagestyle{empty}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,calc}



\newcommand{\CommonElementTextFormat}[4]
{
      \begin{minipage}{2.2cm}
          \centering
          {\textbf{#1} \hfill #2}%
          \linebreak \linebreak
          {\textbf{#3}}%
          \linebreak \linebreak
          {\ifWithNames\large {#4}\fi}
      \end{minipage}
}

\newcommand{\NaturalElementTextFormat}[4]
{
    \CommonElementTextFormat{#1}{#2}{\LARGE {#3}}{#4}
}

\newcommand{\OutlineText}[1]
{
    \ifpdf
    % Couldn't find a nicer way of doing an outline font with TikZ
    % other than using pdfliteral 1 Tr
    %
    \pdfliteral direct {0.5 w 1 Tr}{#1}%
    \pdfliteral direct {1 w 0 Tr}%
    \else
    % pstricks can do this with \pscharpath from pstricks
    %
    \pscharpath[shadow=false,
    fillstyle=solid,
    fillcolor=white,
    linestyle=solid,
    linecolor=black,
    linewidth=.2pt]{#1}
    \fi
}

\newcommand{\SyntheticElementTextFormat}[4]
{
    \ifpdf
    \CommonElementTextFormat{#1}{#2}{\OutlineText{\LARGE #3}}{#4}
    \else
    % pstricks approach results in slightly larger box
    % that doesn't break, so fudge here
    \CommonElementTextFormat{#1}{#2}{\OutlineText{\Large #3}}{#4}
    \fi
}

    %% Fill Color Styles
    \tikzstyle{ElementFill} = [fill=yellow!15]
    \tikzstyle{AlkaliMetalFill} = [fill=blue!55]
    \tikzstyle{AlkalineEarthMetalFill} = [fill=blue!40]
    \tikzstyle{MetalFill} = [fill=blue!25]
    \tikzstyle{MetalloidFill} = [fill=orange!25]
    \tikzstyle{NonmetalFill} = [fill=green!25]
    \tikzstyle{HalogenFill} = [fill=green!40]
    \tikzstyle{NobleGasFill} = [fill=green!55]
    \tikzstyle{LanthanideActinideFill} = [fill=purple!25]

    %% Element Styles
    \tikzstyle{Element} = [draw=black, ElementFill,
    minimum width=2.75cm, minimum height=2.75cm, node distance=2.75cm]
    \tikzstyle{AlkaliMetal} = [Element, AlkaliMetalFill]
    \tikzstyle{AlkalineEarthMetal} = [Element, AlkalineEarthMetalFill]
    \tikzstyle{Metal} = [Element, MetalFill]
    \tikzstyle{Metalloid} = [Element, MetalloidFill]
    \tikzstyle{Nonmetal} = [Element, NonmetalFill]
    \tikzstyle{Halogen} = [Element, HalogenFill]
    \tikzstyle{NobleGas} = [Element, NobleGasFill]
    \tikzstyle{LanthanideActinide} = [Element, LanthanideActinideFill]
    \tikzstyle{PeriodLabel} = [font={\sffamily\LARGE}, node distance=2.0cm]
    \tikzstyle{GroupLabel} = [font={\sffamily\LARGE}, minimum width=2.75cm, node distance=2.0cm]
    \tikzstyle{TitleLabel} = [font={\sffamily\Huge\bfseries}]


\usepackage{xparse}
\newif\ifWithNames\WithNamestrue

\NewDocumentCommand\TabPeriodique{ s O{0.55} }{
  \begin{tikzpicture}[font=\sffamily, scale=#2, transform shape]
    \IfBooleanTF{#1}{\WithNamesfalse}{\WithNamestrue}
    %% Group 1 - IA
    \node[name=H, Element] {\NaturalElementTextFormat{1}{1.0079}{H}{Hydrogène}};
    \node[name=Li, below of=H, AlkaliMetal] {\NaturalElementTextFormat{3}{6.941}{Li}{Lithium}};
    \node[name=Na, below of=Li, AlkaliMetal] {\NaturalElementTextFormat{11}{22.990}{Na}{Sodium}};
    \node[name=K, below of=Na, AlkaliMetal] {\NaturalElementTextFormat{19}{39.098}{K}{Potassium}};
    \node[name=Rb, below of=K, AlkaliMetal] {\NaturalElementTextFormat{37}{85.468}{Rb}{Rubidium}};
    \node[name=Cs, below of=Rb, AlkaliMetal] {\NaturalElementTextFormat{55}{132.91}{Cs}{Césium}};
    \node[name=Fr, below of=Cs, AlkaliMetal] {\NaturalElementTextFormat{87}{223}{Fr}{Francium}};

    %% Group 2 - IIA
    \node[name=Be, right of=Li, AlkalineEarthMetal] {\NaturalElementTextFormat{4}{9.0122}{Be}{Beryllium}};
    \node[name=Mg, below of=Be, AlkalineEarthMetal] {\NaturalElementTextFormat{12}{24.305}{Mg}{Magnésium}};
    \node[name=Ca, below of=Mg, AlkalineEarthMetal] {\NaturalElementTextFormat{20}{40.078}{Ca}{Calcium}};
    \node[name=Sr, below of=Ca, AlkalineEarthMetal] {\NaturalElementTextFormat{38}{87.62}{Sr}{Strontium}};
    \node[name=Ba, below of=Sr, AlkalineEarthMetal] {\NaturalElementTextFormat{56}{137.33}{Ba}{Barium}};
    \node[name=Ra, below of=Ba, AlkalineEarthMetal] {\NaturalElementTextFormat{88}{226}{Ra}{Radium}};

    %% Group 3 - IIIB
    \node[name=Sc, right of=Ca, Metal] {\NaturalElementTextFormat{21}{44.956}{Sc}{Scandium}};
    \node[name=Y, below of=Sc, Metal] {\NaturalElementTextFormat{39}{88.906}{Y}{Yttrium}};
    \node[name=LaLu, below of=Y, LanthanideActinide] {\NaturalElementTextFormat{57-71}{}{La-Lu}{Lanthanide}};
    \node[name=AcLr, below of=LaLu, LanthanideActinide] {\NaturalElementTextFormat{89-103}{}{Ac-Lr}{Actinide}};

    %% Group 4 - IVB
    \node[name=Ti, right of=Sc, Metal] {\NaturalElementTextFormat{22}{47.867}{Ti}{Titane}};
    \node[name=Zr, below of=Ti, Metal] {\NaturalElementTextFormat{40}{91.224}{Zr}{Zirconium}};
    \node[name=Hf, below of=Zr, Metal] {\NaturalElementTextFormat{72}{178.49}{Hf}{Halfnium}};
    \node[name=Rf, below of=Hf, Metal] {\SyntheticElementTextFormat{104}{261}{Rf}{Rutherfordium}};

    %% Group 5 - VB
    \node[name=V, right of=Ti, Metal] {\NaturalElementTextFormat{23}{50.942}{V}{Vanadium}};
    \node[name=Nb, below of=V, Metal] {\NaturalElementTextFormat{41}{92.906}{Nb}{Niobium}};
    \node[name=Ta, below of=Nb, Metal] {\NaturalElementTextFormat{73}{180.95}{Ta}{Tantale}};
    \node[name=Db, below of=Ta, Metal] {\SyntheticElementTextFormat{105}{262}{Db}{Dubnium}};

    %% Group 6 - VIB
    \node[name=Cr, right of=V, Metal] {\NaturalElementTextFormat{24}{51.996}{Cr}{Chrome}};
    \node[name=Mo, below of=Cr, Metal] {\NaturalElementTextFormat{42}{95.94}{Mo}{Molybdène}};
    \node[name=W, below of=Mo, Metal] {\NaturalElementTextFormat{74}{183.84}{W}{Tungstène}};
    \node[name=Sg, below of=W, Metal] {\SyntheticElementTextFormat{106}{266}{Sg}{Seaborgium}};

    %% Group 7 - VIIB
    \node[name=Mn, right of=Cr, Metal] {\NaturalElementTextFormat{25}{54.938}{Mn}{Manganèse}};
    \node[name=Tc, below of=Mn, Metal] {\NaturalElementTextFormat{43}{96}{Tc}{Technétium}};
    \node[name=Re, below of=Tc, Metal] {\NaturalElementTextFormat{75}{186.21}{Re}{Rhénium}};
    \node[name=Bh, below of=Re, Metal] {\SyntheticElementTextFormat{107}{264}{Bh}{Bohrium}};

    %% Group 8 - VIIIB
    \node[name=Fe, right of=Mn, Metal] {\NaturalElementTextFormat{26}{55.845}{Fe}{Fer}};
    \node[name=Ru, below of=Fe, Metal] {\NaturalElementTextFormat{44}{101.07}{Ru}{Ruthénium}};
    \node[name=Os, below of=Ru, Metal] {\NaturalElementTextFormat{76}{190.23}{Os}{Osmium}};
    \node[name=Hs, below of=Os, Metal] {\SyntheticElementTextFormat{108}{277}{Hs}{Hassium}};

    %% Group 9 - VIIIB
    \node[name=Co, right of=Fe, Metal] {\NaturalElementTextFormat{27}{58.933}{Co}{Cobalt}};
    \node[name=Rh, below of=Co, Metal] {\NaturalElementTextFormat{45}{102.91}{Rh}{Rhodium}};
    \node[name=Ir, below of=Rh, Metal] {\NaturalElementTextFormat{77}{192.22}{Ir}{Iridium}};
    \node[name=Mt, below of=Ir, Metal] {\SyntheticElementTextFormat{109}{268}{Mt}{Meitnerium}};

    %% Group 10 - VIIIB
    \node[name=Ni, right of=Co, Metal] {\NaturalElementTextFormat{28}{58.693}{Ni}{Nickel}};
    \node[name=Pd, below of=Ni, Metal] {\NaturalElementTextFormat{46}{106.42}{Pd}{Palladium}};
    \node[name=Pt, below of=Pd, Metal] {\NaturalElementTextFormat{78}{195.08}{Pt}{Platine}};
    \node[name=Ds, below of=Pt, Metal] {\SyntheticElementTextFormat{110}{281}{Ds}{Darmstadtium}};

    %% Group 11 - IB
    \node[name=Cu, right of=Ni, Metal] {\NaturalElementTextFormat{29}{63.546}{Cu}{Cuivre}};
    \node[name=Ag, below of=Cu, Metal] {\NaturalElementTextFormat{47}{107.87}{Ag}{Argent}};
    \node[name=Au, below of=Ag, Metal] {\NaturalElementTextFormat{79}{196.97}{Au}{Or}};
    \node[name=Rg, below of=Au, Metal] {\SyntheticElementTextFormat{111}{280}{Rg}{Roentgenium}};

    %% Group 12 - IIB
    \node[name=Zn, right of=Cu, Metal] {\NaturalElementTextFormat{30}{65.39}{Zn}{Zinc}};
    \node[name=Cd, below of=Zn, Metal] {\NaturalElementTextFormat{48}{112.41}{Cd}{Cadmium}};
    \node[name=Hg, below of=Cd, Metal] {\NaturalElementTextFormat{80}{200.59}{Hg}{Mercure}};
    \node[name=Uub, below of=Hg, Metal] {\SyntheticElementTextFormat{112}{285}{Uub}{Ununbium}};

    %% Group 13 - IIIA
    \node[name=Ga, right of=Zn, Metal] {\NaturalElementTextFormat{31}{69.723}{Ga}{Gallium}};
    \node[name=Al, above of=Ga, Metal] {\NaturalElementTextFormat{13}{26.982}{Al}{Aluminium}};
    \node[name=B, above of=Al, Metalloid] {\NaturalElementTextFormat{5}{10.811}{B}{Bore}};
    \node[name=In, below of=Ga, Metal] {\NaturalElementTextFormat{49}{114.82}{In}{Indium}};
    \node[name=Tl, below of=In, Metal] {\NaturalElementTextFormat{81}{204.38}{Tl}{Thallium}};
    \node[name=Uut, below of=Tl, Metal] {\SyntheticElementTextFormat{113}{284}{Uut}{Ununtrium}};

    %% Group 14 - IVA
    \node[name=C, right of=B, Nonmetal] {\NaturalElementTextFormat{6}{12.011}{C}{Carbone}};
    \node[name=Si, below of=C, Metalloid] {\NaturalElementTextFormat{14}{28.086}{Si}{Silicium}};
    \node[name=Ge, below of=Si, Metalloid] {\NaturalElementTextFormat{32}{72.64}{Ge}{Germanium}};
    \node[name=Sn, below of=Ge, Metal] {\NaturalElementTextFormat{50}{118.71}{Sn}{Etain}};
    \node[name=Pb, below of=Sn, Metal] {\NaturalElementTextFormat{82}{207.2}{Pb}{Plomb}};
    \node[name=Uuq, below of=Pb, Metal] {\SyntheticElementTextFormat{114}{289}{Uuq}{Ununquadium}};

    %% Group 15 - VA
    \node[name=N, right of=C, Nonmetal] {\NaturalElementTextFormat{7}{14.007}{N}{Azote}};
    \node[name=P, below of=N, Nonmetal] {\NaturalElementTextFormat{15}{30.974}{P}{Phosphore}};
    \node[name=As, below of=P, Metalloid] {\NaturalElementTextFormat{33}{74.922}{As}{Arsenic}};
    \node[name=Sb, below of=As, Metalloid] {\NaturalElementTextFormat{51}{121.76}{Sb}{Antimoine}};
    \node[name=Bi, below of=Sb, Metal] {\NaturalElementTextFormat{83}{208.98}{Bi}{Bismuth}};
    \node[name=Uup, below of=Bi, Metal] {\SyntheticElementTextFormat{115}{288}{Uup}{Ununpentium}};

    %% Group 16 - VIA
    \node[name=O, right of=N, Nonmetal] {\NaturalElementTextFormat{8}{15.999}{O}{Oxygène}};
    \node[name=S, below of=O, Nonmetal] {\NaturalElementTextFormat{16}{32.065}{S}{Soufre}};
    \node[name=Se, below of=S, Nonmetal] {\NaturalElementTextFormat{34}{78.96}{Se}{Sélenium}};
    \node[name=Te, below of=Se, Metalloid] {\NaturalElementTextFormat{52}{127.6}{Te}{Tellure}};
    \node[name=Po, below of=Te, Metalloid] {\NaturalElementTextFormat{84}{209}{Po}{Polonium}};
    \node[name=Uuh, below of=Po, Metal] {\SyntheticElementTextFormat{116}{293}{Uuh}{Ununhexium}};

    %% Group 17 - VIIA
    \node[name=F, right of=O, Halogen] {\NaturalElementTextFormat{9}{18.998}{F}{Fluor}};
    \node[name=Cl, below of=F, Halogen] {\NaturalElementTextFormat{17}{35.453}{Cl}{Chlore}};
    \node[name=Br, below of=Cl, Halogen] {\NaturalElementTextFormat{35}{79.904}{Br}{Brome}};
    \node[name=I, below of=Br, Halogen] {\NaturalElementTextFormat{53}{126.9}{I}{Iode}};
    \node[name=At, below of=I, Halogen] {\NaturalElementTextFormat{85}{210}{At}{Astatine}};
    \node[name=Uus, below of=At, Element] {\SyntheticElementTextFormat{117}{292}{Uus}{Ununseptium}};

    %% Group 18 - VIIIA
    \node[name=Ne, right of=F, NobleGas] {\NaturalElementTextFormat{10}{20.180}{Ne}{Néon}};
    \node[name=He, above of=Ne, NobleGas] {\NaturalElementTextFormat{2}{4.0025}{He}{Hélium}};
    \node[name=Ar, below of=Ne, NobleGas] {\NaturalElementTextFormat{18}{39.948}{Ar}{Argon}};
    \node[name=Kr, below of=Ar, NobleGas] {\NaturalElementTextFormat{36}{83.8}{Kr}{Krypton}};
    \node[name=Xe, below of=Kr, NobleGas] {\NaturalElementTextFormat{54}{131.29}{Xe}{Xénon}};
    \node[name=Rn, below of=Xe, NobleGas] {\NaturalElementTextFormat{86}{222}{Rn}{Radon}};
    \node[name=Uuo, below of=Rn, Nonmetal] {\SyntheticElementTextFormat{118}{294}{Uuo}{Ununoctium}};

    %% Period
    \node[name=Period1, left of=H, PeriodLabel] {1};
    \node[name=Period2, left of=Li, PeriodLabel] {2};
    \node[name=Period3, left of=Na, PeriodLabel] {3};
    \node[name=Period4, left of=K, PeriodLabel] {4};
    \node[name=Period5, left of=Rb, PeriodLabel] {5};
    \node[name=Period6, left of=Cs, PeriodLabel] {6};
    \node[name=Period7, left of=Fr, PeriodLabel] {7};

    %% Group
    \node[name=Group1, above of=H, GroupLabel] {1 \hfill IA};
    \node[name=Group2, above of=Be, GroupLabel] {2 \hfill IIA};
    \node[name=Group3, above of=Sc, GroupLabel] {3 \hfill IIIA};
    \node[name=Group4, above of=Ti, GroupLabel] {4 \hfill IVB};
    \node[name=Group5, above of=V, GroupLabel] {5 \hfill VB};
    \node[name=Group6, above of=Cr, GroupLabel] {6 \hfill VIB};
    \node[name=Group7, above of=Mn, GroupLabel] {7 \hfill VIIB};
    \node[name=Group8, above of=Fe, GroupLabel] {8 \hfill VIIIB};
    \node[name=Group9, above of=Co, GroupLabel] {9 \hfill VIIIB};
    \node[name=Group10, above of=Ni, GroupLabel] {10 \hfill VIIIB};
    \node[name=Group11, above of=Cu, GroupLabel] {11 \hfill IB};
    \node[name=Group12, above of=Zn, GroupLabel] {12 \hfill IIB};
    \node[name=Group13, above of=B, GroupLabel] {13 \hfill IIIA};
    \node[name=Group14, above of=C, GroupLabel] {14 \hfill IVA};
    \node[name=Group15, above of=N, GroupLabel] {15 \hfill VA};
    \node[name=Group16, above of=O, GroupLabel] {16 \hfill VIA};
    \node[name=Group17, above of=F, GroupLabel] {17 \hfill VIIA};
    \node[name=Group18, above of=He, GroupLabel] {18 \hfill VIIIA};

    %% Lanthanide
    \node[name=La, below of=Rf, LanthanideActinide, yshift=-1cm] {\NaturalElementTextFormat{57}{138.91}{La}{Lanthanum}};
    \node[name=Ce, right of=La, LanthanideActinide] {\NaturalElementTextFormat{58}{140.12}{Ce}{Cerium}};
    \node[name=Pr, right of=Ce, LanthanideActinide] {\NaturalElementTextFormat{59}{140.91}{Pr}{Praseodymium}};
    \node[name=Nd, right of=Pr, LanthanideActinide] {\NaturalElementTextFormat{60}{144.24}{Nd}{Neodymium}};
    \node[name=Pm, right of=Nd, LanthanideActinide] {\NaturalElementTextFormat{61}{145}{Pm}{Promethium}};
    \node[name=Sm, right of=Pm, LanthanideActinide] {\NaturalElementTextFormat{62}{150.36}{Sm}{Samarium}};
    \node[name=Eu, right of=Sm, LanthanideActinide] {\NaturalElementTextFormat{63}{151.96}{Eu}{Europium}};
    \node[name=Gd, right of=Eu, LanthanideActinide] {\NaturalElementTextFormat{64}{157.25}{Gd}{Gadolinium}};
    \node[name=Tb, right of=Gd, LanthanideActinide] {\NaturalElementTextFormat{65}{158.93}{Tb}{Terbium}};
    \node[name=Dy, right of=Tb, LanthanideActinide] {\NaturalElementTextFormat{66}{162.50}{Dy}{Dysprosium}};
    \node[name=Ho, right of=Dy, LanthanideActinide] {\NaturalElementTextFormat{67}{164.93}{Ho}{Holmium}};
    \node[name=Er, right of=Ho, LanthanideActinide] {\NaturalElementTextFormat{68}{167.26}{Er}{Erbium}};
    \node[name=Tm, right of=Er, LanthanideActinide] {\NaturalElementTextFormat{69}{168.93}{Tm}{Thulium}};
    \node[name=Yb, right of=Tm, LanthanideActinide] {\NaturalElementTextFormat{70}{173.04}{Yb}{Ytterbium}};
    \node[name=Lu, right of=Yb, LanthanideActinide] {\NaturalElementTextFormat{71}{174.97}{Lu}{Lutetium}};

    %% Actinide
    \node[name=Ac, below of=La, LanthanideActinide, yshift=-1cm] {\NaturalElementTextFormat{89}{227}{Ac}{Actinium}};
    \node[name=Th, right of=Ac, LanthanideActinide] {\NaturalElementTextFormat{90}{232.04}{Th}{Thorium}};
    \node[name=Pa, right of=Th, LanthanideActinide] {\NaturalElementTextFormat{91}{231.04}{Pa}{Protactinium}};
    \node[name=U, right of=Pa, LanthanideActinide] {\NaturalElementTextFormat{92}{238.03}{U}{Uranium}};
    \node[name=Np, right of=U, LanthanideActinide] {\SyntheticElementTextFormat{93}{237}{Np}{Neptunium}};
    \node[name=Pu, right of=Np, LanthanideActinide] {\SyntheticElementTextFormat{94}{244}{Pu}{Plutonium}};
    \node[name=Am, right of=Pu, LanthanideActinide] {\SyntheticElementTextFormat{95}{243}{Am}{Americium}};
    \node[name=Cm, right of=Am, LanthanideActinide] {\SyntheticElementTextFormat{96}{247}{Cm}{Curium}};
    \node[name=Bk, right of=Cm, LanthanideActinide] {\SyntheticElementTextFormat{97}{247}{Bk}{Berkelium}};
    \node[name=Cf, right of=Bk, LanthanideActinide] {\SyntheticElementTextFormat{98}{251}{Cf}{Californium}};
    \node[name=Es, right of=Cf, LanthanideActinide] {\SyntheticElementTextFormat{99}{252}{Es}{Einsteinium}};
    \node[name=Fm, right of=Es, LanthanideActinide] {\SyntheticElementTextFormat{100}{257}{Fm}{Fermium}};
    \node[name=Md, right of=Fm, LanthanideActinide] {\SyntheticElementTextFormat{101}{258}{Md}{Mendelevium}};
    \node[name=No, right of=Md, LanthanideActinide] {\SyntheticElementTextFormat{102}{259}{No}{Nobelium}};
    \node[name=Lr, right of=No, LanthanideActinide] {\SyntheticElementTextFormat{103}{262}{Lr}{Lawrencium}};

    %% Draw dotted lines connecting Lanthanide breakout to main table
    \draw (LaLu.north west) edge[dotted] (La.north west)
%   (LaLu.north east) edge[dotted] (Lu.north east)
    (LaLu.south west) edge[dotted] (La.south west);
%   (LaLu.south east) edge[dotted] (Lu.south east);
    %% Draw dotted lines connecting Actinide breakout to main table
    \draw (AcLr.north west) edge[dotted] (Ac.north west)
%   (AcLr.north east) edge[dotted] (Lr.north east)
    (AcLr.south west) edge[dotted] (Ac.south west);
%   (AcLr.south east) edge[dotted] (Lr.south east);

    %% Legend
    \draw[black, AlkaliMetalFill] ($(La.north -| Fr.west) + (1em,-0.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Alcalins};
    \draw[black, AlkalineEarthMetalFill] ($(La.north -| Fr.west) + (1em,-1.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Alcalino-terreux};
    \draw[black, MetalFill] ($(La.north -| Fr.west) + (1em,-3.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Metal};
    \draw[black, MetalloidFill] ($(La.north -| Fr.west) + (1em,-4.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Métalloïde};
    \draw[black, NonmetalFill] ($(La.north -| Fr.west) + (1em,-6.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Non-métal};
    \draw[black, HalogenFill] ($(La.north -| Fr.west) + (1em,-7.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Halogène};
    \draw[black, NobleGasFill] ($(La.north -| Fr.west) + (1em,-9.0em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Gaz noble};
    \draw[black, LanthanideActinideFill] ($(La.north -| Fr.west) + (1em,-10.5em)$)
    rectangle +(1em, 1em) node[right, yshift=-1ex]{Lanthanide/Actinide};

    \node at ($(La.north -| Fr.west) + (5em,-15em)$) [name=elementLegend, Element, fill=white]
    {\NaturalElementTextFormat{Z}{mass}{Symbole}{Name}};
    \node[Element, fill=white, right of=elementLegend, xshift=1em]
    {\SyntheticElementTextFormat{}{}{Artificiel}{}} ;

    %% Diagram Title
    \node at (H.west -| Fe.north) [name=diagramTitle, TitleLabel]
    {Tableau péridique des éléments};

    \end{tikzpicture}
}
\begin{document}
    \TabPeriodique[0.5]

    \TabPeriodique*[0.5]

\end{document}

除了上面描述的更改外,这与原始帖子基本相同。我还简化了 的定义。我删除了和\CommonElementTextFormat的特殊处理,因为这破坏了对齐,因此对我来说似乎是不必要的和不想要的(并且我更改了文档类,以便我可以为上面的图像制作动画。)La-LuAc-Lr

最后,该\tikzstyle命令已被弃用,但代码仍然有效,所以我没有更新它来使用\tikzset

相关内容