Q: Parentheses within chemfig are shifted in height I am trying to draw a polymer with repeating units using chemfig. However, my opening and closing parentheses are shifted in vertical direction. This is my minimal working example:
\documentclass[a4paper]{scrbook} \nonstopmode
\input{header}
\begin{document}
\setpolymerdelim()
\chemfig{
    H_3C-[1](-[7]-[1]O-[@{opa,.5}7]-[1]-[7]O-[@{cla,.5}1](=[2]O)(-[7]=[1]CH_2))
}
\makebraces[0pt,45pt]{\!\!\!n}{opa}{cla}
\end{document}

with header.tex:
\usepackage[utf8]{inputenc}
\usepackage{chemfig}

% Chemfig brackets
\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$}}$};}}

The makebraces and setpolymerdelim-part is just copy&paste of the chemfig manual. Below you find an screenshot of the output:


A: You need to adjust the first parameter in your call to \makebraces to shift them upward. The total brace height is the sum of the two optional parameters (45 pt in your MWE). Keeping that same overall height:
\documentclass[a4paper]{scrbook} \nonstopmode
\usepackage[utf8]{inputenc}
\usepackage{chemfig}

% Chemfig brackets
\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$}}$};}}

\begin{document}
\setpolymerdelim()
\chemfig{
    H_3C-[1](-[7]-[1]O-[@{opa,.5}7]-[1]-[7]O-[@{cla,.5}1](=[2]O)(-[7]=[1]CH_2))
}
\makebraces[20pt,25pt]{\!\!\!n}{opa}{cla}
\end{document}

Yields:

Edit:
The individual braces are positioned based on the passed nodes (opa and cla which are positioned along the bonds. Since the bond are not symmetric, the left brace is lower than the right brace. If you want the braces to be at the same height, you will need to modify the \makebraces command. The following sets the two braces at the average y for the two points:
\documentclass[a4paper]{scrbook} \nonstopmode
\usepackage[utf8]{inputenc}
\usepackage{chemfig}
\usetikzlibrary{calc}

% Chemfig brackets
\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{%
\path let \p1=(#4), \p2=(#5) in node[yshift=(\delimvshift)] at (\x1,0.5*\y1+0.5*\y2)
{$\left\delimleft\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right.$};%
\path let \p1=(#4), \p2=(#5) in node[yshift=(\delimvshift)] at (\x2,0.5*\y1+0.5*\y2)
{$\left.\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};}}

\begin{document}
\setpolymerdelim()
\chemfig{
    H_3C-[1](-[7]-[1]O-[@{opa,.5}7]-[1]-[7]O-[@{cla,.5}1](=[2]O)(-[7]=[1]CH_2))
}
\makebraces[20pt,25pt]{\!\!\!n}{opa}{cla}
\end{document}


