0

I've created a graph with TikZ. The problem is that the arrows do not have the same length, so the whole graph is asymmetric. Is there a way to correct that?

\documentclass{article}
\usepackage\[utf8\]{inputenc}
\usepackage{adjustbox}
\usepackage{tikz}
\begin{document}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{amsthm}
\usepackage\[svgnames\]{xcolor}
\usepackage{soul}
\usenavigationsymbolstemplate{}
\newcommand{\mathcolorbox}\[2\]{\colorbox{#1}{$\displaystyle #2$}}
\usepackage{amsmath}
\usepackage{bbm}
\usepackage{attrib} %use for quotes
\usepackage\[utf8x\]{inputenc}
\usepackage{lmodern,textcomp} %use for euro sign.
\usepackage{threeparttable}
\usepackage{siunitx} %align columns in reg table
\usepackage\[justification=centering\]{caption}
\usepackage{lmodern,textcomp} 
\usepackage{mathtools}%Euro sig
\usepackage\[backposition=title\]{beamerappendixnote}
\usepackage{comment}
\usepackage{subfig}
\usepackage{physics}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{mathdots}
\usepackage{yhmath}
\usepackage{cancel}
\usepackage{color}
\usepackage{siunitx}
\usepackage{array}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{gensymb}
\usepackage{tabularx}
\usepackage{extarrows}
\usepackage{booktabs}
\usetikzlibrary{fadings}
\usetikzlibrary{patterns}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes}
\usepackage{graphicx}
\usepackage{xcolor}
\usetikzlibrary{arrows.meta,
                calc,
                positioning,
                quotes,
                shapes}
\usepackage{changepage}



\bigskip
\bigskip
\bigskip
\bigskip
\bigskip



\begin{frame}
    \begin{itemize}


    \begin{tikzpicture}\[%x=0.5pt,y=0.5pt,%yscale=-1,
node distance = 2mm and 6mm,
  base/.style = {draw=blue, semithick, minimum width=3.3em, minimum height=3ex,
                 inner ysep=2mm, outer sep=1pt,   
                 execute at end node=\vphantom{g}
                 },  
   box/.style = {base, rounded corners},
    io/.style = {base, inner xsep=-2pt,
                 signal, signal to=west and east,
                 draw, semithick, minimum width=3em},
every edge/.style = {draw, -{Straight Barb\[scale=0.8\]}},
every edge quotes/.style = {auto,font=\footnotesize\linespread{0.84}\selectfont,
                            inner sep=2pt, align=center}
                        \]
%% nodes  
\node (n1) \[box\] {Politische Stimmung};
\node (n2)  \[box, below left=30mm of n1\]    {Ökonomische Lage};
\node (n3)  \[box, below=50mm of n1\]      {Wählerinnen};
\node (n4)  \[box,below right=30mm of n1\]             {Umfragewerte};

%% arrows 
\path   (n1.south)  edge \[sloped,anchor=center,"polit. Instrumente" 
                  \]    (n2.north)
        (n2.south)  edge \[sloped,anchor=center,"Indikatoren" 
                  \]    (n3.north)
        (n3.north)  edge \["Indiv. Wahlneigung",
                  sloped,anchor=center\]    (n4.south)
        (n4.north)  edge \["Reaktion der Parteien",
                  sloped,anchor=center
                  \]    (n1.south)
    \end{tikzpicture}
    
\end{itemize}

\end{frame}
    
    
\end{document}

enter image description here

3
  • 1
    The left and the right boxes are not the same size. Your arrows point to the middle of these boxes sides, hence the difference. You can adjust it manually by changing the destination position: path (n1.south) edge (n2.60) for example. .north meaning .90 for 90 degrees.
    – SebGlav
    Jun 16 at 11:46
  • 2
    Your code example does not compile and is certainly not minimal. Please try to make it an MWE by fixing errors and removing all unused packages.
    – schtandard
    Jun 16 at 11:59
  • 2 suggestions: 1) use \usetikzlibrary{positioning} (see pgf manual for details) and rewrite your positions, like [below=of NODEname] / 2) use option [minimum width=...] with your nodes and select a value which is large enough for all 4
    – MS-SPO
    Jun 16 at 12:11

1 Answer 1

2
  • For sure showed image is not produced by provided code!
  • Provided code is total mess with errors almost in each code line.
  • Also image code, copied from somewhere (it is quite familiar to me), is destroyed.
  • For your problem the MWE (which consider @SebGlav comment) can be:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                fadings,
                patterns, positioning, 
                quotes,
                shadows.blur, shapes}

\begin{document}

    \begin{tikzpicture}[
node distance = 17mm and 13mm,  % <--- changed
  base/.style = {draw=blue, semithick, minimum width=3.3em, minimum height=3ex,
                 inner ysep=2mm, outer sep=1pt,
                 text width=9em, align=center,  % <--- new
                 execute at end node=\vphantom{g}
                 },
   box/.style = {base, rounded corners},
    io/.style = {base, inner xsep=-2pt,
                 signal, signal to=west and east,
                 draw, semithick, minimum width=3em},
every edge/.style = {draw, -{Straight Barb[scale=0.8]}},
every edge quotes/.style = {auto,font=\footnotesize\linespread{0.84}\selectfont,
                            inner sep=2pt, align=center, sloped}
                        ]
%% nodes
\node (n1)  [box]                       {Politische Stimmung};
\node (n2)  [box, below  left=of n1]    {Ökonomische Lage};
\node (n3)  [box, below right=of n2]    {Wählerinnen};
\node (n4)  [box, below right=of n1]    {Umfragewerte};
%% arrows
\path   (n1.260)    edge ["polit. Instrumente"]     (n2.north)
        (n2.south)  edge ["Indikatoren"]            (n3.100)
        (n3.80)     edge ["Indiv. Wahlneigung"]     (n4.south)
        (n4.north)  edge ["Reaktion der Parteien"]  (n1.280);
    \end{tikzpicture}
\end{document}

enter image description here

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.