Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to scale a reaction scheme generated with chemfig to .9/textwidth. Below is my MWE.

\documentclass{report}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\begin{document}

\begin{figure}[width=.9\textwidth]
\schemestart
\ce{O2^.-}\arrow (c1--c2){0}\ce{NO^.}\merge{v}(c1)(c2)--(c3)\ce{ONOO-}
\arrow (--c4){<=>[*{0}\parbox{1.2cm}{\ce{+ H+}\\ pK 6.6}][*{0}\ce{- H+}]}[-90,1.5]\ce{ONOOH}
\arrow(--c5){->[\ce{+ NO^.}][\ce{- HNO2}]}[0,1.5]\ce{NO2^.}
\arrow(--c6){->[\ce{+ NO^.}]}\ce{N2O3}
\arrow(@c4--c7){->[\ce{+ O2^.-}][\ce{- OH-},\ce{- O2}]}[180,1.5]\ce{NO2^.}
\arrow(@c7--c8){->[\ce{+ O2^.-}]}[180]\parbox{1.5cm}{\centering \ce{O2NOO-}\\or \\\ce{NO2- + O2}}
\arrow(@c3--@c7){->[\ce{+ CO2}][\ce{- CO3^.}]}[2.12]
\arrow(@c3--@c5){->[\ce{+ CO2}][\ce{- CO3^.-}]}[2.12]
\arrow(@c1--c9){->[\ce{+ O2^.-}, \ce{+ 2H+}][\ce{- O2}]}[180,1.5]\ce{H2O2}
\arrow(@c9--c10){->[\ce{Fe2+}][\ce{- OH-}]}[180]\ce{^.OH}
\arrow(@c2--c11){->[\ce{+ O2}]}$[$\ce{^.ONOO}$]$
\arrow(@c11--c12){->[\ce{+ ^.NO}]}\ce{2 NO2^.}
\schemestop

\end{figure}
\end{document}

However, this still results in the following and seems not to scale the figure:

Overfull \hbox (71.11223pt too wide) in paragraph at lines 20--21.

Any thoughts and comments how to change this would be very much appreciated. Hope that is clear enough.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Just put it in a \scalebox perhaps:

\documentclass{report}
\usepackage{chemfig}
\usepackage{graphicx}
\usepackage[version=3]{mhchem}
\begin{document}

\begin{figure}[width=.9\textwidth]
\scalebox{.6}{
\schemestart
\ce{O2^.-}\arrow (c1--c2){0}\ce{NO^.}\merge{v}(c1)(c2)--(c3)\ce{ONOO-}
\arrow (--c4){<=>[*{0}\parbox{1.2cm}{\ce{+ H+}\\ pK 6.6}][*{0}\ce{- H+}]}[-90,1.5]\ce{ONOOH}
\arrow(--c5){->[\ce{+ NO^.}][\ce{- HNO2}]}[0,1.5]\ce{NO2^.}
\arrow(--c6){->[\ce{+ NO^.}]}\ce{N2O3}
\arrow(@c4--c7){->[\ce{+ O2^.-}][\ce{- OH-},\ce{- O2}]}[180,1.5]\ce{NO2^.}
\arrow(@c7--c8){->[\ce{+ O2^.-}]}[180]\parbox{1.5cm}{\centering \ce{O2NOO-}\\or \\\ce{NO2- + O2}}
\arrow(@c3--@c7){->[\ce{+ CO2}][\ce{- CO3^.}]}[2.12]
\arrow(@c3--@c5){->[\ce{+ CO2}][\ce{- CO3^.-}]}[2.12]
\arrow(@c1--c9){->[\ce{+ O2^.-}, \ce{+ 2H+}][\ce{- O2}]}[180,1.5]\ce{H2O2}
\arrow(@c9--c10){->[\ce{Fe2+}][\ce{- OH-}]}[180]\ce{^.OH}
\arrow(@c2--c11){->[\ce{+ O2}]}$[$\ce{^.ONOO}$]$
\arrow(@c11--c12){->[\ce{+ ^.NO}]}\ce{2 NO2^.}
\schemestop
}

\end{figure}
\end{document}

However, to answer the more specific question of matching the figure width to the textwidth, we can borrow from Philipp's answer at How to find the ratio of a length command (e.g., \textwidth) to a reference value (e.g., 6cm) ?, and can indirectly scale the box to the textwidth as follows (note I add a lipsum paragraph to show it is the proper width). To do this, I save the figure in \x. Then I find the natural width of \x, so that I can develop the proper scale ratio. Then I \scalebox the image to the proper scale:

