![将图形包裹在 tikzpicture 中](https://linux22.com/image/271886/%E5%B0%86%E5%9B%BE%E5%BD%A2%E5%8C%85%E8%A3%B9%E5%9C%A8%20tikzpicture%20%E4%B8%AD.png)
我正在尝试将图形环境放置在 tikzpicture 中,如下所示:
\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}
如果我只放置includegraphics
,而不放置figure
env ,它就可以工作。但在这种情况下我需要图形 env ,因为我想将标题放在图形旁边。
我正在使用 pdflatex 和 texlive 2013 进行编译
答案1
一种选择是使用sidecap
打包并将 tikzpicture 放置在SCfigure
环境中:
\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}
答案2
也许你可以使用捕获包。figure
环境用于显示浮动图形,但在本例中您不需要它。包提供了一个在浮动图形之外工作的capt-of
命令( )。\captionof
答案3
这就是我解决问题的方法。@Gonzalo,我也会尝试你的
\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}