# Connect a 5-Ring to two 6-Rings in chemfig

\chemfig{*6(-(*5(---))-(*6(------))----)}


gives me that:

How do I connect it like this?

EDIT: Thanks to all suggestions I came up with this:

\documentclass{article}
usepackage{chemfig}
\begin{document}
\chemfig{[:30]*6(-([:6,1.0705]*5(-=-))-(*6(------))----)}
\end{document}


Which produces this:

Explanation:
The structure is made up from two regular hexagons and three sides of a regular pentagon, with the sides of the pentagon enlarged by a factor 1.0705 to make the two ends correspond to the vertices of the hexagons. This approach has an advantage in that the double bond is considered as part of a ring and drawn properly as such.
The enlargement factor comes from solving the equation that sets the width between the two ends of the "half pentagon" equal to the width between the vertices of the hexagons:

2 cos(30 deg) l = l' + 2 sin(18 deg) l'

where l is the length of the hexagons' sides and l' is the unknown, the length of the pentagon sides. Solving for l' with l = 1 yields to

(2 cos(30 deg))/(1 + 2 sin(18 deg)) = 1.0705

The rotation has to be figured with some sums and differences over the angles involved in the structure. For brevity's sake let's just say the 6 deg angle comes from 18 + 18 - 30 deg.

The angles differ in case of rings with five and six corners. Therefore, the angles need to be specified manually. Trigonometric calculations using the regular/symmetric structure give the angles:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\pgfmathsetmacro\angleA{-acos((sqrt(3)-1)/2)+30}
\pgfmathsetmacro\angleB{-\angleA + 30}
\chemfig{*6(-(-[::\angleA]-[::\angleB]?)-(*6(-?-----))----)}
\end{document}


Version with labelled atoms for the calculation:

\chemfig{*6(-A(-[::\angleA]B-[::\angleB]C?)-E(*6(-D?-----))----)}


Calculation:

1. The length of AD is calculated by the the law of sinus of the triangle ADE with angles 120° and two times 30°. The length of AE and DE is the bond length.

2. F is the orthogonal projection of B to the line AD. Then, there is an orthogonal triangle ABF. The length of AF can be calculated by subtracting the bond length from AD and dividing the result by two.

3. The angle FAB is calculated (right triangle, see right-angled triangle definitions) and compared to -30°, the direction of the bond towards A. The result is stored in macro \angleA.

4. The second relative angle \angleB angle is calculated to give the absolute angle of 0°.

Result:

\angleA: -38.529°
\angleB:  68.529°


## Double bound

It still works with a double bound at the bottom:

\pgfmathsetmacro\angleA{-acos((sqrt(3)-1)/2)+30}
\pgfmathsetmacro\angleB{-\angleA + 30}
\chemfig{*6(-(-[::\angleA]=[::\angleB]?)-(*6(-?-----))----)}


The problem here is that the command *<n>(<code>) is for regular polygons, and the 5-membered ring that you're trying to draw cannot possibly be regular (the angle around the top atom is already fixed at 120deg.

My solution is one of trial and error, but if I come up with another, more elegant solution I'll post it here again.

## Code

\documentclass{article}
\usepackage{chemfig}

\begin{document}
\chemfig{*6(-(-[::-42]=^[::72,1.11]?)-(*6(-?-----))----)}
\end{document}


## Idea:

• The typical angle for a regular polygon is 108 deg. Going CW from 12 o' clock position, the angles of the modified polygon are 120, 102, 108, 108, 102. Since we already have 120 deg at the top, I spread out the extra -12 degrees on either side to make 102 deg each.
• I had to increase the length of the bottom-most bond because of the weird angle, using [::72,1.11].
• The two ? ensures that the bonds are joint correctly, and makes up for any length error coming from the bottom-most bond.

## EDIT

Alternative solution with the bottom bond having the same length as the hexagons. To preserve the pentagon shape, geometry then necessitates the two side bonds to be elongated, like so:

\chemfig{*6(-(-[::-42,1.18]=^[::72]?)-(*6(-?-----))----)}


Personally I think this looks uglier. :-p

## Correction

Well, colour me surprised. It is possible to have a pentagon with equal sides but unequal interior angles, known as an equilateral pentagon. @Heiko's method is conclusively better, that answer/code produces an equilateral pentagon.