\documentclass{report}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\usepackage{lipsum}
\makeatletter
\newcommand*{\DivideLengths}[2]{%
    \strip@pt\dimexpr\number\numexpr\number\dimexpr#1%
     \relax*65536/\number\dimexpr#2\relax\relax sp\relax
}
\makeatother
\global\newlength\thewidth
\newcommand\findwidth[1]{\setbox0\hbox{#1}\setlength\thewidth{\wd0}}
\begin{document}
\def\x{
\schemestart
\ce{O2^.-}\arrow (c1--c2){0}\ce{NO^.}\merge{v}(c1)(c2)--(c3)\ce{ONOO-}
\arrow (--c4){<=>[*{0}\parbox{1.2cm}{\ce{+ H+}\\ pK 6.6}][*{0}\ce{- H+}]}[-90,1.5]\ce{ONOOH}
\arrow(--c5){->[\ce{+ NO^.}][\ce{- HNO2}]}[0,1.5]\ce{NO2^.}
\arrow(--c6){->[\ce{+ NO^.}]}\ce{N2O3}
\arrow(@c4--c7){->[\ce{+ O2^.-}][\ce{- OH-},\ce{- O2}]}[180,1.5]\ce{NO2^.}
\arrow(@c7--c8){->[\ce{+ O2^.-}]}[180]\parbox{1.5cm}{\centering \ce{O2NOO-}\\or \\\ce{NO2- + O2}}
\arrow(@c3--@c7){->[\ce{+ CO2}][\ce{- CO3^.}]}[2.12]
\arrow(@c3--@c5){->[\ce{+ CO2}][\ce{- CO3^.-}]}[2.12]
\arrow(@c1--c9){->[\ce{+ O2^.-}, \ce{+ 2H+}][\ce{- O2}]}[180,1.5]\ce{H2O2}
\arrow(@c9--c10){->[\ce{Fe2+}][\ce{- OH-}]}[180]\ce{^.OH}
\arrow(@c2--c11){->[\ce{+ O2}]}$[$\ce{^.ONOO}$]$
\arrow(@c11--c12){->[\ce{+ ^.NO}]}\ce{2 NO2^.}
\schemestop
}
\findwidth{\x}
\begin{figure}[width=.9\textwidth]
\scalebox{\DivideLengths{\textwidth}{\thewidth}}{\x}
\end{figure}
\lipsum[1]
\end{document}

enter image description here

share|improve this answer
    
Thanks, didn't know about \scalebox. Still new to all this. However it seems that this will not scale the figure to the \textwidth. Is there a way to scale it to the actual \textwidth? –  Katja Menger May 13 '13 at 13:21
    
@KatjaMenger Does the \makebox approach work for you? –  Steven B. Segletes May 13 '13 at 14:50
    
It seems as if the \makebox only centers the figure, so that the overhang is on both sides and playing with fractions of .9\textwidth or .8\textwidth just shifts the figure more towards the left edge of the page. –  Katja Menger May 13 '13 at 15:09
    
@KatjaMenger, fixed, with the help of referenced page. –  Steven B. Segletes May 13 '13 at 15:56
    
Thank you, that helps a lot. I don't entirely understand what you did with the \DivideLengths command, but at least it now scales everything accordingly. –  Katja Menger May 13 '13 at 16:33

I believe the easiest way out is not to scale the scheme but to slightly rearrange it:

enter image description here

\documentclass{article}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\usepackage{showframe}% show page layout
\begin{document}

\begin{figure}[ht]
\centering
\schemestart
 \ce{O2^.-}\arrow (c1--c2){0}\ce{NO^.}
 \merge{v}(c1)(c2)--(c3)\ce{ONOO-}
 \arrow (--c4){<=>[*{0}\parbox{1.2cm}{\ce{+ H+}\\ pK 6.6}][*{0}\ce{- H+}]}[-90,1.5]\ce{ONOOH}
 \arrow(--c5){->[\ce{+ NO^.}][\ce{- HNO2}]}[0,1.5]\ce{NO2^.}
 \arrow(--c6){->[*0\ce{+ NO^.}]}[-90]\ce{N2O3}
 \arrow(@c4--c7){->[\ce{+ O2^.-}][\ce{- OH-},\ce{- O2}]}[180,1.5]\ce{NO2^.}
 \arrow(@c7--c8){->[*0\ce{+ O2^.-}]}[-90]\parbox{1.5cm}{\centering \ce{O2NOO-}\\or \\\ce{NO2- + O2}}
 \arrow(@c3--@c7){->[\ce{+ CO2}][\ce{- CO3^.}]}[2.12]
 \arrow(@c3--@c5){->[\ce{+ CO2}][\ce{- CO3^.-}]}[2.12]
 \arrow(@c1--c9){->[\ce{+ O2^.-}, \ce{+ 2H+}][\ce{- O2}]}[180,1.5]\ce{H2O2}
 \arrow(@c9--c10){->[*0\ce{Fe2+}][*0\ce{- OH-}]}[-90]\ce{^.OH}
 \arrow(@c2--c11){->[\ce{+ O2}]}$[$\ce{^.ONOO}$]$
 \arrow(@c11--c12){->[*0\ce{+ ^.NO}]}[-90]\ce{2 NO2^.}
\schemestop
\end{figure}

\end{document}
share|improve this answer
    
thank you, while this is a solution, it changes the layout of the scheme and it is this layout that I need for my document. So a scaleable approach is needed. –  Katja Menger May 13 '13 at 17:58
    
@KatjaMenger whatever suits you best! :) I find it strange though that you're required layout - the adjustments does not change any meaning or information (I actually think there's a slight gain in information by having the products aligned horizontally). (Don't forget to vote on any answer you found useful such as Steven's). –  cgnieder May 13 '13 at 18:10
    
“that you're required layout” should read “that you're required to use a certain layout/arrangement” –  cgnieder May 13 '13 at 19:43
    
@StevenSegletes Unfortunately I am not able to vote yet. I will as soon as I can. Thanks for all your help. –  Katja Menger May 14 '13 at 22:24

The optional argument to the figure environment only deals with the allowed position of the float, it cannot contain scaling or other things.

Another way of reducing the size is to simply reduce the fontsize, by adding \scriptsize right after \begin{figure}.

You can also squeeze things together a bit with the optional argument to \schemestart, e.g. \schemestart[0,.7].

\documentclass{report}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\begin{document}

\begin{figure}
\scriptsize
\schemestart
% option 2 -- comment out the two previous lines, uncomment the two next.
%\small
%\schemestart[0,.7]
\ce{O2^.-}\arrow (c1--c2){0}\ce{NO^.}\merge{v}(c1)(c2)--(c3)\ce{ONOO-}
\arrow (--c4){<=>[*{0}\parbox{1.2cm}{\ce{+ H+}\\ pK 6.6}][*{0}\ce{- H+}]}[-90,1.5]\ce{ONOOH}
\arrow(--c5){->[\ce{+ NO^.}][\ce{- HNO2}]}[0,1.5]\ce{NO2^.}
\arrow(--c6){->[\ce{+ NO^.}]}\ce{N2O3}
\arrow(@c4--c7){->[\ce{+ O2^.-}][\ce{- OH-},\ce{- O2}]}[180,1.5]\ce{NO2^.}
\arrow(@c7--c8){->[\ce{+ O2^.-}]}[180]\parbox{1.5cm}{\centering \ce{O2NOO-}\\or \\\ce{NO2- + O2}}
\arrow(@c3--@c7){->[\ce{+ CO2}][\ce{- CO3^.}]}[2.12]
\arrow(@c3--@c5){->[\ce{+ CO2}][\ce{- CO3^.-}]}[2.12]
\arrow(@c1--c9){->[\ce{+ O2^.-}, \ce{+ 2H+}][\ce{- O2}]}[180,1.5]\ce{H2O2}
\arrow(@c9--c10){->[\ce{Fe2+}][\ce{- OH-}]}[180]\ce{^.OH}
\arrow(@c2--c11){->[\ce{+ O2}]}$[$\ce{^.ONOO}$]$
\arrow(@c11--c12){->[\ce{+ ^.NO}]}\ce{2 NO2^.}
\schemestop

\end{figure}
\end{document}
share|improve this answer
    
Thanks, I will most likely go with the second option, completely ignored the additional arguments to \schemestart previously. It will then fit nicely in my pagelayout. –  Katja Menger May 13 '13 at 13:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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