1

Caption of tikzpicture placed in wrong postion (see image)

My code is:

\documentclass[8pt]{article}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{translator, tikz, array}
\usepackage{tikzsymbols}
\usepackage{float}                                      
\usepackage{graphicx}
\usetikzlibrary{arrows,shapes.geometric,positioning}
\begin{document}
Example caption of Tikzpicture:
\begin{figure}
\begin{center}
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0,xshift=6.0cm,yshift=0cm]
[circle,draw, very thick, color=red, minimum size=5.0cm, fill overzoom image=example-image-a]{};
\end{tikzpicture}
\captionof*{figure}{ABC}
\end{center}
\end{figure}
\end{document}

enter image description here

How can i put caption under tikzpicture and can change vertical space between caption/tikzpicture? Thank in advance

latexforti
  • 2,091

1 Answers1

3
  1. See When should we use \begin{center} instead of \centering?
  2. the option overlay is used to write "something" over "something else" and do not consider the dimension of "something", it's like "something" has no dimension, you don't have to use it for an ordinary picture
  3. fill overzoom image is an option of tcolorbox, you need to load it
  4. if you are in a figure environment, you do not need \captionof, use \caption instead.

\documentclass[8pt]{article}
\usepackage{caption}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage[many]{tcolorbox}

\begin{document}
Example caption of Tikzpicture:
\begin{figure}
\centering
\begin{tikzpicture}
\node[circle, draw, very thick, color=red, minimum size=5.0cm, fill overzoom image=example-image-a] {};
\end{tikzpicture}
\caption{ABC}
\end{figure}
\end{document}

enter image description here

Edit: it's not very clear to me what you want to achieve, but if you want to horizontally move the picture and its caption, use a minipage, like here:

\documentclass[8pt]{article}
\usepackage{caption}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage[many]{tcolorbox}

\begin{document}
In Fig.~\ref{fig:left} the image and its caption are on the left.
\begin{figure}[htb]
\begin{minipage}{.42\linewidth}
\centering
\begin{tikzpicture}
\node[circle, draw, very thick, color=red, minimum size=5.0cm, fill overzoom image=example-image-a] {};
\end{tikzpicture}
\caption{ABC\label{fig:left}}
\end{minipage}
\end{figure}

With \verb|\hspace{...}| you can shift them to the right as you like, see Fig.~\ref{fig:hspa}. 
\begin{figure}[htb]\hspace{5cm}
\begin{minipage}{.42\linewidth}
\centering
\begin{tikzpicture}
\node[circle, draw, very thick, color=red, minimum size=5.0cm, fill overzoom image=example-image-a] {};
\end{tikzpicture}
\caption{ABC\label{fig:hspa}}
\end{minipage}
\end{figure}

With \verb|\hfill| you can shift them completely to the right, see Fig.~\ref{fig:hfi}. 
\begin{figure}[htp]\hfill
\begin{minipage}{.42\linewidth}
\centering
\begin{tikzpicture}
\node[circle, draw, very thick, color=red, minimum size=5.0cm, fill overzoom image=example-image-a] {};
\end{tikzpicture}
\caption{ABC\label{fig:hfi}}
\end{minipage}
\end{figure}
\end{document}

enter image description here

enter image description here

CarLaTeX
  • 62,716