2

Anybody knows how to reproduce this table in latex?

enter image description here

Thanks in advance for your time and advice.

  • 3
    See here, for example: texample.net/tikz/examples/periodic-table-of-chemical-elements – CarLaTeX Nov 6 '16 at 19:50
  • 6
    On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – samcarter_is_at_topanswers.xyz Nov 6 '16 at 20:09
9

Note that in my view I ought not answer do-it-for-mes. Even if somebody else already has.

This turns Enrico Maria De Angelis's code into a pic, element and then uses a couple of loops to mis-construct the first three-and-a-bit rows of the periodic table.

A less chemically blasphemous version was provided in a link in the comments. However, that version uses deprecated code.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\newcounter{atomicnumber}
\setcounter{atomicnumber}{0}
\tikzset{%
  element/.pic={%
    \tikzset{%
      elements/.cd,
      #1,
      /tikz/.cd,
    }%
    \stepcounter{atomicnumber}%
    % addaswyd o gôd Enrico Maria De Angelis:
    % https://tex.stackexchange.com/a/339005/
    \node (\elementsymbol) [font=\huge\elementfont, text=\elementtext, inner sep=.5*\elementsep, anchor=mid, fill=\elementfill, rounded corners=2pt, minimum size=\elementsize] {\strut\elementsymbol};
    \node [font=\tiny\elementfont, text=\elementtext, inner sep=2pt, anchor=north west] at (\elementsymbol.north west) {\theatomicnumber};
    \node [font=\tiny\elementfont, text=\elementtext, inner sep=2pt, anchor=south] at (\elementsymbol.south) {\elementname};
  },
  elements/.search also={/tikz},
  elements/.cd,
  name/.store in=\elementname,
  font/.store in=\elementfont,
  text/.store in=\elementtext,
  fill/.store in=\elementfill,
  symbol/.store in=\elementsymbol,
  size/.store in=\elementsize,
  sep/.store in=\elementsep,
  name=Full Name,
  font=\sffamily,
  text=white,
  fill=black,
  symbol=Sy,
  size=35pt,
  sep=2.5pt,
}
\begin{document}
\begin{tikzpicture}[node distance=\elementsize]
  \coordinate (o);
  \foreach \k/\m [count=\elementrow, evaluate=\elementrow as \elementshift using {-\elementrow*(\elementsize+\elementsep)}] in {%
    magenta/{H/Hydrogen,He/Helium},
    cyan/{%
      Li/Lithium,Be/Beryllium,B/Boron,C/Carbon,Ny/Nitrogen,
      O/Oxygen,F/Fluorine,Ne/Neon%
    },
    blue!50!cyan/{%
      Na/Sodium,Mg/Magnesium,Al/Aluminium,Si/Silicon,P/Phosphorous,
      S/Sulphur,Cl/Chlorine,Ar/Argon%
    },
    blue/{K/Potassium,Ca/Calcium}%
  }{%
    \coordinate (o\elementrow) at (0,\elementshift pt);
    \begin{scope}
      \foreach \i/\j [remember=\i as \ilast (initially o\elementrow)] in \m
      \pic [right=\elementsize+\elementsep of \ilast.mid] {element={name=\j, symbol=\i, fill=\k}};
    \end{scope}
  }
\end{tikzpicture}
\end{document}

chemical blasphemy

|improve this answer|||||
  • +1 looks great. But could you edit your code so that the elements of \foreach are better grouped by adding some linebreaks? If you don't want to do it, I'll be happy to do it myself, if you are ok with this. – Stefan Pinnow Nov 14 '16 at 17:29
  • @StefanPinnow They are grouped according to their rows in the periodic table. If you have different content, you just create the groups differently when setting up the loop, but I'm not going to do that with this content - it is already chemical blasphemy. I'm not going to make it into chemical heresy as well! – cfr Nov 14 '16 at 17:34
  • @StefanPinnow The real issue is the horizontal spacing i.e. the lack of gaps between elements which should be separated by space. However, since that is not required by the OP's image, I decided it was not worth figuring out a neat way of doing it here. (But I would quite like to do this when I get time or steal time.) – cfr Nov 14 '16 at 17:37
  • What I mean is, that code line starting with \foreach is veeeeeeery long and so -- at least for me -- hard to read. I just wanted to insert some linebreaks to the code and not change the content ... – Stefan Pinnow Nov 14 '16 at 17:47
  • @StefanPinnow Oh, sorry. I completely misunderstood. I've added some - is that enough? Please add some more if not. I've broken the lines by groups to keep the code for each row together as that seemed logical to me. – cfr Nov 14 '16 at 18:05
7

This is just one tile.

enter image description here

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

    % Dv
    \coordinate (dv) at (0,0);
    \coordinate (base) at (35pt,0pt);
    \coordinate (height) at (0pt,35pt);
    \coordinate (diag) at ($(base)+(height)$);
    \fill[rounded corners=2pt, magenta] ($(dv)-.5*(diag)$) rectangle +(diag); 
    \node[white] at (dv) {\sffamily\huge Dv};
    \node[white, inner sep=2pt] (dvtext) at ($(dv)-.5*(height)$) [anchor=south] {\sffamily\tiny Diversification};
    \node[white, inner sep=2pt] (dvnum) at ($(dv)+.5*(height)-.5*(base)$) [anchor=north west] {\sffamily\tiny 01};
\end{tikzpicture}

\end{document}

It should be easy to copy, paste and modify a lot of times. To put them together the commands \pgftransformshift{\pgfpoint{1cm}{1cm}} should be enough.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.