\documentclass{article}
\usepackage[margin=.5in]{geometry}
\usepackage{tikz}
\usetikzlibrary{patterns, decorations.pathreplacing}
\usepackage{circuitikz}

\title{TikZ Example}
\author{Amirhossien Dehghan}

\begin{document}

\maketitle

There is a simple demo for TikZ, enjoy.
There is a simple demo for TikZ, enjoy.
There is a simple demo for TikZ, enjoy.
There is a simple demo for TikZ, enjoy.
There is a simple \the\textwidth demo for TikZ, enjoy.
\bigskip

\hbox to \textwidth{
\hfil
\hbox{
\begin{tikzpicture}[scale=.8]
\fill[pattern=north west lines] (0, 5) rectangle (4, 5.2);
\draw (2, 2)--(2, 5);
\draw[fill=gray] (2, 1.5) circle (.5);
\end{tikzpicture}}
\hspace{2cm}
\hbox{
\begin{tikzpicture}[scale=.5, domain=1:5]
\draw[->] (0,0) -- (6,0) node[right, below] {$x$};
\draw[->] (0,0) -- (0,6);
\coordinate [label=left:$A$] (a) at (1,1);
\coordinate [label=above:$B$] (b) at (5,5);

%\fill[gray, variable=\x]
\draw plot (\x, \x);
\end{tikzpicture}}
\hfil
}

There is some text after that image.

\begin{tikzpicture}
	\draw (0, 0) grid (4, 2);
	\node at (.5, .5) {$\times$};
	\node at (1.5, .5) {$\times$};
	\node at (2.5, .5) {$\times$};
	\node at (3.5, .5) {$\times$};
	\node at (2.5, 1.5) {1};
	\draw (2.25, .25) rectangle (2.75, 1.75);
	\tikzstyle{mydec}=[decorate, decoration={brace, raise=2pt}];
	\tikzstyle{midnode}=[midway, xshift=-10pt];
	\draw[mydec] (0,0) -- (0,1) node[midnode] {$A$};
\end{tikzpicture}

The following Venn diagram depicts the intersection of two sets (the green area):
\begin{figure}[h]
	\centering
	\begin{tikzpicture}
		\def\firstcircle{(0,0) circle (2)}
		\def\secondcircle{(2.3,0) circle (1.5)}
		\fill[red!50]\firstcircle;
		\fill[blue!50]\secondcircle;
		\begin{scope}
			\clip \firstcircle;
			\fill[green!50]\secondcircle;
		\end{scope}
		\draw\firstcircle node[left] {$A$};
		\draw\secondcircle node[right] {$B$};
		\draw (1.4,-0.2) node[above] {$A\cap B$};
	\end{tikzpicture}
\end{figure}
\pagebreak

Look at this analog to digital converter.
\begin{figure}[h]
	\centering
	\ctikzset{muxdemux/inner label font=\normalsize}
	\ctikzset{muxdemux/outer label font=\normalsize}
	\ctikzset{amplifiers/scale=.7, amplifiers/plus={\small $+$},
		amplifiers/minus={\small $-$}}
	\tikzset{encoder/.style={muxdemux,
		muxdemux def={Lh=14.3, Rh=14.3, w=4, NL=4, NR=1, NB=0},
		muxdemux label={L1=3, L2=2, L3=1, L4=0},
		external pins width=.5
	}}
	\begin{circuitikz}
		\draw (0,0) node[encoder](e){}
			(e.lpin 1) node[op amp, noinv input up, anchor=out](c1){}
			(e.lpin 2) node[op amp, noinv input up, anchor=out](c2){}
			(e.lpin 3) node[op amp, noinv input up, anchor=out](c3){}
			(e.lpin 4) node[anchor=east] {$V_{cc}$}
			
			(c3.+) -| ++(-1,6) node[vcc](vin){$V_{in}$}

			($(vin)+(-1.5,0)$) node[vcc](vref){$V_{ref}$}
			(vref) to[R=$R$] (vref |- c1.-) to[R=$R$] (vref |- c2.-)
				to[R=$R$] (vref |- c3.-) to[R=$R$] ++(0,-2) node[ground]{}

			(c1.-) -- (vref |- c1.-)
			(c2.-) -- (vref |- c2.-)
			(c3.-) -- (vref |- c3.-)

			(c1.+) -- (vin |- c1.+)
			(c2.+) -- (vin |- c2.+)
			(c3.+) -- (vin |- c3.+)

			(e.rpin 1) node[anchor=west] {$D_{out}$}

			(e.north) node[above, align=center] {priority\\encoder}
		;
	\end{circuitikz}
\end{figure}

\end{document}
