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!

| improve this question | | | | |
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

| improve this answer | | | | |
  • Hello @marmot! Thank you for your answer! That's an easy one! – Su-47 Mar 28 '18 at 20:42
5

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

| improve this answer | | | | |
  • What is better in your solution? That the arrow lines go slightly into the box? – user121799 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. – user121799 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? ;-) – user121799 Mar 28 '18 at 0:44

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.