5

This question continues my another.

My code:

\documentclass{scrartcl}
\usepackage{tikz}

\usetikzlibrary{positioning}
\tikzset{
         signal/.style = coordinate,
         non linear block/.style = {
                                    draw,
                                    rectangle,
                                    minimum height = 2em,
                                    minimum width = 4em,
                                    path picture = {
                                                    \draw
                                                      (path picture bounding box.south west) rectangle (path picture bounding box.north east);
                                                   }
                                   }
        }

\begin{document}

  \begin{tikzpicture}
  \node[signal] (input) {};
  \node[
        non linear block,
        right = of input
       ] (inverse) {$\sqrt{\phantom{u}}$};
  \node[
        signal,
        right = of inverse
       ] (output) {};
  \draw
    [->] (input) -- (inverse);
  \draw
    [->] (inverse) -- (output);
  \end{tikzpicture}

\end{document}

produces:

result

I wish:

wish

I must somehow modify this (path picture bounding box.south west) rectangle (path picture bounding box.north east) line. What I have to do to achieve the request. Also complete another solutions are welcome, but I have to stay by signal and block syntax (needed for control system block diagrams).

Thank you for your effort in advance!

Su-47
  • 2,508

2 Answers2

4

Indeed, you need to modify this line.

\documentclass{scrartcl}
\usepackage{tikz}

\usetikzlibrary{positioning}
\tikzset{
         signal/.style = coordinate,
         non linear block/.style = {
                                    draw,
                                    rectangle,
                                    minimum height = 2em,
                                    minimum width = 4em,
                                    path picture = {
                                                    \draw[double distance=2pt]
                                                      (path picture bounding box.south west) rectangle (path picture bounding box.north east);
                                                   }
                                   }
        }

\begin{document}

  \begin{tikzpicture}
  \node[signal] (input) {};
  \node[
        non linear block,
        right = of input
       ] (inverse) {$\sqrt{\phantom{u}}$};
  \node[
        signal,
        right = of inverse
       ] (output) {};
  \draw
    [->] (input) -- (inverse);
  \draw
    [->] (inverse) -- (output);
  \end{tikzpicture}

\end{document}

enter image description here

4

very simple, just add option double to your non linear block

\documentclass{scrartcl}
\usepackage{tikz}

\usetikzlibrary{positioning}
\tikzset{
         signal/.style = coordinate,
         non linear block/.style = {
                    draw,
                    double, % <--- added
                    rectangle,
                    double distance between line centers=0.5mm, % <--- added
                    minimum height = 2em,
                    minimum width = 4em,
                    outer sep=0.5mm, % <--- added
                    % path picture = { <--- superfluous 
                    %   \draw
                    %   (path picture bounding box.south west) rectangle (path picture bounding box.north east);
                    %               }
                                   }
        }

\begin{document}

  \begin{tikzpicture}
  \node[signal] (input) {};
  \node[
        non linear block,
        right = of input
       ] (inverse) {$\sqrt{\phantom{u}}$};
  \node[
        signal,
        right = of inverse
       ] (output) {};
  \draw
    [->] (input) -- (inverse);
  \draw
    [->] (inverse) -- (output);
  \end{tikzpicture}

\end{document}

enter image description here

Zarko
  • 296,517
  • What is better in your solution? That the arrow lines go slightly into the box? –  Mar 27 '18 at 23:34
  • @marmot, simplicity. on arrows i forgot, but now is corrected. – Zarko Mar 27 '18 at 23:42
  • 1
    Well, I wouldn't call this simpler. The OP @Su-47 will have to decide whether whenever (s)he wants to add an element to the scheme (s)he has to adjust all sorts of parameters. I think that the path picture is really much better in this case because it uses the bounding box and does not require additional adjustments. And it is straightforward to add other features. Finally, it would be nice if you could mention this post where the mess with double was discussed. –  Mar 27 '18 at 23:46
  • 2
    i disagree with you. from op question i didn't see any reason for additional adjustments of this node shapes. anyway, thank you very much to pointed me problem with arrows. – Zarko Mar 27 '18 at 23:53
  • Well, perhaps then we can agree to disagree? ;-) –  Mar 28 '18 at 00:44
  • Hello @Zarko! Thank you for your answer! This is much effort! For my actual purposes I don't need that much, but maybe somedays... – Su-47 Mar 28 '18 at 20:42
  • @Su-47, for some reason you select other answer. hopefully you will be happy with it. – Zarko Mar 28 '18 at 20:48
  • @Zarko. Sorry, your answer is good too, but I have to choose one answer. My choice is for those with minimal changes compared with my code. Maybe your answer is more professional. I haven't enough experience in LaTex to decide it. But like I said, for my actual purposes it is enough what marmot done. – Su-47 Mar 28 '18 at 21:03