3

This is my code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{steinmetz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows,calc,positioning,chains,arrows.meta,patterns}
\tikzset{
%   pinstyle/.style={pin edge={to-,thin,black}}, % you have another one below
block/.style = {draw, rectangle,
   minimum height=1cm,
   align = center
%   minimum width=2cm
},
input/.style = {coordinate,node distance=1cm},
output/.style = {coordinate,node distance=1cm},
arrow/.style={draw, -latex,node distance=2cm},
pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
sum/.style = {draw, circle, node distance=1cm},
gain/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=-90
},
gain_feedback/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=90
},
dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}
}

\begin{document}
\begin{tikzpicture}[auto,>=latex',every node/.append style={font=\scriptsize}]

    %DEFINIZIONE BLOCCHI
    \node [input, name=input] {};
    \node [block, right=of input] (controllo) {CONTROLLO};
    \node [block,above right=0.5cm of controllo] (catena_aperta) {CATENA APERTA};
    \node [block, below right=0.5cm of controllo] (catena_chiusa) {CATENA CHIUSA};
    \node [block, above right=0.5cm of catena_chiusa] (cella_di_carico) {CELLA \\DI CARICO};
    \node [block,below right=0.5cm of catena_chiusa] (encoder) {ENCODER};
    \node [block, above right=0.5cm of encoder] (ballerino_attivo) {BALLERINO\\ATTIVO};
    \node [block, below right=0.5cm of encoder] (ballerino_passivo) {BALLERINO\\PASSIVO};
    \node [output, right=of encoder] () {};

    %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
    \draw [->] (controllo.east) -- (catena_aperta.west);
    \draw [->] (controllo.east) -- (catena_chiusa.west);
    \draw [->] (catena_chiusa.east) -- (cella_di_carico.west);
    \draw [->] (catena_chiusa.east) -- (encoder.west);
    \draw [->] (encoder.east) -- (ballerino_attivo.west);
    \draw [->] (encoder.east) -- (ballerino_passivo.west) ;

\end{tikzpicture}
\end{document}

I get this picture:

enter image description here

I would like to expand it in the horizontal direction and compress it in the vertical direction.

4
  • Hi ! Could you be more explicit about what you want (maybe a picture) ? Maybe you could take a look on the chains (§46) or tree (§ 29.1) function of tikz.
    – flav
    Sep 5, 2017 at 6:53
  • I would like to have a picture with a larger x dimension and a smaller y dimension. I can't be more explicit with a picture since i create this on my own and there are no copy out there
    – it8
    Sep 5, 2017 at 6:57
  • 2
    While I do enjoy the additional reputation, you should not accept my answer just now. There most likely is a better way of doing this setting up a custom style or what ever. You should wait a bit before accepting any answer to possibly get better answers.
    – Skillmon
    Sep 5, 2017 at 7:18
  • Ok, anyway the solution fits my needs ;) Thank you!
    – it8
    Sep 5, 2017 at 8:04

4 Answers 4

1

with forest the code is very simple:

\documentclass{article}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

\begin{document}
\centering
    \begin{forest}
for tree={
  grow=east,
% common style of nodes
  rectangle,
  draw,
  align=center,
% common style of edges
  parent anchor=east,
  child anchor=west,
  edge={semithick,-Straight Barb},
% distances of nodes
  l sep+=6mm,           % <-- *l*: level distance
  s sep+=2mm,           % <-- *s*: sibling distance between leaves
        }
[CONTROLLO
    [CATENA\\ CHIUSA
        [ENCODER
            [BALLERINO\\ ATTIVO]
            [BALLERINO\\ PASSIVO]
        ]
        [CELLA\\ DI CARICO]
    ]
    [CATENA\\ APERTA]
]
    \end{forest}
\end{document}

enter image description here

3

I would remove all the 0.5cm from the positioning options, i.e. have just above right=of somenode, and then set node distance=-3mm and 13mm in the tikzpicture options. The first is the vertical distance, the second is horizontal. Adjust those lengths to your need.

output of code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{steinmetz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows,calc,positioning,chains,arrows.meta,patterns}
\tikzset{
%   pinstyle/.style={pin edge={to-,thin,black}}, % you have another one below
block/.style = {draw, rectangle,
   minimum height=1cm,
   align = center
%   minimum width=2cm
},
input/.style = {coordinate,node distance=1cm},
output/.style = {coordinate,node distance=1cm},
arrow/.style={draw, -latex,node distance=2cm},
pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
sum/.style = {draw, circle, node distance=1cm},
gain/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=-90
},
gain_feedback/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=90
},
dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}
}

