3

Am using the amazing TikZ software to draw figures for a book chapter. Am very pleased with the quality of the figures I've been able to create. Unfortunately, I've gotten a bit stuck with just one thing. The code below illustrates the part of the figure I'm struggling with.

The drawing is essentially correct. Trouble is the double-headed arrows look terrible. The ends of the arrows don't point to r1j and r3j the way they should and the arrow heads at the top and the bottom are superimposed on one another when there really ought to be some separation between them. Was hoping someone could show me how to change this so it looks better. Occurs to me it might be necessary to increase the vertical space between r1j, r2j, r3j, for the arrows to look right. If so, then I think it probably makes sense to do that.

\documentclass[10pt]{article}

%%%% Packages %%%%

\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric}
\usepackage{hyperref}

%%%% Set pdf zoom to 100% %%%%

\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}

%%%% TikZ graphics styles/commands %%%%

\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]

\begin{document}

\newcommand{\rlist}{
\left\{
\begin{array}{cl}
r_{1j} \\ 
r_{2j} \\ 
r_{3j}
\end{array}
\right.
}

\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[auto]

\node[rect]                     (Yij)            at (26, 0) {$LifeSat_{ij}$};
\node[input]                    (rij)            at (28.5, 0) {$r_{ij} \rlist$};

\draw [arr] (rij)                                to (Yij);
\draw [doublearr, bend left]    (rij.north east) to (rij.south east);
\draw [doublearr, bend left]    (rij.north east) to (rij.east);
\draw [doublearr, bend left]    (rij.east)       to (rij.south east);

\end{tikzpicture}
\end{center}
\end{figure}

\end{document}
5

Use [xshift=...mm] or [yshift=...mm] for node.

\documentclass[10pt]{article}

%%%% Packages %%%%

\usepackage{here}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,shapes.geometric}
\usepackage{hyperref}

%%%% Set pdf zoom to 100% %%%%

\hypersetup{pdfstartview={XYZ null null 1.00}, pdfview={XYZ null null 1.00}}

%%%% TikZ graphics styles/commands %%%%

\tikzstyle{arr}=[-latex, black, line width=0.5pt]
\tikzstyle{doublearr}=[latex-latex, black, line width=0.5pt]
\tikzstyle{input}=[font=\small\sffamily\bfseries]
\tikzstyle{rect}=[rectangle, draw=black, font=\small\sffamily\bfseries, inner sep=9pt]

\begin{document}

\newcommand{\rlist}{
\left\{
\begin{array}{cl}
r_{1j} \\ 
r_{2j} \\ 
r_{3j}
\end{array}
\right.
}

\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[auto]

\node[rect]                    (Yij)            at (26, 0) {$LifeSat_{ij}$};
\node[input]                   (rij)            at (28.5, 0) {$r_{ij} \rlist$};

\draw [arr] (rij)                                to (Yij);
\draw [doublearr, bend left]    ([xshift=2mm]rij.north east) to ([xshift=2mm]rij.south east);
\draw [doublearr, bend left]    (rij.north east) to (rij.east);
\draw [doublearr, bend left]    (rij.east)       to (rij.south east);

\end{tikzpicture}
\end{center}
\end{figure}

\end{document}

enter image description here

  • 1
    It is always better to make the code complete for us from the OP, and for OP from us. – percusse Mar 11 '14 at 13:26
  • Using xshift and yshift, I was able to get exactly what I needed. Thank you very much for your help. – Paul Miller Mar 11 '14 at 13:35
  • You could use \centering command (between \begin{figure} and \begin{tikzpicture}) instead center environment. – juanuni Jul 20 '15 at 18:22

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.