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
- 看何时应使用 \begin{center} 而不是 \centering?
- 该选项
overlay
用于将“某物”写在“其他东西”上,而不考虑“某物”的维度,就像“某物”没有维度一样,你不必将它用于普通图片 fill overzoom image
是选项tcolorbox
,你需要加载它- 如果您处于
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}
编辑:我不太清楚你想要实现什么,但是如果你想水平移动图片和它的标题,使用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}