4

To better understand the axis of vision in the Newman projection, I would like to add a symbolic eye (while searching, I found this code: Symbol for eye (looking for a library) ) in the middle of my figure as in the image below enter image description here

After drawing my molecule with \chemfig, the addition of the eye is done at the bottom right and not in the axis as desired:

    \documentclass[border=3mm]{standalone}
\usepackage{chemmacros}
\usepackage{chemfig}

\newcommand*\lateraleye{% \scalebox{0.15}{ \tikzset{every picture/.style={line width=0.75pt}} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [line width=1.5] (300,100.33) .. controls (326,122) and (352,135) .. (378,139.33) .. controls (352,143.67) and (326,156.67) .. (300,178.33) ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (308.94,116.33) .. controls (313.87,116.33) and (317.86,125.51) .. (317.85,136.83) .. controls (317.84,148.15) and (313.84,157.33) .. (308.91,157.33) .. controls (303.99,157.32) and (300,148.14) .. (300.01,136.82) .. controls (300.02,125.5) and (304.02,116.32) .. (308.94,116.33) -- cycle ; \draw [draw opacity=0][line width=1.5] (314.84,166.6) .. controls (311.87,164.64) and (309.14,162.18) .. (306.76,159.24) .. controls (295.12,144.82) and (296.6,124.33) .. (310.07,113.45) .. controls (311.48,112.32) and (312.96,111.33) .. (314.5,110.49) -- (331.14,139.55) -- cycle ; \draw [line width=1.5] (314.84,166.6) .. controls (311.87,164.64) and (309.14,162.18) .. (306.76,159.24) .. controls (295.12,144.82) and (296.6,124.33) .. (310.07,113.45) .. controls (311.48,112.32) and (312.96,111.33) .. (314.5,110.49) ; \draw [fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (304.43,124.2) .. controls (306.09,124.25) and (307.32,128.01) .. (307.18,132.6) .. controls (307.05,137.19) and (305.59,140.88) .. (303.93,140.83) .. controls (302.27,140.78) and (301.03,137.02) .. (301.17,132.43) .. controls (301.31,127.83) and (302.76,124.15) .. (304.43,124.2) -- cycle ; \end{tikzpicture} },} \begin{document}

\chemfig{H-[:60]{\color{purple}C}(<[:140,,,,green]{\color{green}H})(<:[:115,,,,magenta]{\color{magenta}H})-{\color{cyan}C}(<[:-75,,,,blue]{\color{blue}OH})(<:[:-45,,,,brown]{\color{brown}H})-[:60,,,,red]{\color{red}H}}
\lateraleye{}
\end{document}

enter image description here

how can i move the eye in my \chemfig figure?

Nicolas
  • 1,023

2 Answers2

5

The trick is to re-write the code for the molecule, such that the first atom is the left C. The first atom in the code of a molecule always sits on the baseline:

\documentclass[border=3mm]{standalone}
\usepackage{chemfig}

\newcommand*\lateraleye{% \begin{tikzpicture}[x=0.75pt, y=0.75pt, yscale=-0.15, xscale=0.15] \draw[very thin] (300,100.33) .. controls (326,122) and (352,135) .. (378,139.33) .. controls (352,143.67) and (326,156.67) .. (300,178.33) ; \fill (308.94,116.33) .. controls (313.87,116.33) and (317.86,125.51) .. (317.85,136.83) .. controls (317.84,148.15) and (313.84,157.33) .. (308.91,157.33) .. controls (303.99,157.32) and (300,148.14) .. (300.01,136.82) .. controls (300.02,125.5) and (304.02,116.32) .. (308.94,116.33) -- cycle ; \draw[very thin] (314.84,166.6) .. controls (311.87,164.64) and (309.14,162.18) .. (306.76,159.24) .. controls (295.12,144.82) and (296.6,124.33) .. (310.07,113.45) .. controls (311.48,112.32) and (312.96,111.33) .. (314.5,110.49) ; \fill[white] (304.43,124.2) .. controls (306.09,124.25) and (307.32,128.01) .. (307.18,132.6) .. controls (307.05,137.19) and (305.59,140.88) .. (303.93,140.83) .. controls (302.27,140.78) and (301.03,137.02) .. (301.17,132.43) .. controls (301.31,127.83) and (302.76,124.15) .. (304.43,124.2) -- cycle ; \end{tikzpicture}% }

\begin{document}

\chemfig{{\color{purple}C}(-[:240]H)(<[:140,,,,green]{\color{green}H})(<:[:115,,,,magenta]{\color{magenta}H})-{\color{cyan}C}(<[:-75,,,,blue]{\color{blue}OH})(<:[:-45,,,,brown]{\color{brown}H})-[:60,,,,red]{\color{red}H}}
\lateraleye

\end{document}

(I also simplified the code for the eye icon a bit.)

enter image description here

4

You can enclose the chemfig in a \vcentered \hbox:

enter image description here

\[\vcenter{\hbox{\chemfig{H-[:60]{\color{purple}C}(<[:140,,,,green]{\color{green}H})(<:[:115,,,,magenta]{\color{magenta}H})-{\color{cyan}C}(<[:-75,,,,blue]{\color{blue}OH})(<:[:-45,,,,brown]{\color{brown}H})-[:60,,,,red]{\color{red}H}}}}
\lateraleye{}\]

Unrelated, but the code for the eye is overly complicated. Here is a simpler version:

enter image description here

\documentclass{article}
\usepackage{chemfig}

\newcommand{\eyel}{40} % increase (up to 45) for shorter eyelashes \colorlet{eyecolor}{green!60!black}

\newcommand\lateraleye{% \scalebox{0.4}[.5]{\tikz[line cap=round, line join=round]{ \draw(225:1) arc (225:270:1) arc (90:135:1) (270-\eyel:1) arc (180-\eyel/2:180+\eyel/2:{sqrt(2-2cos(\eyel))}); % outline \draw[eyecolor, fill=eyecolor]({-sqrt(2-2cos(\eyel))},-1) arc(-180:180:.07 and .15); % iris \fill[white, shift={(.03,.03)}] ({-sqrt(2-2cos(\eyel))},-1)circle[x radius=.02, y radius=.05]; % accent }} } \begin{document}

[ \vcenter{\hbox{\chemfig{H-[:60]{\color{purple}C}(<[:140,,,,green]{\color{green}H})(<:[:115,,,,magenta]{\color{magenta}H})-{\color{cyan}C}(<[:-75,,,,blue]{\color{blue}OH})(<:[:-45,,,,brown]{\color{brown}H})-[:60,,,,red]{\color{red}H}}}} \hspace{.5cm}\lateraleye ]

\end{document}

Sandy G
  • 42,558