我一直在使用 tikz 包尝试表示平面中的向量和(平行四边形方法)。但是,我尝试失败了,因为我不知道如何修改轴的限制,并且前进是 5 个单位,因为我想表示 (5,0) + (45,15),但图形表示太大了
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%eje x
\draw[ultra thick, ->](-0.5,0)--(6.5,0) node [right]{$x$};
%eje y
\draw[ultra thick, ->](0,-0.5)--(0,6.5) node [left]{$y$};
\foreach \x in {5,10,15,20,25}
\draw (\x,0.1)--(\x,-0.1) node[below]{$\x$};
\end{tikzpicture}
\end{document}
答案1
好吧,我猜你想要什么:
\foreach
解析我基本上使用的值,\pgfmathparse{<expression>}
如所述这里。
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%eje x
\draw[ultra thick, ->](-0.5,0)--(6,0) node [right]{$x$};
%eje y
\draw[ultra thick, ->](0,-0.5)--(0,6) node [left]{$y$};
\foreach \x in {0.5,1,...,4.5,5}{
\draw (\x,0.1)--(\x,-0.1);
\draw node at (\x, -10pt) {%
\pgfmathparse{\x*10}
\pgfmathprintnumber[
]{\pgfmathresult}%
};}
% parallelogram with vectors
\node[inner sep=0pt,outer sep=0pt,label=left:A](A) at(2,2) {};
\node[inner sep=0pt,outer sep=0pt,label=left:B](B) at(3,3) {};
\node[inner sep=0pt,outer sep=0pt,label=right:C](C) at(4,3) {};
\node[inner sep=0pt,outer sep=0pt,label=right:D](D) at(3,2) {};
\draw [-latex] (A) edge (B) (B) edge (C) (D) edge (A) (C) edge (D);
\end{tikzpicture}
答案2
您还可以尝试scale=
使用选项和来修改默认的 tikz- x=
length y=
。
下面是执行这两项操作的一些示例代码:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=.1,vector/.style={->,>=stealth,thick},unitvector/.style={ultra thick, ->,>=stealth,gray}]
\draw[unitvector](-0.5,0)--(6.5,0) node [right]{$x$};
\draw[unitvector](0,-0.5)--(0,6.5) node [left]{$y$};
\foreach \x in {5,10,...,50}{
\draw (\x,0.1)--(\x,-0.1) node[anchor=north,font=\footnotesize]{$\x$};
}
\draw[vector] (0,0) -- (0,5);
\draw[vector] (0,5) -- ++(45,15);
\end{tikzpicture}
\begin{tikzpicture}[x=.1cm,y=.1cm,vector/.style={->,>=stealth,thick},unitvector/.style={ultra thick, ->,>=stealth,gray}]
\draw[unitvector](-0.5,0)--(6.5,0) node [right]{$x$};
\draw[unitvector](0,-0.5)--(0,6.5) node [left]{$y$};
\foreach \x in {5,10,...,50}{
\draw (\x,0.1)--(\x,-0.1) node[anchor=north,font=\footnotesize]{$\x$};
}
\draw[vector] (0,0) -- (0,5);
\draw[vector] (0,5) -- ++(45,15);
\end{tikzpicture}
\end{document}
两者都产生相同的图像: