6
\documentclass[10pt]{article}
\usepackage{chemfig}
\usepackage[margin=1.2in]{geometry}
\newcommand{\chem}{\setatomsep{2em}\chemfig}

\begin{document}

\begin{itemize}
\item[--] 1$^\circ$ Alcohol $\rightarrow$  Aldehyde\\
\centerline{\schemestart
\chem{R-C(-[2]OH)(-[6]H)-H} \arrow{0}[,0] \+ [O] \arrow \chem{R-[:30]C(=[2]O)-[:-30]H} \arrow{0}[,0] \+ H$_2$O
\schemestop}
\end{itemize}

\end{document}

The above gives:

Overfull \hbox (25.00003pt too wide) in paragraph

It was working but now it doesn't, how can I fix it?

2
  • 1
    Please, make that code snippet into a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – egreg
    May 8, 2013 at 18:00
  • I assume \newcommand{\chem}{\setatomsep{2em}\chemfig} is to have a command that's supposed to locally use an atomsep of 2em? If yes then the definition is wrong since the scope is not local to \chem. It simply sets the atomsep to 2em for all following appearances of \chemfig. It works in your MWE since the scheme places its compounds into TikZ nodes which are TeX groups. So it probably doesn't matter if you only use \chem inside \schemestart ...\schemestop. But it you use it anywhere else in the document beware to use it inside a group.
    – cgnieder
    May 8, 2013 at 20:41

2 Answers 2

10

\centerline{ isn't really a latex command (it is in the latex format but just escaped from plain TeX). It makes a box \hsize wide but does not know about latex list structures and the indentation they introduce. So you line is too wide by 25pt which will be the left margin of the list item. Just remove \centerline and replace it with a \begin{center}...\end{center}.

5
  • I need to have the line centered though, as chemical equations look much better in the center.
    – Levi H
    May 8, 2013 at 19:13
  • @STRAIGHTOUTTACOMPTON \begin{center}...\end{center} May 8, 2013 at 19:19
  • Thanks but now I get "Underfull \hbox (badness 10000) in paragraph" instead. I even get it in the ones not even inside of itemize
    – Levi H
    May 8, 2013 at 19:45
  • 1
    Edit: never mind removing the \\ did fix it
    – Levi H
    May 8, 2013 at 19:51
  • delete the \\ as well (\\ is almost always the wrong thing if used in a paragraph rather than to end a table row) I just checked, your example then runs with no warnings. May 8, 2013 at 19:53
0

If you really want to, you can redefine the \centerline command to get rid of the warning: \renewcommand{\centerline}[1]{\null\hfill#1\hfill\null}

\documentclass[10pt]{article}
\usepackage{chemfig}
\usepackage[margin=1.2in]{geometry}
\newcommand{\chem}{\setatomsep{2em}\chemfig}

\renewcommand{\centerline}[1]{\null\hfill#1\hfill\null}

\begin{document}
  \begin{itemize}
    \item[--] 1$^\circ$ Alcohol $\rightarrow$  Aldehyde\\
                \centerline{
                  \schemestart 
                  \chem{R-C(-[2]OH)(-[6]H)-H} \arrow{0}[,0] \+ [O] \arrow 
                  \chem{R-[:30]C(=[2]O)-[:-30]H} \arrow{0}[,0] \+ H$_2$O
                  \schemestop
                }
  \end{itemize}
\end{document}

Output

1
  • Thanks, I figured it out about 6 years 3 months ago though. Just kidding, it's just strange to give such a hackish answer 6 years after the fact.
    – Levi H
    Aug 20, 2019 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .