Duplicación y traducción horizontal en tikz.

Duplicación y traducción horizontal en tikz.

Soy nuevo en tikz, encontré este código sin conexión pero tengo una experiencia mínima con la codificación. Quiero tener cinco matraces seguidos con flechas apuntando en la misma dirección hacia los matraces. Además, me gustaría agregar medidas de volumen.

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{calc, shadings, arrows.meta}

\definecolor{tappo}{RGB}{148,154,110}
\definecolor{lightblue}{RGB}{155,210,220}

\tikzset{
    arrR/.style={-Latex},
    arrL/.style={Latex-}
}

\newcommand\flask[4][arrR]{%
\begin{scope}[shift={(#2)}]
\draw[gray] (-1.8,0) arc (180:0:1.8cm and 6mm);
\begin{scope}
\clip[rounded corners=5mm] (-.5,5) -- (-.5,3.5) -- (-1.8,.5) [sharp corners]-- (-1.8,0) arc (180:360:1.8cm and 6mm) [rounded corners=5mm]--  (1.8,.5) --  (.5,3.5) [sharp corners]-- (.5,5) -- cycle;
\end{scope}

\draw[right color=tappo, left color=tappo, middle color=tappo!40] (.4,4.5) -- (.6,5.5) arc (0:180:6mm and 2mm) -- (-.4,4.5) arc (180:360:4mm and 2mm);
\draw[fill=tappo!60] (0,5.5) ellipse (6mm and 2mm);
\draw[fill=lightblue,rounded corners=5mm, fill opacity=.7] (-.5,5) -- (-.5,3.5) -- (-1.8,.5) [sharp corners]-- (-1.8,0) arc (180:360:1.8cm and 6mm) [rounded corners=5mm]--  (1.8,.5) --  (.5,3.5) [sharp corners]-- (.5,5) arc (360:180:5mm and 2mm);
\draw[fill=lightblue, opacity=.5] (.5,5) to[out=-50,in=230, looseness=2] (-.5,5) arc (180:360:5mm and 2mm);

\begin{scope}[remember picture,overlay,shift={(0,7.5)},rotate=210-(#3*.16)]
\filldraw[black] (-.2,.03) --++ (1,-.01) --++ (0,-.04) --++ (-1,-.01) --++ (0,-.08) --++ (-.05,0) --++ (0,.22) --++ (.05,0) -- cycle;
\end{scope}

\begin{scope}
\draw[#1, line width=.2mm] (1.5,3.9) -- (2.5,3.9) node[right, font=\scriptsize] {#4};

\end{scope}
\begin{scope}[xshift=4mm]

\end{scope}
\end{scope}
}

\begin{document}
\begin{tikzpicture}

\flask{0,0}{0}{1 Molar};
\flask[arrL]{5,0}{130}{0.5 Molar};
\flask[arrL]{10,0}{590}{0.125 Molar};

\end{tikzpicture}
\end{document}

Respuesta1

¡Bienvenido a TeX:SE!

En su MWE (ejemplo de trabajo mínimo), con el siguiente fragmento de código se dibujan tres matraces:

\flask{0,0}{0}{1 Molar};
\flask[arrL]{5,0}{130}{0.5 Molar};
\flask[arrL]{10,0}{590}{0.125 Molar};

Si desea tener más, simplemente agregue más líneas de código con la distancia horizontal deseada entre sus centros. Por ejemplo:

\flask{0,0}{0}{1 Molar};
\flask[arrL]{5,0}{130}{0.5 Molar};
\flask[arrL]{10,0}{590}{0.125 Molar};
\flask[arrL]{15,0}{590}{0.125 Molar};
\flask[arrL]{20,0}{590}{0.125 Molar};

Con esta distancia la imagen se saldrá de la página. Para evitar esto, es necesario reducir las distancias en consecuencia. Por ejemplo como se hace en el siguiente WME:

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc, 
                shadings}

\definecolor{tappo}{RGB}{148,154,110}
\definecolor{lightblue}{RGB}{155,210,220}

\tikzset{
    arrR/.style={-Latex},
    arrL/.style={Latex-}
}

\newcommand\flask[4][arrR]{%
\begin{scope}[shift={(#2)}]
\draw[gray] (-1.8,0) arc (180:0:1.8cm and 6mm);
\begin{scope}
\clip[rounded corners=5mm] (-.5,5) -- (-.5,3.5) -- (-1.8,.5) [sharp corners] -- (-1.8,0) arc (180:360:1.8cm and 6mm) [rounded corners=5mm]--  (1.8,.5) --  (.5,3.5) [sharp corners]-- (.5,5) -- cycle;
\end{scope}

\draw[right color=tappo, left color=tappo, middle color=tappo!40] (.4,4.5) -- (.6,5.5) arc (0:180:6mm and 2mm) -- (-.4,4.5) arc (180:360:4mm and 2mm);
\draw[fill=tappo!60] (0,5.5) ellipse (6mm and 2mm);
\draw[fill=lightblue,rounded corners=5mm, fill opacity=.7] (-.5,5) -- (-.5,3.5) -- (-1.8,.5) [sharp corners]-- (-1.8,0) arc (180:360:1.8cm and 6mm) [rounded corners=5mm]--  (1.8,.5) --  (.5,3.5) [sharp corners]-- (.5,5) arc (360:180:5mm and 2mm);
\draw[fill=lightblue, opacity=.5] (.5,5) to[out=-50,in=230, looseness=2] (-.5,5) arc (180:360:5mm and 2mm);

\begin{scope}[remember picture,overlay,shift={(0,7.5)},rotate=210-(#3*.16)]
\filldraw[black] (-.2,.03) --++ (1,-.01) --++ (0,-.04) --++ (-1,-.01) --++ (0,-.08) --++ (-.05,0) --++ (0,.22) --++ (.05,0) -- cycle;
\end{scope}

\begin{scope}
\draw[#1, line width=.2mm] (1,3.9) -- (2,3.9) node[right, font=\scriptsize] {#4};
\end{scope}

\end{scope}
}

\begin{document}
\begin{tikzpicture}

\flask{0,0}{0}{1 Molar};
\flask[arrL]{4.2,0}{130}{0.5 Molar};    % <--- changed
\flask[arrL]{8.4,0}{590}{0.125 Molar};  % <--- changed
\flask[arrR]{12.6,0}{590}{0.125 Molar}; % <--- added
\flask[arrL]{16.8,0}{590}{0.125 Molar}; % <--- added

\end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta2

¡Es una petaca realmente bonita! El problema es que no escala bien debido a rounded corners. Y cinco de ellos no caben en una página. Así que usa \scaleboxy dibuja las flechas usando LaTeXcomandos comunes. Nota: agregué algunas medidas de volumen al matraz.

ingrese la descripción de la imagen aquí

Hice un nuevo comando \scaleflaskque toma un argumento opcional.

\scaleflask[.3]

.3es el factor de escala (opcional) (predeterminado = 1).

ingrese la descripción de la imagen aquí

El código

\[
\scaleflask[.3]\xleftarrow{\textstyle1.0\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.5\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.25\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.13\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.06\Molar}
\]

crea la imagen de arriba. Aquí está el código completo:

\documentclass{article}
\usepackage{tikz, amsmath}
\usetikzlibrary{shadings}

\definecolor{tappo}{RGB}{148,154,110}
\definecolor{lightblue}{RGB}{155,210,220}

\newcommand\flask[1][1]{\begin{tikzpicture}
    \draw[gray] (-1.8,0) arc (180:0:1.8cm and 6mm);
    \begin{scope}
        \clip[rounded corners=5mm] (-.5,5) -- (-.5,3.5) -- (-1.8,.5) [sharp corners]-- 
            (-1.8,0) arc (180:360:1.8cm and 6mm) [rounded corners=5mm]--  (1.8,.5) --  
            (.5,3.5) [sharp corners]-- (.5,5) -- cycle;
    \end{scope}
    \draw[right color=tappo, left color=tappo, middle color=tappo!40] (.4,4.5) -- 
        (.6,5.5) arc (0:180:6mm and 2mm) -- (-.4,4.5) arc (180:360:4mm and 2mm);
    \draw[fill=tappo!60] (0,5.5) ellipse (6mm and 2mm);
    \draw[fill=lightblue,rounded corners=5mm, fill opacity=.7] (-.5,5) -- (-.5,3.5) -- 
        (-1.8,.5) [sharp corners]-- (-1.8,0) arc (180:360:1.8cm and 6mm) [rounded corners=5mm]--  
        (1.8,.5) --  (.5,3.5) [sharp corners]-- (.5,5) arc (360:180:5mm and 2mm); 
    \draw[fill=lightblue, opacity=.5] (.5,5) to[out=-50,in=230, looseness=2] (-.5,5) arc (180:360:5mm and 2mm);
    \foreach \y[count=\n, evaluate=\n as \m using int(50*\n), evaluate=\y as \k using 18-\y^(3/2)/14] in {4,10,17,25}{
    \draw[white, thick, yshift=\y mm]([xscale=3]250:.333*\k mm) arc(250:280:\k mm and .333*\k mm)node[rotate=4, right]{\sffamily \m};}
\end{tikzpicture}}

\newcommand{\scaleflask}[1][1]{\vcenter{\hbox{\scalebox{#1}{\flask}}}}
\newcommand{\Molar}{\textup{ Molar}}

\begin{document}

\[
\scaleflask[.3]\xleftarrow{\textstyle1.0\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.5\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.25\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.13\Molar}
\scaleflask[.3]\xleftarrow{\textstyle0.06\Molar}
\]

\end{document}

información relacionada