\documentclass{article}
\usepackage{tikz,amssymb,amsmath}
\usetikzlibrary{patterns}

\usepackage{xepersian}


\def\ba{\backslash}
\begin{document}
رسم خطوط راست و شکسته:  مختصات نقاطی که خط از آنها عبور می‌کند  به شکل زیر داده می‌شود.
\begin{flushleft}
$\backslash draw\ (x_0,y_0)\ --\ (x_1,y_1)\ \cdots\ --\ (x_n,y_n);$
\end{flushleft}
پارامتر‌های 
\lr{line width=dim}
 و 
 \lr{draw=color}
  برای تغییر ضخامت و رنگ خط بکار می‌رود. در خطوط شکسته می‌توان با استفاده از پارامتر
 \lr{rounded corners=dim}
 گوشه‌های تیز را از بین برد.  آپشن‌های دیگری مانند 
 \lr{dashed}
  و
 \lr{dotted}
 نیز برای ترسیم خط‌چین و نقطه‌چین بکار می‌رود.
 \\
 مثال
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw (0,0) -- (1,.5);
\draw  [line width=5pt,draw=red](1.2,0) -- (2,1) -- (3,.5);
\draw[->,rounded corners=6pt,line width=2pt,blue]%
 (4,1) -- (5,0) -- (5.5,.7) -- (7,0);
\draw[line width=2pt,dashed] (8,0) -- (9,1) -- (10,.5) -- (8,0);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\draw (0,0) -- (1,.5);
\draw  [line width=5pt,draw=red](1.2,0) -- (2,1) -- (3,.5);
\draw[->,rounded corners=6pt,line width=2pt,blue] (4,1) -- (5,0) -- (5.5,.7) -- (7,0);
\draw[line width=2pt,dashed] (8,0) -- (9,1) -- (10,.5) -- (8,0);
\end{tikzpicture}
نام برخی از رنگهای پیش فرض عبارتند از:
\begin{latin}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
red  & green  & blue &cyan  &magenta  &yellow  &black  &gray  \\ 
\hline 
\tikz \draw [red, line width=6]
(0,0) -- (.5,0); &
\tikz \draw [green, line width=6]
(0,0) -- (.5,0);  &
\tikz \draw [blue, line width=6]
(0,0) -- (.5,0);  & 
\tikz \draw [cyan, line width=6]
(0,0) -- (.5,0); &
\tikz \draw [magenta, line width=6]
(0,0) -- (.5,0);  &
\tikz \draw [yellow, line width=6]
(0,0) -- (.5,0);  &  
\tikz \draw [black, line width=6]
(0,0) -- (.5,0);& 
\tikz \draw [gray, line width=6]
(0,0) -- (.5,0); \\ 
\hline 
darkgray  & lightgray & brown &lime  &olive  &orange  &pink  &purpla  \\ 
\hline 
\tikz \draw [darkgray, line width=6]
(0,0) -- (.5,0); &
\tikz \draw [lightgray, line width=6]
(0,0) -- (.5,0);  &
\tikz \draw [brown, line width=6]
(0,0) -- (.5,0);  & 
\tikz \draw [lime, line width=6]
(0,0) -- (.5,0); &
\tikz \draw [olive, line width=6]
(0,0) -- (.5,0);  &
\tikz \draw [orange, line width=6]
(0,0) -- (.5,0);  &  
\tikz \draw [pink, line width=6]
(0,0) -- (.5,0);& 
\tikz \draw [purple, line width=6]
(0,0) -- (.5,0); \\ \hline
teal  & violet & white &  &  &  &  &  \\ 
\hline 
\tikz \draw [teal, line width=6]
(0,0) -- (.5,0); &
\tikz \draw [violet, line width=6]
(0,0) -- (.5,0);  &
\tikz \draw [fill=white]
(0,0) rectangle (.5,.2);  & 
 &  &  &  & 
 \\ \hline
\end{tabular} 
\end{latin}



 در ترسیمات مختلف می‌توان مختصات نقطه را به صورت قطبی 
 $(\theta :r)$
 وارد نمود. همچنین محدودیتی در این کار وجود ندارد. یعنی می‌توان مختصات برخی نقاط را دکارتی و برخی دیگر را قطبی وارد نمایید. هچنین می‌توان مولفه‌ها را بصورت اعداد توان دارد یا مجموعی از اعداد وارد نمود
 \\
 مثال
 \begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw[line width=2pt] (0,0) -- (0:1) --(30:1);
