2

I am using \chemfig for writing chemical symbols, but those symbols they are misaligned with the rest of the text. Is there a package that I should add?

enter image description here

\documentclass[11pt]{report} 
\usepackage[english,greek]{babel} 
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{chemfig} 
\begin{document} 
\par{Το πυρίτιο \chemfig{(Si)} που ανιχνεύθηκε καθώς και το βάριο \chemfig{(Ba)} αποτελούν τμήμα των ανόργανων ενισχυτικών ουσιών που εμφανίστηκαν στην επιφάνεια των δειγμάτων κατά την διαδικασία της λείανσης και στίλβωσης.} 
\end{document} 
  • please provide a small example that can be compiled, so that helpers don't have to guess what you are doing. – barbara beeton Mar 28 '16 at 19:33
  • \documentclass[11pt]{report} \usepackage[english,greek]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{chemfig} \begin{document} \par{Το πυρίτιο \chemfig{(Si)} που ανιχνεύθηκε καθώς και το βάριο \chemfig{(Ba)} αποτελούν τμήμα των ανόργανων ενισχυτικών ουσιών που εμφανίστηκαν στην επιφάνεια των δειγμάτων κατά την διαδικασία της λείανσης και στίλβωσης.} \end{document} – Petros Mourouzis Apr 2 '16 at 8:01
  • it's always possible to edit your own question. that's where examples should be entered, not in comments. i've moved your example code into the question so it's easier for others to look at and experiment with. – barbara beeton Apr 2 '16 at 12:10
  • I didn't notice the parentheses in the first place..thank you again – Petros Mourouzis Apr 2 '16 at 12:49
2

The parentheses ( and ) are special characters inside \chemfig. They denote branching (and also are part or the ring syntax). \chemfig{(Si)} starts a branch after an empty atom which in effect seems to shift the baseline.

\documentclass{article}

\usepackage{chemfig}

\begin{document}

X\chemfig{H-C-H}X\chemfig{C}X \par
X\chemfig{-C-}X\chemfig{(C)}X

\end{document}

enter image description here

In your case the simple solution is to not put the parentheses inside the formula as they are not a part of it:

Write (\chemfig{Si}) instead of \chemfig{(Si)}.

\documentclass{article}

\usepackage{chemfig}

\begin{document}

X\chemfig{(C)}X(\chemfig{C})X

\end{document}

enter image description here

In theory you could also write \chemfig{{(}Si{)}}, i.e., put the parentheses in braces in order to have them interpreted as atoms. The output is ok but semantically this is wrong: this treats the parentheses as part of the chemical formula.

As my first example shows the same is true for compounds starting with a bond:

\documentclass{article}

\usepackage{chemfig}

\begin{document}

X\chemfig{-OH}X\chemfig{OH-[4]}X

\end{document}

enter image description here

  • Thank you very much, it work for single atoms but when I tried to write (\chemfig{-OH}) again I had the same problem.. – Petros Mourouzis Jun 23 '16 at 9:31
  • @PetrosMourouzis of course! My first example actually demonstrates this with \chemfig{-C-}. \chemfig{-OH} also starts with an empty atom. You need to start with a non-empty atom, e.g., write \chemfig{OH-[4]} instead. – clemens Jun 23 '16 at 9:49
  • @PetrosMourouzis if my answer helped you you may consider upvoting it. And if it solved your problem you may also consider accepting it (which marks it as solved). – clemens Jun 23 '16 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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