中心 pgf-tikz 路径

中心 pgf-tikz 路径

我希望我的绘图的尖端位于中心,而不是位于侧面。我对图形一无所知,而且\centering行不通。

代码生成的图片:

原来的

我想要的图片是:

应该

我的代码:

\documentclass{article}
\usepackage{pgf,tikz}
\tikzset{>=stealth}
\begin{document}
\begin{tikzpicture}[y=0.75pt, x=0.75pt, yscale=-1, xscale=1, inner sep=0pt, outer sep=0pt, <->]
\begin{scope}
\path[color=black,draw=black,line join=round,line cap=round,miter limit=4.00,even odd rule,line width=2.000pt] (0,0) .. controls (65,85) and (105,-15) .. (135,-45) .. controls (185,-95) and (255,-70) .. (290,-120) .. controls (325,-160) and (340,30) .. (385,-10) .. controls (420,-50) and (440,-35) .. (480,-45) .. controls (505,-50) and (530,-95) .. (530,-95);
\end{scope}
\end{tikzpicture}
\end{document}

答案1

使用您的 MWE,问题似乎出在一个坏框上(特别是 \hbox 过满,这意味着图像太宽,无法放入段落中)。稍微调整一下选项中的x和的值,我发现值可以正常工作,但图像会变小。同样,您可以尝试操纵字段和的值。ytikzpicture0.61ptxscaleyscale

另一种解决方案:您可以将tikzpucture图像包装在figure环境中,然后使用命令\centering将图像居中。请注意,我更改了xy值,因为0.75pt坏框仍然存在。我使用该包lipsum只是为了编写文本以查看对齐。

\documentclass{article}

\usepackage{pgf,tikz}
\usepackage{lipsum}

\tikzset{>=stealth}
\begin{document}
\lipsum[1]
\begin{figure}[h]
    \centering
\begin{tikzpicture}[y=0.64pt, x=0.64pt, yscale=-1, xscale=1, inner sep=0pt, outer sep=0pt, <->]
\begin{scope}
\path[color=black,draw=black,line join=round,line cap=round,miter limit=4.00,even odd rule,line width=2.000pt] (0,0) .. controls (65,85) and (105,-15) .. (135,-45) .. controls (185,-95) and (255,-70) .. (290,-120) .. controls (325,-160) and (340,30) .. (385,-10) .. controls (420,-50) and (440,-35) .. (480,-45) .. controls (505,-50) and (530,-95) .. (530,-95);
\end{scope}
\end{tikzpicture}
\end{figure}
\lipsum[1]
\end{document}

在此处输入图片描述

答案2

像这样吗?

调整后的图片

\documentclass{article}
\usepackage{tikz,showframe}
\tikzset{>=stealth}
\begin{document}
\centering
\begin{tikzpicture}[y=0.5pt, x=0.5pt, yscale=-1, xscale=1, inner sep=0pt, outer sep=0pt, <->]
  \path[draw=black, line join=round, line cap=round,miter limit=4, line width=2pt] (0,0) .. controls (65,85) and (105,-15) .. (135,-45) .. controls (185,-95) and (255,-70) .. (290,-120) .. controls (325,-160) and (340,30) .. (385,-10) .. controls (420,-50) and (440,-35) .. (480,-45) .. controls (505,-50) and (530,-95) .. (530,-95);
\end{tikzpicture}
\end{document}

相关内容