\draw[line width=2pt] (2,0) -- (2+1,2^.5);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\draw[line width=2pt] (0,0) -- (0:1) --(30:1);
\draw[line width=2pt] (2,0) -- (2+1,2^.5);
\end{tikzpicture}
می‌توان هنگام اتصال دو نقطه با استفاده  دستور $to$ و آپشن‌های 
\lr{out=deg}
 و 
 \lr{in=deg}
 زاویه خروج خط از نقطه شروه و ورود آن به نقطه پایانی، انحنای دلخواهی به خط اتصال داد.\\
 مثال
 \begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw[very thick] (0,0) to [out=90,in=195] (2,0);
\draw[very thick] (2.5,0) to [out=90,in=90] (3.5,0);
\draw[very thick] (4.5,0) to [out=45,in=135]
 (5.5,0) to [out=-45,in=-135] (6,0) ;
\draw [<->,thick, cyan] (7,0) to [out=90,in=180] (8,1)
to [out=0,in=180] (9.5,0) to [out=0,in=-135] (11,1) ;
\end{tikzpicture}
\end{verbatim}
\end{LTR}
 \begin{tikzpicture}
\draw[very thick] (0,0) to [out=90,in=195] (2,0);
\draw[very thick] (2.5,0) to [out=90,in=90] (3.5,0);
\draw[very thick] (4.5,0) to [out=45,in=135] (5.5,0) to [out=-45,in=-135] (6,0) ;
\draw [<->,thick, cyan] (7,0) to [out=90,in=180] (8,1)
to [out=0,in=180] (9.5,0) to [out=0,in=-135] (11,1) ;
\end{tikzpicture}
  
برای رسم مستطیل می‌توان   اضلاع آن را رسم نمود اما روش ساده‌تر آن است  مختصات دو گوشه مقابل به هم از مستطیل  به شکل زیر داده می‌شود. 

\begin{flushleft}
$\backslash draw  (x_0,y_0)\ rectangle\ (x_1,y_1);$
\end{flushleft}
 و یا با استفاده از علامت$+$ می‌توان مختصات یک گوشه را داد و به مقدار دلخواه به طول و عرض این نقطه اضافه نمود
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw (0,0) rectangle (2,1);
\draw (-0.5,-0.5) rectangle (-1,-1);
\draw (3,0) rectangle +(1.5,1);
\draw (5,1) rectangle +(1,-1);
\end{tikzpicture}
\end{verbatim}
\begin{tikzpicture}
\draw (0,0) rectangle (2,1);
\draw (-0.5,-0.5) rectangle (-1,-1);
\draw (3,0) rectangle +(1.5,1);
\draw (5,1) rectangle +(1,-1);
\end{tikzpicture}
\end{LTR}
رسم شطرنجی 

\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw[step=.25cm] (-2,-1) grid (3,2);
\draw[step=.5cm] (3.75,-.75) grid (6.7,2.3);
\end{tikzpicture}
\end{verbatim}\end{LTR}
\begin{tikzpicture}
\draw[step=.25cm] (-1,-1) grid (2,2);
\draw[step=.5cm] (3.75,-.75) grid (6.7,2.3);
\end{tikzpicture}


