# DPPC (Dipalmitoylphosphatidylcholine) DSPC and DMPC in Latex

Using chemfig I was able to represent DPPC (Dipalmitoylphosphatidylcholine) and other lipids in Latex by using the following code

\newcommand\setpolymerdelim[2]{\def\delimleft{#1}\def\delimright{#2}}
\def\makebraces[#1,#2]#3#4#5{%
\edef\delimhalfdim{\the\dimexpr(#1+#2)/2}%
\edef\delimvshift{\the\dimexpr(#1-#2)/2}%
\chemmove{%
\node[at=(#4),yshift=(\delimvshift)]
{$\left\delimleft\vrule height\delimhalfdim depth\delimhalfdim width0pt\right.$};%
\node[at=(#5),yshift=(\delimvshift)]
{$\left.\vrule height\delimhalfdim depth\delimhalfdim width0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};}}
\setpolymerdelim[]

\begin{figure}
\small
\setatomsep{1.5em}
\chemfig{N^+(-[:180,1.1]H_3C)(-[:90,1.3]CH_3)(-[:270,1.3]CH_3)(-[:-30]-[:30]-[:-30]O-[:30,1.3]P^+(<[:50,1.5]O\rlap{${}^-$})(<:[:130,1.5]O\rlap{${}^-$})(-#(1pt,)[:330,1.3]O-[:30]-[:-30](-[:270]O-[:-30](=[:270]O)(-[@{downleft,0.8}:30]CH_2-#(1pt,1pt)[@{downright,0.3}:-30,1.2]CH_3))(-[:30]-[:-30]O-[:30](=[:90]O)(-[@{upleft,0.8}:-30]CH_2-#(1pt,1pt)[@{upright,0.3}:30,1.2]CH_3))))}
\makebraces[10pt,13pt]{n}{downleft}{downright}
\makebraces[6pt,15pt]{n}{upleft}{upright}
\label{fig:lipids}
\end{figure}

The crucial line is:
\chemfig{N^+(-[:180,1.1]H_3C)(-[:90,1.3]CH_3)(-[:270,1.3]CH_3)(-[:-30]-[:30]-[:-30]O-[:30,1.3]P^+(<[:50,1.5]O\rlap{${}^-$})(<:[:130,1.5]O\rlap{${}^-$})(-#(1pt,)[:330,1.3]O-[:30]-[:-30](-[:270]O-[:-30](=[:270]O)(-[@{downleft,0.8}:30]CH_2-#(1pt,1pt)[@{downright,0.3}:-30,1.2]CH_3))(-[:30]-[:-30]O-[:30](=[:90]O)(-[@{upleft,0.8}:-30]CH_2-#(1pt,1pt)[@{upright,0.3}:30,1.2]CH_3))))}

You’ll also need to include the following in the preamble

\usepackage{chemfig}

Which produces something that looks like this: