3

The chemplants package offers tools to draw simple or barely complex schemes of chemical processes. Process units and styles for streams and utilities are defined to be a sort of extension of the TikZ package, thus a basic knowledge of the logic of this powerful tool is required to profitably use chemplants.

Since this package is based on TikZ, its options should be valid. But if I try to pass fill=gray!25 as a parameter, it doesn't work. Below is the MWE:

\documentclass[12pt]{article}
\usepackage{tikz}
\definecolor{viola}{HTML}{8100FF}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{chemplants}
\renewcommand{\dim}[1]{\left[\mathrm{#1}\right]}
\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}
        \pic[xscale = 1.50 ,yscale = 2.50, fill=gray!25] (R) at (0 ,0) { tank reactor };
                    
        \node[xshift=1cm,yshift=1cm] (topright) at (R-anchor) {};

        \pic (het) at (3,1) { heat exchanger };
        \draw[-stealth] (2.5,1) --++ (-1.3,0);      
        \draw[dotted] (-1.2,1.25) --++ (2.4,0);
        \draw[dotted] (-1.2,0.75) --++ (2.4,0);
        
        \pic (heb) at (3,-1) { heat exchanger };
        \draw[-stealth] (2.5,-1) --++ (-1.3,0);     
        \draw[dotted] (-1.2,-1.25) --++ (2.4,0);
        \draw[dotted] (-1.2,-0.75) --++ (2.4,0);
    \end{tikzpicture}
\end{figure}
\end{document}

Any ideas?

1
  • 1
    Please accept the answers you receive Sep 9 at 22:26

1 Answer 1

3

The majority of elements provided by the chemplants package is defined as \pic. You cannot style a \pic in the same way like a node, because a \pic is, so to say, a scoped mini tikzpicture.

(In fact, you can style a \pic like a node if it uses the key pic actions. But the \pics defined in this package don't use this key. Thanks to Qrrbrbirlbel for this annotation.)

However, after having looked into the scource code of the package, it seems that almost all the \pics defined in the package use a certain option, namely chpunitstyle, for the main \draw command of each \pic, which is used to set the line thickness and scaling.

For example the tank reactor is defined as follows:

\tikzset{tank reactor/.pic=%
    {%
    \draw [chpunitstyle]
        (-0.8,-0.732) to [out=270, in=270]
        (0.8,-0.732) --
        (0.8,0.732) to [out=90, in=90]
        (-0.8,0.732) -- cycle;
    \begin{scope} [scale=\chp@UnitScale]
        \coordinate (-anchor) at (0,0);
        \coordinate (-left) at (-0.8,0);
        \coordinate (-bottom left) at (-0.8,-0.732);
        \coordinate (-bottom) at (0,-1.2);
        \coordinate (-bottom right) at (0.8,-0.732);
        \coordinate (-right) at (0.8,0);
        \coordinate (-top right) at (0.8,0.732);
        \coordinate (-top) at (0,1.2);
        \coordinate (-top left) at (-0.8,0.732);
    \end{scope}
    }%
}

You can therefore append custom styles to this option using, for example, chpunitstyle/.append style={fill=gray!25}. Of course, using this trick, you would only be able to style the element with this key. To style more complex \pics, this approach might not work.

\documentclass[border=10pt]{standalone}
\usepackage{chemplants}

\begin{document}
    \begin{tikzpicture}
        \pic[xscale = 1.50, yscale = 2.50, chpunitstyle/.append style={fill=gray!25}] (R) at (0,0) { tank reactor };
                    
        \node[xshift=1cm, yshift=1cm] (topright) at (R-anchor) {};

        \pic (het) at (3,1) { heat exchanger };
        \draw[-stealth] (2.5,1) -- ++(-1.3,0);      
        \draw[dotted] (-1.2,1.25) -- ++(2.4,0);
        \draw[dotted] (-1.2,0.75) -- ++(2.4,0);
        
        \pic (heb) at (3,-1) { heat exchanger };
        \draw[-stealth] (2.5,-1) -- ++(-1.3,0);     
        \draw[dotted] (-1.2,-1.25) -- ++(2.4,0);
        \draw[dotted] (-1.2,-0.75) -- ++(2.4,0);
    \end{tikzpicture}
\end{document}

enter image description here

1
  • 2
    "You cannot style a \pic in the same way like a node …" One could if the pic definition would contain pic actions (e.g. \draw[chpunitstyle, pic actions]). :( Aug 16 at 17:28

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.