برای  رسم دایره و بیضی  مختصات مرکز و اندازه شعاع   به صورت زیر داده می‌شود. در خصوص بیضی شعاع بزرگ و کوچک داده می‌شود.
\begin{flushleft}
$\backslash  draw\ (x,y)\ circle\ (r\ cm);$\\
$\backslash  draw \ (x,y)\ ellipse\ (r_1cm \ and \ r_2cm);$
\end{flushleft}
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw[line width=2pt] (0,0) circle (1cm);
\draw [line width=2pt](3,1) circle (.5cm);
\draw [line width=2pt](3,0) ellipse (1cm and .75cm);
\end{tikzpicture}
\end{verbatim}
\begin{tikzpicture}
\draw[line width=2pt] (0,0) circle (1cm);
\draw [line width=2pt](3,1) circle (.5cm);
\draw [line width=2pt](3,0) ellipse (1cm and .75cm);
\end{tikzpicture}
\end{LTR}



 
می‌توان رنگ نمودن داخل یک شکل هم می‌توان 
از دستورهای 
\lr{fill}
و
\lr{filldraw}
استفاده کرد و هم می‌توان 
\lr{fill}
را به صورت یک آپشن اختیاری استفاده کرد. 
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\fill[green!20!white,ultra thick] (0,0) rectangle (1,1);
\draw [fill=red,ultra thick,red] (2,0) rectangle (3,1);
\filldraw [blue, fill=blue] (4,0) -- (5,1) -- (4.75,0.15) -- (4,0);
\draw [fill] (7,0.5) circle [radius=0.1];
\draw [fill=orange] (9,0) rectangle (11,1);
\draw [fill=white] (9.25,0.25) rectangle (10,1.5);
\end{tikzpicture}
\end{verbatim}
\begin{tikzpicture}
\fill[green!20!white,ultra thick] (0,0) rectangle (1,1);
\draw [fill=red,ultra thick] (2,0) rectangle (3,1);
\filldraw [blue, fill=blue] (4,0) -- (5,1) -- (4.75,0.15) -- (4,0);
\draw [fill] (7,0.5) circle [radius=0.4];
\draw [fill=orange] (9,0) rectangle (11,1);
\draw [fill=white] (9.25,0.25) rectangle (10,1.5);
\end{tikzpicture}
\end{LTR}

استفاده از دستور $\ba shade$  برای  رنگ‌ کردن :


\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}[rounded corners,ultra thick]
\shade[top color=yellow,bottom color=black] (0,0) rectangle (2,1);
\shadedraw[inner color=yellow,outer color=red,draw=black] 
(3,0) rectangle +(2,1);
\shade[left color=yellow,right color=black] (6,0) rectangle +(1,1);
\shadedraw[inner color=yellow,outer%
 color=red,draw=yellow] (7.5,0) rectangle +(2,1);
\shade[ball  color=yellow] (4,-.50) circle (.5cm);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}[rounded corners,ultra thick]
\shade[top color=yellow,bottom color=black] (0,0) rectangle (2,1);
\shadedraw[inner color=yellow,outer color=red,draw=black] 
(3,0) rectangle +(2,1);
\shade[left color=yellow,right color=black] (6,0) rectangle +(1,1);
\shadedraw[inner color=yellow,outer color=red,draw=yellow] (7.5,0) rectangle +(2,1);
\shade[ball  color=yellow] (4,-.50) circle (.5cm);
\end{tikzpicture}
 رسم کمان یا بخش  از یک  دایره‌ به شعاع $r$ را که از زاویه $\alpha$ شروع و به $beta$ ختم می‌شود. 
\begin{flushleft}
$\backslash  draw\ (x,y)\ arc\ (\alpha:\beta:\ r);$
\end{flushleft}
متذکر می‌شویم که
فرم قطبی یک نقطه به صورت $(\theta : r)$ می‌باشد. همچنین برای رسم کمانی از یک بیضی  کافیست در دستور بالا شعاع دوم بیضی نیز اضافه شود.\\
مثال:
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw (0,0) arc (10:80:1cm );
\draw (2,0) arc (0:90:1cm );
\draw (6,0) arc (0:250:1.75cm and 1cm);
\end{tikzpicture}
\end{verbatim}
\begin{tikzpicture}
\draw (0,0) arc (10:80:1cm );
\draw (2,0) arc (0:90:1cm );
\draw (6,0) arc (0:250:1.75cm and 1cm);
\end{tikzpicture}
\end{LTR}  


\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw (0,0) -- (0:4) -- (30:3) -- cycle;
\filldraw[fill=blue!20!white, draw=black]
(0,0) -- (0:.5) arc (0:30:.5) -- cycle;
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\draw (0,0) -- (0:4) -- (30:3) -- cycle;
\filldraw[fill=blue!20!white, draw=black]
(0,0) -- (0:.5) arc (0:30:.5) -- cycle;
\end{tikzpicture}


