3

This is a continuation of my previous question. I am dealing with the following code to include chemical reactions into the shape of a cloud.

\documentclass{article}
\usepackage{chemfig}
\usepackage{tikz}
\usetikzlibrary{shapes}

\newsavebox\ReactionBox
\sbox\ReactionBox{
\tiny
\setchemfig{compound style={draw,line width=0.8pt,
semitransparent,text opacity=1,inner sep=3pt,
rounded corners=1mm}}
\schemestart[0,1,line width=0.6mm]
$A + B$ \arrow([fill=cyan]--[fill=cyan]){->[k_1]}[,,green] $C$
\schemestop  

\schemestart[0,1,line width=0.6mm]
$C$ \arrow([fill=cyan]--[fill=cyan]){->[k_2]}[,,green] $D$
\schemestop  
}


\begin{document}
\begin{tikzpicture} 
    \node [align=center,cloud, draw,cloud puffs=10,cloud puff arc=120, aspect=2, inner ysep=2em] 
    {\usebox\ReactionBox};
\end{tikzpicture} 

\end{document}

The problem is that both reactions appear next to each other instead of one above the other. How to go about fixing this?

enter image description here

1 Answers1

3

One way would be to use two \saveboxes:

enter image description here

The problem has nothing to do with tikz as can be seen if you simply use \usebox\ReactionBox.

Notes:

Code:

\documentclass[border=2pt]{standalone}
\usepackage{chemfig}
\usepackage{tikz}
\usetikzlibrary{shapes}

\newsavebox\ReactionBoxA \newsavebox\ReactionBoxB \sbox\ReactionBoxA{% <-- Added % \tiny \setchemfig{compound style={draw,line width=0.8pt, semitransparent,text opacity=1,inner sep=3pt, rounded corners=1mm}}% <-- Added % \schemestart[0,1,line width=0.6mm] $A + B$ \arrow([fill=cyan]--[fill=cyan]){->[]}[,,green] $C$ \schemestop}

\sbox\ReactionBoxB{% \tiny \setchemfig{compound style={draw,line width=0.8pt, semitransparent,text opacity=1,inner sep=3pt, rounded corners=1mm}}% <-- Added % \schemestart[0,1,line width=0.6mm] $C$ \arrow([fill=cyan]--[fill=cyan]){->[]}[,,green] $D$ \schemestop}

\begin{document} \begin{tikzpicture} \node [align=center,cloud, draw,cloud puffs=10,cloud puff arc=120, aspect=2, inner ysep=2em] {\usebox\ReactionBoxA \ \usebox\ReactionBoxA}; \end{tikzpicture}

\end{document}

Peter Grill
  • 223,288