我有以下由 geogebra 生成的代码,我对其进行了一些调整,特别是将 x、y 更改为 3cm 并将比例更改为 4。但现在我不确定如何将图片居中,这里是代码:
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=3.0cm,y=3.0cm,scale=4]
\clip(3.5333787630945284,1.7083565670236165) rectangle (5.6183536539936805,3.2691205033798227);
\draw(4.562096541660087,3.141936112320542) -- (3.864932244907646,2.1201049468877806) -- (5.203961300072035,2.1259431133816373) -- cycle;
\draw (4.562096541660087,3.141936112320542)-- (3.864932244907646,2.1201049468877806);
\draw (3.864932244907646,2.1201049468877806)-- (5.203961300072035,2.1259431133816373);
\draw (5.203961300072035,2.1259431133816373)-- (4.562096541660087,3.141936112320542);
\draw (4.168366372182411,2.4145577397475275) node[anchor=north west] {$\widetilde{\pi}(t+1)$};
\draw [dash pattern=on 1pt off 1pt] (4.743645593347985,2.3997297548490266)-- (4.254634754554275,2.410801698368883);
\draw (4.5125652630898605,2.8359046579273395) node[anchor=north west] {$\mu(t+1)$};
\draw (4.510587108544415,2.590613494292144) node[anchor=north west] {$\pi(t+1)$};
\draw (4.684664708543586,2.404666967020302) node[anchor=north west] {$\pi(t)$};
\draw (4.447286163090172,2.3868635761112955) node[anchor=north west] {drift};
\draw (4.312771653999904,2.517421776110674) node[anchor=north west] {rebalance};
\draw (4.653014235816464,2.5273125488379) node[anchor=north west] {consume $\lambda \gamma^*_\pi(t) $};
\draw [dash pattern=on 1pt off 1pt] (5.203961300072034,2.125943113381638)-- (4.743645593347985,2.3997297548490266);
\draw (4.743645593347985,2.3997297548490266)-- (4.55726787743039,2.5086038661276215);
\draw [dash pattern=on 1pt off 1pt] (4.254634754554275,2.410801698368883)-- (4.55726787743039,2.5086038661276215);
\draw (5.222722744904657,2.14948503065788) node[anchor=north west] {$e_3$};
\begin{scriptsize}
\draw [fill=black] (4.743645593347985,2.3997297548490266) circle (0.5pt);
\draw [fill=black] (4.48882740854452,2.7548003215640895) circle (0.5pt);
\draw [fill=black] (4.254634754554275,2.410801698368883) circle (0.5pt);
\draw [fill=black] (4.55726787743039,2.5086038661276215) circle (0.5pt);
\end{scriptsize}
\end{tikzpicture}
\end{figure}
\end{document}
我尝试了几个参数,但似乎缺少一个可以起作用的参数。
答案1
该数字太大。更改scale=4
为scale=2
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=3.0cm,y=3.0cm,scale=2]
用showframe
包来表明它处于居中状态:
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usepackage{showframe} % for demo
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=3.0cm,y=3.0cm,scale=2]
\clip(3.5333787630945284,1.7083565670236165) rectangle (5.6183536539936805,3.2691205033798227);
\draw(4.562096541660087,3.141936112320542) -- (3.864932244907646,2.1201049468877806) -- (5.203961300072035,2.1259431133816373) -- cycle;
\draw (4.562096541660087,3.141936112320542)-- (3.864932244907646,2.1201049468877806);
\draw (3.864932244907646,2.1201049468877806)-- (5.203961300072035,2.1259431133816373);
\draw (5.203961300072035,2.1259431133816373)-- (4.562096541660087,3.141936112320542);
\draw (4.168366372182411,2.4145577397475275) node[anchor=north west] {$\widetilde{\pi}(t+1)$};
\draw [dash pattern=on 1pt off 1pt] (4.743645593347985,2.3997297548490266)-- (4.254634754554275,2.410801698368883);
\draw (4.5125652630898605,2.8359046579273395) node[anchor=north west] {$\mu(t+1)$};
\draw (4.510587108544415,2.590613494292144) node[anchor=north west] {$\pi(t+1)$};
\draw (4.684664708543586,2.404666967020302) node[anchor=north west] {$\pi(t)$};
\draw (4.447286163090172,2.3868635761112955) node[anchor=north west] {drift};
\draw (4.312771653999904,2.517421776110674) node[anchor=north west] {rebalance};
\draw (4.653014235816464,2.5273125488379) node[anchor=north west] {consume $\lambda \gamma^*_\pi(t) $};
\draw [dash pattern=on 1pt off 1pt] (5.203961300072034,2.125943113381638)-- (4.743645593347985,2.3997297548490266);
\draw (4.743645593347985,2.3997297548490266)-- (4.55726787743039,2.5086038661276215);
\draw [dash pattern=on 1pt off 1pt] (4.254634754554275,2.410801698368883)-- (4.55726787743039,2.5086038661276215);
\draw (5.222722744904657,2.14948503065788) node[anchor=north west] {$e_3$};
\begin{scriptsize}
\draw [fill=black] (4.743645593347985,2.3997297548490266) circle (0.5pt);
\draw [fill=black] (4.48882740854452,2.7548003215640895) circle (0.5pt);
\draw [fill=black] (4.254634754554275,2.410801698368883) circle (0.5pt);
\draw [fill=black] (4.55726787743039,2.5086038661276215) circle (0.5pt);
\end{scriptsize}
\end{tikzpicture}
\end{figure}
\end{document}