\begin{LTR}
\begin{verbatim}
\filldraw[thick,fill=black!10] (0,0) circle (1.3cm);
\draw(0,0) -- (100:1.3);
\draw (1.35cm,8mm) node[above] {$100^\circ$};
\draw(0,0) -- (180:1.3);
\draw (-10mm,10mm) node[above] {$80^\circ$};
\draw(0,0) -- (260:1.3);\draw (-13mm,-13mm) node[above] {$80^\circ$};
\draw(0,0) -- (320:1.3);\draw (4mm,-18mm) node[above] {$60^\circ$};
\draw(0,0) -- (0:1.3);\draw (16mm,-9mm) node[above] {$40^\circ$};
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\filldraw[thick,fill=black!10] (0,0) circle (1.3cm);
\draw(0,0) -- (100:1.3);
\draw (1.35cm,8mm) node[above] {$100^\circ$};
\draw(0,0) -- (180:1.3);
\draw (-10mm,10mm) node[above] {$80^\circ$};
\draw(0,0) -- (260:1.3);\draw (-13mm,-13mm) node[above] {$80^\circ$};
\draw(0,0) -- (320:1.3);\draw (4mm,-18mm) node[above] {$60^\circ$};
\draw(0,0) -- (0:1.3);\draw (16mm,-9mm) node[above] {$40^\circ$};
\end{tikzpicture}



\begin{LTR}\begin{verbatim}
\begin{tikzpicture}
\fill[red!20!white] (0,0) -- (2,0) arc (0:50:2cm) -- (0,0);
\fill[green!60!white]  (0,0) -- (50:2) arc (50:180:2) -- (0,0);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\filldraw[red!20!white] (0,0) -- (2,0) arc (0:50:2cm) -- (0,0);
\fill[green!60!white]  (0,0) -- (50:2) arc (50:180:2) -- (0,0);
\end{tikzpicture}
در اشکال بسته، برای برگشت به نقطه اولیه بجای دادن  مختصات آن  می‌توان دستور $cycle$ را داد. 

\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\filldraw[fill=blue!20!white, draw=red!50!black]
(0,0) -- (2,0) arc (0:30:2) -- (0,0);
\filldraw[fill=blue!20!white, draw=red!50!black]
(3,0) -- (5,0) arc (0:30:2) -- cycle;
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\filldraw[fill=blue!20!white, draw=red!50!black]
(0,0) -- (2,0) arc (0:30:2) -- (0,0);
\filldraw[fill=blue!20!white, draw=red!50!black]
(3,0) -- (5,0) arc (0:30:2) -- cycle;
\end{tikzpicture}
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\shadedraw[left color=red!90,right color=green!80, draw=blue]
(0,0) -- (2,0) arc (0:60:2) -- cycle;
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\shadedraw[left color=red!90,right color=green!80, draw=blue]
(0,0) -- (2,0) arc (0:60:2) -- cycle;
\end{tikzpicture}
مثال
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw (0,0) -- (4,0) -- (3,2) -- cycle;
\filldraw[fill=blue!20!white, draw=black]
(0,0) -- (.5,0) arc (0:33:.5) -- cycle;
\filldraw[fill=blue!20!white, draw=black]
(4,0) -- (3.5,0) arc (180:117:.5) -- cycle;
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\draw (0,0) -- (4,0) -- (3,2) -- cycle;
\filldraw[fill=blue!20!white, draw=black]
(0,0) -- (.5,0) arc (0:33:.5) -- cycle;
\filldraw[fill=blue!20!white, draw=black]
(4,0) -- (3.5,0) arc (180:117:.5) -- cycle;
\end{tikzpicture}
برای برچسب گذاری در شکل‌ها از دستور 
\lr{node}
استفاده می‌کنیم.\\
مثال
\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (-.4,-.4) grid (2.4,2.4);
\draw [thick, <->] (0,2) -- (0,0) -- (2,0);
\node at (1,1) {\rl{برچسب}};
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (-.4,-.4) grid (2.4,2.4);
\draw [thick, <->] (0,2) -- (0,0) -- (2,0);
\node at (1,1) {\rl{برچسب}};
\end{tikzpicture}
همانطور که از شکل پیداست محل قرار گرفتن «برچسب» به گونه‌ای است که وسط آن در مختصات $(1,1)$ است. مثال‌های زیر روش جابجایی محل استقرار  «برچسب» را نشان می‌دهد