\begin{document}
\begin{tikzpicture}[
    auto,>=latex',
    every node/.append style={font=\scriptsize},
    node distance=+3mm and 13mm % added
]

    %DEFINIZIONE BLOCCHI
    \node [input, name=input] {};
    \node [block, right=of input] (controllo) {CONTROLLO};
    \node [block,above right=of controllo] (catena_aperta) {CATENA APERTA};
    \node [block, below right=of controllo] (catena_chiusa) {CATENA CHIUSA};
    \node [block, above right=of catena_chiusa] (cella_di_carico) {CELLA \\DI CARICO};
    \node [block,below right=of catena_chiusa] (encoder) {ENCODER};
    \node [block, above right=of encoder] (ballerino_attivo) {BALLERINO\\ATTIVO};
    \node [block, below right=of encoder] (ballerino_passivo) {BALLERINO\\PASSIVO};
    \node [output, right=of encoder] () {};

    %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
    \draw [->] (controllo.east) -- (catena_aperta.west);
    \draw [->] (controllo.east) -- (catena_chiusa.west);
    \draw [->] (catena_chiusa.east) -- (cella_di_carico.west);
    \draw [->] (catena_chiusa.east) -- (encoder.west);
    \draw [->] (encoder.east) -- (ballerino_attivo.west);
    \draw [->] (encoder.east) -- (ballerino_passivo.west) ;

\end{tikzpicture}
\end{document}
2

The following solves this mostly manually, but gives a vertically more condensed and horizontal stretched output:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{steinmetz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows,calc,positioning,chains,arrows.meta,patterns}
\tikzset{
%   pinstyle/.style={pin edge={to-,thin,black}}, % you have another one below
block/.style = {draw, rectangle,
   minimum height=1cm,
   align = center
%   minimum width=2cm
},
input/.style = {coordinate,node distance=1cm},
output/.style = {coordinate,node distance=1cm},
arrow/.style={draw, -latex,node distance=2cm},
pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
sum/.style = {draw, circle, node distance=1cm},
gain/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=-90
},
gain_feedback/.style = {
 regular polygon, regular polygon sides=3,
 draw, fill=white, text width=1em,
 inner sep=0mm, outer sep=0mm,
 shape border rotate=90
},
dot/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}
}

\begin{document}
\begin{tikzpicture}[auto,>=latex',every node/.append style={font=\scriptsize}]

    %DEFINIZIONE BLOCCHI
    \node [input, name=input] {};
    \node [block, right=of input] (controllo) {CONTROLLO};
    \node [block] at($(controllo.north east)+(2,0.25)$) (catena_aperta) {CATENA APERTA};
    \node [block] at($(controllo.south east)+(2,-.25)$) (catena_chiusa) {CATENA CHIUSA};
    \node [block] at($(catena_chiusa.north east)+(2,0.25)$) (cella_di_carico) {CELLA \\DI CARICO};
    \node [block] at($(catena_chiusa.south east)+(2,-.25)$) (encoder) {ENCODER};
    \node [block] at($(encoder.north east)+(2,0.25)$) (ballerino_attivo) {BALLERINO\\ATTIVO};
    \node [block] at($(encoder.south east)+(2,-.25)$) (ballerino_passivo) {BALLERINO\\PASSIVO};
    \node [output, right=of encoder] () {};

    %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
    \draw [->] (controllo.east) -- (catena_aperta.west);
    \draw [->] (controllo.east) -- (catena_chiusa.west);
    \draw [->] (catena_chiusa.east) -- (cella_di_carico.west);
    \draw [->] (catena_chiusa.east) -- (encoder.west);
    \draw [->] (encoder.east) -- (ballerino_attivo.west);
    \draw [->] (encoder.east) -- (ballerino_passivo.west) ;

\end{tikzpicture}
\end{document}

enter image description here

1

I'd suggest using a tikz matrix:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,matrix}
\tikzset{%
    font=\tiny,
    block/.style = {draw, rectangle,
        minimum height=1.1cm,
        align = center,
        text width=1.6cm,
    },
    ->/.style={-Stealth},
}

\begin{document}
\begin{center}
    \begin{tikzpicture}
        \matrix[matrix of nodes, nodes={block},
            row sep=-3ex, column sep=4em] {
            % DEFINIZIONE BLOCCHI
            & |[name=catena_aperta]| CATENA APERTA \\
            |[name=controllo]| CONTROLLO & & |[name=cella_di_carico]| {CELLA \\DI CARICO} \\
            & |[name=catena_chiusa]| CATENA CHIUSA & &
            |[name=ballerino_attivo]| {BALLERINO\\ATTIVO} \\
            && |[name=encoder]| ENCODER \\  
            &&& |[name=ballerino_passivo]| {BALLERINO\\PASSIVO} \\
        };
        % DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
        \draw [->] (controllo.east) -- (catena_aperta.west);
        \draw [->] (controllo.east) -- (catena_chiusa.west);
        \draw [->] (catena_chiusa.east) -- (cella_di_carico.west);
        \draw [->] (catena_chiusa.east) -- (encoder.west);
        \draw [->] (encoder.east) -- (ballerino_attivo.west);
        \draw [->] (encoder.east) -- (ballerino_passivo.west);
    \end{tikzpicture}
\end{center}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .