tikzpicture 的標題並修改垂直空間

tikzpicture 的標題並修改垂直空間

tikzpicture 的標題放置在錯誤的位置(見圖)

我的程式碼是:

\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}

在此輸入影像描述

如何將標題放在 tikzpicture 下並更改標題/tikzpicture 之間的垂直間距?預先感謝

答案1

  1. 我們什麼時候應該使用 \begin{center} 而不是 \centering ?
  2. 此選項overlay用於將“某物”寫在“其他東西”上,並且不考慮“某物”的尺寸,就像“某物”沒有尺寸一樣,您不必將其用於普通圖片
  3. fill overzoom image是 的一個選項tcolorbox,您需要載入它
  4. 如果您所在的figure環境不需要\captionof,請改用\caption

\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}

在此輸入影像描述

編輯:我不太清楚你想要實現什麼,但如果你想水平移動圖片它的標題,使用 a minipage,如下所示:

\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}

在此輸入影像描述

在此輸入影像描述

相關內容