\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
\draw [thick, <->] (0,2) -- (0,0) -- (3,0);
\draw[fill] (2,1) circle [radius=0.025];
\node [below right, red] at (2,1) {\rl{راست پایین}};
\node [above left, green] at (2,1) {\rl{چپ بالا}};
\node [below left, purple] at (2,1) {\rl{چپ پایین}};
\node [above right, magenta] at (2,1) {\rl{راست بالا}};
\end{tikzpicture}
\end{verbatim}
\end{LTR}

\begin{tikzpicture}
\draw [thick, <->] (0,2) -- (0,0) -- (2,0);
\draw[fill] (1,1) circle [radius=0.025];
\node [below] at (1,1) {\rl{زیر}};
\node [above] at (1,1) {\rl{بالا}};
\node [left] at (1,1) {\rl{چپ}};
\node [right] at (1,1) {\rl{راست}};
\end{tikzpicture}


\begin{LTR}
\begin{verbatim}
\draw [thick, <->] (0,2) -- (0,0) -- (3,0);
\draw[fill] (2,1) circle [radius=0.025];
\node [below right, red] at (2,1) {\rl{راست پایین}};
\node [above left, green] at (2,1) {\rl{چپ بالا}};
\node [below left, purple] at (2,1) {\rl{چپ پایین}};
\node [above right, magenta] at (2,1) {\rl{راست بالا}};
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
\draw [thick, <->] (0,2) -- (0,0) -- (3,0);
\draw[fill] (2,1) circle [radius=0.025];
\node [below right, red] at (2,1) {\rl{راست پایین}};
\node [above left, green] at (2,1) {\rl{چپ بالا}};
\node [below left, purple] at (2,1) {\rl{چپ پایین}};
\node [above right, magenta] at (2,1) {\rl{راست بالا}};
\end{tikzpicture}



\begin{LTR}
\begin{verbatim}
\begin{tikzpicture}[xscale=3, yscale=1.5]
\draw [thick, <->] (0,1) -- (0,0) -- (1,0);
\node [below right] at (1,0) {$x$};
\node [left] at (0,1) {$y$};
\draw[fill] (.4,.6) circle
[radius=.5pt];
\node[above right] (.4,.6) {$A$};
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}[xscale=3, yscale=1.5]
\draw [thick, <->] (0,1) -- (0,0) -- (1,0);
\node [below right] at (1,0) {$x$};
\node [left] at (0,1) {$y$};
\draw[fill] (.4,.6) circle
[radius=.5pt];
\node[above right] (.4,.6) {$A$};
\end{tikzpicture}
  مختصاتی که در ترسیم‌ها بکار می‌رود را  نیز می‌توان برچسب‌گذاری نمود.\\
   مثال
 \begin{LTR}
\begin{verbatim}
\\begin{tikzpicture}[xscale=1.5]
\draw [thick] (0,0) node
[below left]{$A$} -- (2,0) node[below right]{$B$} -- (.5,1)
node[above]{$C$} --(0,0);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}[xscale=1.5]
\draw [thick] (0,0) node
[below left]{$A$} -- (2,0) node[below right]{$B$} -- (.5,1)
node[above]{$C$} --(0,0);
\end{tikzpicture}











 \begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
  \node (C) {$C$};
  \node (P) [below of=C] {$\prod_{i \in I} A_i$};
  \node (Ai) [right of=P] {$A_i$};
  \draw[->] (C) to node {$f_i$} (Ai);
  \draw[->, dashed] (C) to node [swap] {$\langle f_i \rangle_{i \in I}$} (P);
  \draw[->] (P) to node [swap] {$\pi_i$} (Ai);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\tikzset{node distance=2cm, auto}
\begin{tikzpicture}
  \node (C) {$C$};
  \node (P) [below of=C] {$\prod_{i \in I} A_i$};
  \node (Ai) [right of=P] {$A_i$};
  \draw[->] (C) to node {$f_i$} (Ai);
  \draw[->, dashed] (C) to node [swap] {$\langle f_i \rangle_{i \in I}$} (P);
  \draw[->] (P) to node [swap] {$\pi_i$} (Ai);
\end{tikzpicture}


 \begin{LTR}
