3

Are there any latex packages that allow for drawing the ball and stick models of different molecules (or packages that are meant for a different purpose but can be used to draw ball and stick models). Ball and stick models such as this ones: enter image description here

I'm currently using avogadro -> exporting as svg -> inkscape svg -> pdf+latex -> insert into document. I would preferably like a tikz package.

New Question

I have found that Avogadro can export the coordinates of the atoms. I would like to know how to make the joins cylinders and add shading on the cylinders. I would also like to change the view angle and is there a more natural 3d rather than a tikz 3d view? Here is the TiKz code for the molecule I am trying to draw (not the one above)

\begin{tikzpicture}[scale=1]
\node (C1)  at         (-3.19898,        0.68575,       -0.09137) {};
\node (N1)  at         (-2.00788,       -0.15303,       -0.05472) {};
\node (H1)  at         (-3.17155,        1.39571,       -0.92422) {};
\node (H2)  at         (-3.31563,        1.23754,        0.84706) {};
\node (H3)  at         (-4.08519,        0.05549,       -0.21396) {};
\node (C2)  at         (-0.78815,        0.67831,        0.01256) {};
\node (H4)  at         (-1.95362,       -0.69266,       -0.92177) {};
\node (C3)  at         ( 0.47237,       -0.18670,        0.21998) {};
\node (H5)  at         (-0.86520,        1.39211,        0.84227) {};
\node (H6)  at         (-0.69535,        1.26040,       -0.91400) {};
\node (C4)  at         ( 1.73163,        0.67172,        0.09304) {};
\node (N2)  at         ( 0.51467,       -1.32801,       -0.73516) {};
\node (H7)  at         ( 0.46502,       -0.59296,        1.23918) {};
\node (H8)  at         ( 1.39360,       -1.82407,       -0.57104) {};
\node (H9)  at         (-0.23067,       -1.96899,       -0.46111) {};
\node (O1)  at         ( 1.80456,        1.88884,        0.13111) {};
\node (O2)  at         ( 2.86188,       -0.07112,        0.00360) {};
\node (H10) at         ( 3.57354,        0.59879,       -0.06651) {};
\shade [ball color=white] (H1) circle (0.15);
\shade [ball color=white] (H2) circle (0.15);
\shade [ball color=white] (H3) circle (0.15);
\shade [ball color=white] (H4) circle (0.15);
\shade [ball color=white] (H5) circle (0.15);
\shade [ball color=white] (H6) circle (0.15);
\shade [ball color=white] (H7) circle (0.15);
\shade [ball color=white] (H8) circle (0.15);
\shade [ball color=white] (H9) circle (0.15);
\shade [ball color=white] (H10) circle (0.15);
\shade [ball color=black!75] (C1) circle (0.25);
\shade [ball color=black!75] (C2) circle (0.25);
\shade [ball color=black!75] (C3) circle (0.25);
\shade [ball color=black!75] (C4) circle (0.25);
\shade [ball color=blue!75] (N1) circle (0.25);
\shade [ball color=blue!75] (N2) circle (0.25);
\shade [ball color=red!75] (O1) circle (0.25);
\shade [ball color=red!75] (O2) circle (0.25);
\draw (H1) -- (C1) -- (N1) -- (C2) -- (C3) -- (C4) -- (O1);
\draw (H2) -- (C1);
\draw (H3) -- (C1);
\draw (N1) -- (H4);
\draw (C2) -- (H5);
\draw (C2) -- (H6);
\draw (C3) -- (H7);
\draw (C3) -- (N2) -- (H8);
\draw (N2) -- (H9);
\draw (C4) -- (O2) -- (H10);
\end{tikzpicture}

The code above does not do cylinders as bonds but rather just lines by the \draw function. How do I make cylinders shading and change the 3d view angles?

sab hoque
  • 2,627
  • 2
    Yes, this can be done with asymptote. See e.g. this answer. There are a few others. –  Oct 04 '18 at 05:17
  • Hi @marmot would you know of any method to figure out the location of each atom (sphere) – sab hoque Oct 04 '18 at 13:00
  • I am sorry, I do not understand the question. You need a model/theory to tell where the atoms sit, I think. I guess that these things should be described in a chemistry or molecular physics book. Naively I'd say in your example the atoms sit on nodes of the root lattice of A_3\simeq SU(4), but that's just guesswork. –  Oct 04 '18 at 15:27
  • Thanks anyways, in the end I just decided to go with tikz and use the \shade with balls. As it is a margin figure I did not bother with making the bonds cylinders with shading. – sab hoque Oct 04 '18 at 16:13
  • You can do that with TikZ (and even shade the cylinders) but you have to be very careful with order in which you draw things and also compute the intersection of the cylinders with the spheres (which is, however, straightforward in this case). However, this does not spare you from determining the coordinates of the atoms. If they are indeed, on the root lattice of A_3, maybe this may help. (Of course, you are not going to pack these things.) –  Oct 04 '18 at 16:22
  • @marmot please see my new question above, I prefer not to use asymptote but if that is the only option, I can follow the steps in a similar question that was asked before and answered using asymptote. – sab hoque Oct 16 '18 at 15:10
  • I guess that the effort that would have to be made to draw this correctly for arbitrary view angles will be substantial. Not sure if anyone will do that very soon. Some of the problems are in principle solved by pgfplots, but I don't think all of them are. –  Oct 16 '18 at 16:17
  • How would I make the cylinders? I did a google search for 3d cylinders in TiKz but I am unsure as to how I would do them as connections between the centres of the balls? Are there any answers out there which answer my question regarding the cylinders. – sab hoque Oct 17 '18 at 09:42
  • See e.g. here, all you need is to do is to add sth like left color=blue!30, right color=blue!60, middle color=blue!20, and add an appropriate shading angle. The problem is more the rotation of the thing, and what is more, the ordering in which you draw things. I really think you'll be much better off with asymptote, which does all these things for you. –  Oct 17 '18 at 12:35
  • Yes, in fact I decided to make some code for the drawing in asymptote based off that crystal structure in this link https://tex.stackexchange.com/questions/114815/help-creating-solid-cylinders-along-a-path-in-tikz-for-crystal-lattice-diagram/114876#114876 but I am having difficulty getting an image to render, I will by trying again but if I can't I may make a new question – sab hoque Oct 17 '18 at 12:36
  • I am having a strange error come up https://tex.stackexchange.com/q/455544/166730 – sab hoque Oct 17 '18 at 13:36

0 Answers0