我有一张 TikZ 图片,我想将其作为 LaTeX 文档中的居中图形。但是,我试图实现的“居中”有些特殊,下图可以最好地解释这一点:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\draw[fill] (0,0) circle [radius=0.075] node [inner sep=0pt] (c) {};
\draw [red] (c) edge [bend right] node[at end, right]{this is the center} (5,-1);
\end{tikzpicture}
\caption{}
\end{figure}
\end{document}
导致
如何才能使图片以“中心”点为中心,例如通过指定要放置在页面水平中间的节点 (c)?
答案1
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\draw[fill,use as bounding box] (0,0) circle [radius=0.075] node [inner sep=0pt] (c) {};
\draw [red] (c) edge [bend right] node[at end, right]{this is the center} (5,-1);
\end{tikzpicture}
\vspace{1cm}
\caption{}
\end{figure}
\end{document}
答案2
尽管对于这种事情,use as bounding box
加号可能是我的第一选择或“默认”选择,但在这种情况下,您可以尝试使用键,这将使之变得不必要。\vspace
trim right
\vspace
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[trim right=(c)]
\draw[fill] (0,0) circle [radius=0.075] node [inner sep=0pt] (c) {};
\draw [red] (c) edge [bend right] node[at end, right]{this is the center} (5,-1);
\end{tikzpicture}
\caption{}
\end{figure}
\end{document}