• Nice solution. Unfortunately are there some problems with the double bond being to long. The ring command does this atomatically right. \chemfig{*6(-(-[::-42]=^[::72,1.11]?)-(*6(-?-----))----)} – Joel Duscha Apr 16 '17 at 2:58
• It's a necessarily evil, because like I said, geometry doesn't permit the bonds to be all of the same length. So it's either the double bond being too long, or the two side bonds being longer than the rest. I'll give the second one a shot. – Troy Apr 16 '17 at 3:04
• I tried again and found this: \chemfig{*6(- ([::10,1.1]*5(---)) -*6(------)----)} But it is a not perfect either. – Joel Duscha Apr 16 '17 at 3:19
• @JoelDuscha Like I said, it's not possible in 2-D for the pentagon to have the same length for all bonds. I don't take chemistry as a major, but I would suppose if this were a planar molecule, the bond lengths wouldn't be the same. If they were, then the molecule would not be planar, and drawing the bonds as Cram bonds would be more suitable? – Troy Apr 16 '17 at 3:29

In spite of the perfect symmetry taking the angles calculated by Heiko, I do not like very much a stumpy pyrrole (A), and enlarged bonds, as stated by Troy, does not help too much, because differences in angles still are clear at a glance inside the pentagon.

My idea is that irregular hexagons could be less noticeable that a simetric equilateral, but not regular, pentagon, so I tryed with:

(B) reducing a bit 5 of 6 angles of both benzene rings, so the bonds shared with the pyrrole ring are shorter, reducing a little the stumpy aspect of the pentagon. However, is not still a regular pentagon, due to the upper angle is far of the 108 degrees. More disclaimers: (a) I left trigonometric calculations to math experts, so symmetry shoul be not perfect (i. e., the angles were determined at a rough guess). (b) This approach avoid use *6(...) and *5(...) rings, so the double bonds look worse.

(C) Attempt to make a true regular pentagon just using one *5(...) and two *6(...) benzene rings, but modified to adapt to the pentagon shape, so they are irregular hexagons. With some rotations of the molecule is hard to me detect the irregular rings, but as showed here, the lack of perfect vertical lines make this more apparent.

(D) Like (C) but in other way (the results is also a bit different).

IMHO there are no good solution in this case, is up to you what is the least bad option.

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\setatomsep{20pt}\footnotesize
\chemname{\chemfig{*6(?[a]=
(-[::-38.529]=^[::68.529]?[c])
-*6(-?[c]=-=?[b])=?[b]-=?[a])}}{ --- A --- }
\chemname{\chemfig{[:90](?[a]?[c]=^
(-[::-60.5]=_[::-60.5]-[::-60.5]=_[::-60.5]?[a]?[b])-[::60.5]=^[::60.5]-[::60.5]=^[::60.5]?[c](-[::-44.4]=^[::72]?[b]))}}{ --- B --- }
\chemname{\chemfig{*6([::0]?[a]=
*5([::6]-=-?[d,2]-?[c,2]-)
-[,,,,,draw=none]*6([::-0]-[,,,,,draw=none]=[,,,,,draw=none]?[d,2]-=?[b])-[,,,,,draw=none]?[b]?[c,2]-=?[a])}}{--- C --- }
\chemname{\chemfig{*6([::6]=*5(-=--(=^[,.95]?[a]))-*6([::-12]-=-=?[a])=[,,,,,draw=none]-[,,,,,draw=none]?[a]=-)}}{--- D --- }

\chemfig{*6(?[a]=
(-[::-38.529]\chembelow{N}{H}-[::68.529]?[c])
-*6(-?[c]=-=?[b])=?[b]-=?[a])}
\chemfig{[:90](?[a]?[c]=^(-[::-61]=_[::-61]-[::-61]=_[::-61]?[a]?[b])-[::61]=^[::61]-[::61]=^[::61]?[c](-[::-48]\chembelow{N}{H}
-[::74,,1]-[::74]))}
\chemfig{*6([::0]?[a]=
*5([::6]-\chembelow{N}{H}--?[d,2]-?[c,2]-)
-[,,,,,draw=none]*6([::-2]-[,,,,,draw=none]=[,,,,,draw=none]?[d,2]-=?[b])-[,,,,,draw=none]?[b]?[c,2]-=?[a])}
{\chemfig{*6([::6]=*5(-\chembelow{N}{H}---(=^[,.95]?[a]))-*6([::-12]-=-=?[a])=[,,,,,draw=none]-[,,,,,draw=none]?[a]=-)}

\end{document}


Well, the angles don't fit together. Therefore, you can't use ring syntax. You could draw it like this instead:

\chemfig{*6(-(-X?)-(*6(-(-?)-----))----)}
`

The question marks connect the two branches from the two six-membered rings.