-1

I wanted to add a figure into my TeX file. To do so I drew it like a picture with TikZ package. I want to add description of the figure and to add reference of the figure, i.e. to say something like this: "Fig1: blah blah blah". Also I want next to this figure to place another one, i.e. if it is possible the first figure to be on the left of the page, the second figure to be on the right of the page. Is this possible, if yes, which package should I use? This is the code that I used for the figure: EDIT I added the whole document.

\documentclass[11pt]{article}

\usepackage{amssymb,amsmath}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{amsthm}
\usepackage{graphicx}
\graphicspath{ {img/} }
\usepackage{fullpage}
\usepackage{algorithm}
\usepackage{hyperref}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
%\newtheorem{thm}{Theorem}
%\newtheorem{thm1}{Theorem}
\theoremstyle{definition}
\usepackage{float}
\newtheorem{defn}{Definition}[section]
\floatname{algorithm}{Algorithm}
\newcommand{\euler}{e}
\newcommand{\firstName}{Name1 }
\newtheorem{thm}{Theorem}
\newcounter{claimcounter}
%\numberwithin{claimcounter}{thm}
%\newenvironment{claim}[1]{\par\noindent\underline{Claim:}\space#1}{}
%\newenvironment{claimproof}[1]{\par\noindent\underline{Proof:}\space#1}{\hfill $\blacksquare$}
\newenvironment{claim}{\stepcounter{claimcounter}{Claim \theclaimcounter:}}{}

\begin{document}

\title{Title}
\author{some author}
\date{\today}
\maketitle

\tikzset{%
   point/.style = {fill=black,inner sep=1pt, circle, minimum width=3pt,align=right,rotate=60},
   } 
\tikzstyle{weight} = [font=\scriptsize]  
\tikzstyle{vertex}=[circle,fill=blue!20]

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother


\section{Some Section}
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah\\
blah blah blah blah blah blah blah blah blah blah blah blah  blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah\\
blah blah blah blah blah blah blah blah blah blah blah blah  blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah\\
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah\\
blah blah blah blah blah blah blah blah blah blah blah blah

\begin{figure}
\resizebox{0.4\textwidth}{!}{
 \begin{tikzpicture}
  [scale=.8,auto=left]
  \node[vertex] (v1) at (1,10)  {$a_1$};
  \node[vertex] (v2) at (1,8)  {$a_2$};
  \node[vertex] (v3) at (1,6)  {$a_3$};
  \node[vertex] (v4) at (8,10)  {$b_1$};
  \node[vertex] (v5) at (8,8)   {$b_2$};


  \begin{scope}[every edge/.style={draw=black}]
    \draw  (v4) edge  (v1);
    \draw  (v4) edge  (v2);
   \end{scope}
   \begin{scope}[every edge/.style={draw=red}]
    \draw  (v5) edge (v1);
    \draw  (v5) edge (v3);
   \end{scope}
 \end{tikzpicture}
 }
 \caption{Right now the caption is on the whole page with one line. I want to be on the half page and may occupy more lines.}
    \label{fig:1}
\end{figure}

blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah\\
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah\\
blah blah blah blah blah blah blah blah blah blah blah blah

\end{document}
  • you can use \begin{figure}[...] \begin{tikzpicture} .... \end{tikzpicture} \caption{bla bla bla} \label{fig:blabla} \end{figure} – rpapa Dec 23 '14 at 19:57
  • 1
    To generate a caption and a label for references just put the tikzpicture in a figure environment, while to have two figures side by side have a look at the package subcaption. – Pier Paolo Dec 23 '14 at 19:58
  • Please complete your code so that people can copy-paste-compile it. That is much more useful than just seeing a fragment. – cfr Dec 23 '14 at 20:18
  • @PierPaolo, thanks for your comment. I have another question. Right now, my coption goues throw the whole page. How should I modify the code such that the whole picture (and the caption) occupy just the left part of the page? – user3371223 Dec 23 '14 at 20:22
  • @cfr, I added thecomplete code. – user3371223 Dec 23 '14 at 20:30
  • 1
    The subcaption package provides the subfigure environment which lets you insert a caption for each figure and also one for the whole figure. – Pier Paolo Dec 23 '14 at 20:38

1 Answers1

0

How to add caption for a TikZ picture?

For subfigures take a look at the http://www.ctan.org/pkg/subfigure package

Dirk11
  • 41
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Usually an answer on this site should not just be a link. When you have more reputation, you will be able to post suggestions like this as comments. Or you could expand your answer to include a small, compilable example. – cfr Dec 23 '14 at 20:17