I have no time to do all of them. Here are some examples. (forget \newcommand
)
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\makeatletter
\pgfdeclareshape{slits}{
\savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
\saveddimen\halfwidth{
\pgf@x=.25cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\saveddimen\halfheight{
\pgf@x=.25cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\anchor{center}\centerpoint
\anchor{north}{
\pgf@process\halfheight
\pgf@x=0cm
\pgf@y=.2cm\advance\pgf@y by\halfheight}
\anchorborder{\centerpoint}
\backgroundpath{
\draw[rounded corners=.1cm](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
\draw[rounded corners=.04cm](-.8*\halfwidth,-.4*\halfheight)rectangle(.8*\halfwidth,-.8*\halfheight)(-.8*\halfwidth,.4*\halfheight)rectangle(.8*\halfwidth,.8*\halfheight);}}
\pgfdeclareshape{steerer}{
\savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
\saveddimen\halfwidth{
\pgf@x=.25cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\saveddimen\halfheight{
\pgf@x=.25cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\anchor{center}\centerpoint
\anchor{north}{
\pgf@process\halfheight
\pgf@x=0cm
\pgf@y=.2cm\advance\pgf@y by\halfheight}
\anchorborder{\centerpoint}
\backgroundpath{
\draw[rounded corners=.1cm](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
\filldraw[rounded corners=.04cm,fill=red](-.8*\halfwidth,-.4*\halfheight)rectangle(.8*\halfwidth,-.8*\halfheight)(-.8*\halfwidth,-.2*\halfheight)rectangle(.8*\halfwidth,.2*\halfheight)(-.8*\halfwidth,.4*\halfheight)rectangle(.8*\halfwidth,.8*\halfheight);}}
\pgfdeclareshape{lens}{
\savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
\saveddimen\halfwidth{
\pgf@x=.05cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\saveddimen\halfheight{
\pgf@x=.3cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\anchor{center}\centerpoint
\anchor{south}{
\pgf@process\halfheight
\pgf@x=0cm
\pgfmathsetlength\pgf@y{-1.2*\halfheight-.2cm}}
\anchorborder{\centerpoint}
\backgroundpath{
\draw(0,-1.2*\halfheight)--(0,-\halfheight)(0,\halfheight)--(0,1.2*\halfheight)(-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);}}
\pgfdeclareshape{lollipop}{
\savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
\saveddimen\halfwidth{
\pgf@x=.1cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\saveddimen\halfheight{
\pgf@x=.3cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\anchor{center}\centerpoint
\anchor{south}{
\pgf@process\halfheight
\pgf@process\halfwidth
\pgf@x=0cm
\pgfmathsetlength\pgf@y{-\halfheight-\halfwidth-.2cm}}
\anchorborder{\centerpoint}
\backgroundpath{
\draw[ultra thick](0,0)--(0,-\halfheight);
\filldraw[fill=white](0,-\halfheight)circle(\halfwidth);}}
\pgfdeclareshape{皿}{
\savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
\saveddimen\halfwidth{
\pgf@x=1cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\saveddimen\halfheight{
\pgf@x=.3cm
\pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
\ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
\anchor{center}\centerpoint
\anchor{north}{
\pgf@process\halfheight
\pgf@x=0cm
\pgf@y=.2cm\advance\pgf@y by\halfheight}
\anchor{south}{
\pgf@process\halfheight
\pgf@x=0cm
\pgf@y=-.2cm\advance\pgf@y by-\halfheight}
\backgroundpath{
\draw(-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight)(-.8*\halfwidth,-1.2*\halfheight)--(-.8*\halfwidth,1.2*\halfheight)(-.4*\halfwidth,-1.2*\halfheight)--(-.4*\halfwidth,1.2*\halfheight)(0,-1.2*\halfheight)--(0,1.2*\halfheight)(.4*\halfwidth,-1.2*\halfheight)--(.4*\halfwidth,1.2*\halfheight)(.8*\halfwidth,-1.2*\halfheight)--(.8*\halfwidth,1.2*\halfheight);}}
\begin{tikzpicture}
\node(sl1)at(2,2)[slits]{};
\node(st1)at(3,2)[steerer]{};
\node(le1)at(5,2)[lens]{};
\node(lo1)at(6,2)[lollipop]{};
\node(皿1)at(4,0)[皿]{};
\draw(sl1.north)node{$6$};
\draw(st1.north)node{$10$};
\draw(le1.south)node{$5$};
\draw(lo1.south)node{$8$};
\draw(皿1.north)node{$2$};
\draw(皿1.south)node{$3$};
\end{tikzpicture}
\end{document}
I approve of your decision not to use TikZ. You can create various shapes by low level PDF commands, as is used in my code here. We define \sqbox
for square, \trianbox
for triangle, \uptrianbox
for rotated triangle, \circbox
for circle and \diabox
for diamonds. All these macros have two parameters: first one is 0
if we need outlined shape or 1
if we need solid shape. Second one is the color defined by \def\nameCOLOR
.
\def\sqPDF#1#2{0 0 m #1 0 l #1 #1 l 0 #1 l h}
\def\trianPDF#1#2{0 0 m #1 0 l #2 4.5 l h}
\def\uptrianPDF#1#2{#2 0 m #1 4.5 l 0 4.5 l h}
\def\circPDF#1#2{#1 0 0 #1 #2 #2 cm .1 w .5 0 m
.5 .276 .276 .5 0 .5 c -.276 .5 -.5 .276 -.5 0 c
-.5 -.276 -.276 -.5 0 -.5 c .276 -.5 .5 -.276 .5 0 c h}
\def\diaPDF#1#2{#2 0 m #1 #2 l #2 #1 l 0 #2 l h}
\def\credCOLOR {.54 .14 0}
\def\cblueCOLOR {.06 .3 .54}
\def\cgreenCOLOR {0 .54 0}
\def\genbox#1#2#3#4#5#6{% #1=0/1, #2=color, #3=shape, #4=raise, #5=width, #6=width/2
\leavevmode\raise#4bp\hbox to#5bp{\vrule height#5bp depth0bp width0bp
\pdfliteral{q .5 w \csname #2COLOR\endcsname\space RG
\csname #3PDF\endcsname{#5}{#6} S Q
\ifx1#1 q \csname #2COLOR\endcsname\space rg
\csname #3PDF\endcsname{#5}{#6} f Q\fi}\hss}}
% shape raise width width/2
\def\sqbox #1#2{\genbox{#1}{#2} {sq} {0} {4.5} {2.25}}
\def\trianbox #1#2{\genbox{#1}{#2} {trian} {0} {5} {2.5}}
\def\uptrianbox #1#2{\genbox{#1}{#2} {uptrian} {0} {5} {2.5}}
\def\circbox #1#2{\genbox{#1}{#2} {circ} {0} {5} {2.5}}
\def\diabox #1#2{\genbox{#1}{#2} {dia} {-.5} {6} {3}}
%% usage:
squares: \sqbox0{cgreen}, \sqbox1{cred}, \sqbox0{cblue}.
triangles: \trianbox0{cgreen}, \trianbox1{cred}, \trianbox0{cblue}.
triangles: \uptrianbox0{cgreen}, \uptrianbox1{cred}, \uptrianbox0{cblue}.
circles: \circbox0{cgreen}, \circbox1{cred}, \circbox0{cblue}.
diamonds: \diabox0{cgreen}, \diabox1{cred}, \diabox0{cblue}.
The result:
You need not any package for this. Nor xcolor
. All stuff is done at PDF low level commands. If you are using XeTeX (no pdfTeX) then you need to define \pdfliteral
by:
\def\pdfliteral#1{\special{pdf:literal #1}}
I tried this in plain TeX but I hope that the code will work in LaTeX too (after adding \documentclass
etc. sequences).
Best Answer
I wrote a package to produce process flow diagram with TikZ. These are slightly less complex than P&IDs, but you can work it out something useful anyway. At least, the package defines a certain variety of symbols commonly used in chemical process diagrams. You may want to have a look to the chemplants package, available on CTAN at https://ctan.org/pkg/chemplants