\begin{verbatim}
\begin{tikzpicture}[line width=1.5pt]%[style={very thick}]
  \node (P) {$P$};
  \node (B) [right of=P] {$B$};
  \node (A) [below of=P] {$A$};
  \node (C) [below of=B] {$C$};
  \node (P1) [node distance=1.94cm, left of=P, above of=P] {$\hat{P}$};
  \draw[->] (P) to node  {$\bar{f}$} (B);
  \draw[->] (P) to node [swap] {$\bar{g}$} (A);
  \draw[->] (A) to node [swap] {$f$} (C);
  \draw[->] (B) to node {$g$} (C);
  \draw[->, bend right ] (P1) to node [swap] {$\hat{g}$} (A);
  \draw[->, bend left] (P1) to node {$\hat{f}$} (B);
  \draw[->, dashed] (P1) to node {$k$} (P);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}[line width=1.5pt]%[style={very thick}]
  \node (P) {$P$};
  \node (B) [right of=P] {$B$};
  \node (A) [below of=P] {$A$};
  \node (C) [below of=B] {$C$};
  \node (P1) [node distance=1.94cm, left of=P, above of=P] {$\hat{P}$};
  \draw[->] (P) to node  {$\bar{f}$} (B);
  \draw[->] (P) to node [swap] {$\bar{g}$} (A);
  \draw[->] (A) to node [swap] {$f$} (C);
  \draw[->] (B) to node {$g$} (C);
  \draw[->, bend right ] (P1) to node [swap] {$\hat{g}$} (A);
  \draw[->, bend left] (P1) to node {$\hat{f}$} (B);
  \draw[->, dashed] (P1) to node {$k$} (P);
\end{tikzpicture}


 \begin{LTR}
\begin{verbatim}
\begin{tikzpicture}[%
  back line/.style={densely dotted},
  cross line/.style={preaction={draw=white, -,line width=6pt}}]
  \node (A) {$A$};
  \node [right of=A] (B) {$B$};
  \node [below of=A] (C) {$C$};
  \node [right of=C] (D) {$D$};
 
  \node (A1) [right of=A, above of=A, node distance=1cm] {$A^\prime$};
  \node [right of=A1] (B1) {$B^\prime$};
  \node [below of=A1] (C1) {$C^\prime$};
  \node [right of=C1] (D1) {$D^\prime$};
 
  \draw[back line] (D1) -- (C1) -- (A1);
  \draw[back line] (C) -- (C1);
  \draw[cross line] (D1) -- (B1) -- (A1) -- (A)  -- (B) -- (D) -- (C) -- (A);
  \draw (D) -- (D1) -- (B1) -- (B);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}[%
  back line/.style={densely dotted},
  cross line/.style={preaction={draw=white, -,line width=6pt}}]
  \node (A) {$A$};
  \node [right of=A] (B) {$B$};
  \node [below of=A] (C) {$C$};
  \node [right of=C] (D) {$D$};
 
  \node (A1) [right of=A, above of=A, node distance=1cm] {$A^\prime$};
  \node [right of=A1] (B1) {$B^\prime$};
  \node [below of=A1] (C1) {$C^\prime$};
  \node [right of=C1] (D1) {$D^\prime$};
 
  \draw[back line] (D1) -- (C1) -- (A1);
  \draw[back line] (C) -- (C1);
  \draw[cross line] (D1) -- (B1) -- (A1) -- (A)  -- (B) -- (D) -- (C) -- (A);
  \draw (D) -- (D1) -- (B1) -- (B);
\end{tikzpicture}



 \begin{LTR}
\begin{verbatim}
\begin{tikzpicture}
  \node (A) {$A$};
  \node [right of=A] (B) {$B$};
  \draw[->] (A) to node {$f$} (B);
  \path (A) to node [swap] {$g$} (B);
\end{tikzpicture}
\end{verbatim}
\end{LTR}
\begin{tikzpicture}
  \node {$A$} edge [loop above] (A);
  \node [right of=A] {$B$} edge [out=10, in=50, loop] (B);
\end{tikzpicture}
\begin{tikzpicture}
  \node (A) {$A$};
  \node [right of=A] (B) {$B$};
  \draw[->] (A) to node {$f$} (B);
  \path (A) to node [swap] {$g$} (B);
\end{tikzpicture}
\end{document}
