Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw histidine with chemfig and I'm stuck. I drew most parts correctly but I'm having trouble attaching the imidazole ring properly. Here's what I have so far:

\documentclass{article}
\usepackage{chemfig}
\definesubmol{ring}{N*5(=-{NH}-(-)=-)} % imidazole ring

\begin{document}
\chemfig{!{ring}-[:30]-[:-30](-[:-90]NH_2)-[:30](=[:90]O)(-[:-30]OH)} % histidine
\end{document}

Is there an easy way to use my sub-molecule and attach it to the main part at the correct atom and angle?

Cheers :)

share|improve this question

2 Answers 2

chemfig's molecules can get a default rotation by specifying an angle as option first in the molecule:

\chemfig{[:<angle>]...}

Choosing the right angle will do the trick here:

\documentclass{article}
\usepackage{chemfig}
\definesubmol{imidazole}{N*5(=-{NH}-(-)=-)} % imidazole ring

\begin{document}
\chemfig{[:168]!{imidazole}-[:30]-[:-30](-[:-90]NH_2)-[:30](=[:90]O)(-[:-30]OH)} % histidine
\end{document}

Before:

enter image description here

After:

enter image description here

The necessary further corrections should be simple (NH must be switched...)

Actually, to have some automatism you could exploit the optional argument to \definesubmol:

`\definesubmol{<name>}[<molecule to the left>]{<molecule to the right>}

In this case:

\documentclass{article}
\usepackage{chemfig}
\definesubmol{imidazole}[N*5(=-{HN}-(-)=-)]{N*5(=-{NH}-(-)=-)} % imidazole ring

\begin{document}
\chemfig{!{imidazole}}

\chemfig{[:168]!{imidazole}}
\end{document}

enter image description here

\documentclass{article}
\usepackage{chemfig}
\definesubmol{imidazole}[N*5(=-{HN}-(-)=-)]{N*5(=-{NH}-(-)=-)} % imidazole ring

\begin{document}
\chemfig{[:168]!{imidazole}-[:30]-[:-30](-[:-90]NH_2)-[:30](=[:90]O)(-[:-30]OH)} % histidine
\end{document}

enter image description here

share|improve this answer
    
That worked like a charm, thank you! How did you determine the rotation angle though? –  dreddy Jul 12 at 23:10
    
Also, I'm drawing all amino acids and struggling with tryptophan's double ring right now. Would you mind if I shoot you a message if I can't figure it out? –  dreddy Jul 12 at 23:10
    
I just played a bit... 168=150+18 and 18° are all over the place in a pentagon... :) –  cgnieder Jul 12 at 23:14
    
Makes sense. Also, the angles aren't perfect but I figured out tryptophan: \chemfig{*6(-*5(-{NH}-=(-[:30]-[:-30](-[:-90]NH_2)-[:30](=[:90]O)(-[:-30]OH))-)=‌​-=-=)}. –  dreddy Jul 12 at 23:25

If it should like (near) exactly as in the picture, the following modification may be useful. The angles are assummed to be 30 and 120 degrees; hence the correction: 120+72=192.

Your original definition is left in the preamble for comparision.

\documentclass{article}
\usepackage{chemfig}
\definesubmol{ring}{N*5(=-{NH}-(-)=-)} % imidazole ring

\begin{document}

\definesubmol{ring}{*5(-{N}=-{HN}-=)} % imidazole ring


\chemfig{[:-192]!{ring}-[:30]-[:-30](-[:-90]NH_2)-[:30](=[:90]O)(-[:-30]OH)} % histidine
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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