Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to use xshift and a variable to place several (different) paths with variable equidistance. I want to configure the space between the paths so giving a variable e.g. to xshift in scope would do the trick. Unfortunately I cannot use foreach since the paths are different.

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning}

\begin{document}

\usetikzlibrary{calc}

\begin{tikzpicture}%[node distance =4.5cm,thick]

\newcommand{\room} {
 \coordinate (a) at  (0,0) ;
 \coordinate (b) at (5,0);
 \coordinate (c) at  (5,5);
 \coordinate (d) at (0,4);
 \coordinate (e) at (1,3);
 \coordinate (f) at     (1.4,3) ;
 \coordinate (g) at (1.4,2.6)   ;
 \coordinate (h) at (1,2.6) ;
 \coordinate (i) at (1,3)   ;
}


\begin{scope}[xshift=0cm,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f);
\end{scope}

\begin{scope}[xshift=6cm,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f) --(g) --(h);
\end{scope}


\begin{scope}[xshift=12cm,yshift=-7cm]  
    \room;
    \draw[densely dotted,very thick] (d)--(e)--(f) --(g) --(h)--(e);
    \draw[dashed,thick] (b)--(c)--(d);
\end{scope}

\end{tikzpicture}
\end{document}

Edit: Added Eaxmple

share|improve this question
1  
Welcome to TeX.sx! Please add a minimal working example (MWE) (or at least an image) that illustrates your problem. –  Tobi May 4 '12 at 14:47
add comment

1 Answer

up vote 1 down vote accepted

I'm not sure of having understood well what you are asking for, but you can define an initial lenght and then use this.

For example, I reproduced your picture three times, with the same code, by changing this length:

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning,calc}

\newlength\mydistance % definition
\setlength{\mydistance}{5cm} % first setting

\newcommand{\room} {
 \coordinate (a) at  (0,0) ;
 \coordinate (b) at (5,0);
 \coordinate (c) at  (5,5);
 \coordinate (d) at (0,4);
 \coordinate (e) at (1,3);
 \coordinate (f) at     (1.4,3) ;
 \coordinate (g) at (1.4,2.6)   ;
 \coordinate (h) at (1,2.6) ;
 \coordinate (i) at (1,3)   ;
}

\begin{document}
\begin{tikzpicture}[scale=0.75]
\begin{scope}[xshift=0cm,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f);
\end{scope}

\begin{scope}[xshift=\mydistance,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f) --(g) --(h);
\end{scope}


\begin{scope}[xshift=2\mydistance,yshift=-7cm]  
    \room;
    \draw[densely dotted,very thick,] (d)--(e)--(f) --(g) --(h)--(e);
    \draw[dashed,thick] (b)--(c)--(d);
\end{scope}
\end{tikzpicture}

\vspace*{2cm}
\setlength{\mydistance}{5.5cm} % re-set the distance

\begin{tikzpicture}[scale=0.75]
\begin{scope}[xshift=0cm,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f);
\end{scope}

\begin{scope}[xshift=\mydistance,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f) --(g) --(h);
\end{scope}


\begin{scope}[xshift=2\mydistance,yshift=-7cm]  
    \room;
    \draw[densely dotted,very thick,] (d)--(e)--(f) --(g) --(h)--(e);
    \draw[dashed,thick] (b)--(c)--(d);
\end{scope}
\end{tikzpicture}

\vspace*{2cm}
\setlength{\mydistance}{7cm} % changed again the distance

\begin{tikzpicture}[scale=0.75]
\begin{scope}[xshift=0cm,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f);
\end{scope}

\begin{scope}[xshift=\mydistance,yshift=-7cm]
    \room;
    \draw[dashed,thick] (b)--(c)--(d)--(e)--(f) --(g) --(h);
\end{scope}


\begin{scope}[xshift=2\mydistance,yshift=-7cm]  
    \room;
    \draw[densely dotted,very thick,] (d)--(e)--(f) --(g) --(h)--(e);
    \draw[dashed,thick] (b)--(c)--(d);
\end{scope}
\end{tikzpicture}
\end{document}

gives you:

enter image description here

share|improve this answer
    
Thanks! That was exactly what I was looking for but I did not find it in the pgfmanual. –  Martin May 4 '12 at 16:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.