2

I am trying to place a figure environment inside a tikzpicture as:

  \begin{tikzpicture}
    \node [mybox] (box){%
      \begin{minipage}{0.45\textwidth}
%   \LHead{
    \begin{wrapfigure}{r}{.2\textwidth}
      \begin{center}
        \includegraphics[scale=1.]{Figures/cell2.png}
        \caption{\tikz \shade[ball color=gray] circle(0.45); Sphere}
      \end{center}
    \end{wrapfigure}
%   }
      \end{minipage}
    };
    \node[fancytitle, right=30pt,rounded corners=10pt] at (box.north west) {\Huge{Structure}};
  \end{tikzpicture}

If I just put includegraphics, without the figure env, its working. But I need figure env in this case as I would like to place the caption beside the figure.

I am compiling with pdflatex and texlive 2013

BaRud
  • 2,179
  • Which is the desired output? Do you just want a figure and its caption beside? Please explain your exact intent. – Gonzalo Medina Jul 11 '13 at 14:37
  • you understand it correctly, as mentioned in my penultimate line: " I would like to place the caption beside the figure." – BaRud Jul 11 '13 at 14:47
  • You don't need caption command. Put a node under it and use the current figure number for the text. After the tikz picture you can increment the number manually. – percusse Jul 11 '13 at 14:51
  • @percusse without a proper caption how would you manage a possible cross-referencing? – Gonzalo Medina Jul 11 '13 at 14:55
  • Can you add to your question a simple, but complete document showing the box and fancytitle styles, so we can get a better idea of your settings? – Gonzalo Medina Jul 11 '13 at 14:56
  • @percusse, I cannt afford it "below". I have to place it "beside" – BaRud Jul 11 '13 at 14:57
  • what I have posted is a complete box. But I have solve the problem, placing 2 minipage side-by-side. – BaRud Jul 11 '13 at 15:06
  • @Gonzalo : can you kindly keep your answer? I am trying sidecap, so I need your reply. – BaRud Jul 11 '13 at 15:22
  • Ah, I though the problem was already solved and my answer was useless. Sorry. I'll undelete it. – Gonzalo Medina Jul 11 '13 at 15:30

3 Answers3

3

One option is to use the sidecap package and place the tikzpicture inside a SCfigure environment:

\documentclass{article}
\usepackage{graphicx}
\usepackage{sidecap}
\usepackage{tikz}

\begin{document}

\begin{SCfigure}
\begin{tikzpicture}
    \node[text width=0.45\textwidth,align=center] (box){%
      \begin{center}
        \includegraphics[height=4cm]{example-image-a}
      \end{center}
    };
    \node[draw=red,right=30pt,rounded corners=10pt] at (box.north west) {\Huge{Structure}};
\end{tikzpicture}
\caption{\protect\tikz \protect\shade[ball color=gray] circle(0.45); Sphere}
\end{SCfigure}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
0

Maybe you can use the capt-of package. The figure environment is used to have a floating figure but in this case you don't need it. The capt-of package provides a command(\captionof) that works outside a floats.

Red
  • 10,181
0

This is how I solved it. @Gonzalo, I will try yours as well

 \begin{tikzpicture}
    \node [mybox] (box){%
      \begin{tabular}{ll}
      \begin{minipage}{0.25\textwidth}
%   \LHead{
      \begin{center}
        \includegraphics[scale=1.]{Figures/cell2.png}
%       \captionof{figure}[onefigure]{onefigure; \tikz \shade[ball color=gray] circle(0.45); Empty Sphere}
      \end{center}
%   }
      \end{minipage} 
      &
      \begin{minipage}{0.15\textwidth}
    \LHead{
%     \begin{center}
        {\tikz \shade[ball color=red] circle(1.); A site}\\
        {\tikz \shade[ball color=gray] circle(1.); B site}\\
        {\tikz \shade[ball color=green] circle(1.); C Sphere}
%     \end{center}
    }
      \end{minipage} 
      \end{tabular}
    };
    \node[fancytitle, right=30pt,rounded corners=10pt] at (box.north west) {\Huge{MnBi Structure}};
  \end{tikzpicture}
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
BaRud
  • 2,179