我是 latex 和 pgf/tikz 的新手。我的主管让我在 pgf 中创建下图。我不知道从哪里开始。有人能帮我/指导我吗?
答案1
当前的问题:
- 标签:并非所有标签我都能读懂并正确重现。
- 角平分线的标签:需要更多定制。
(0, 0, 0)
:它真的需要在那里吗?- 左下角的坐标系。添加起来并不难。
一对优点:
- 使用
em
:可以轻松缩放(基于字体大小)。 - 直角的半自动计算(开玩笑的,只是底部的一个)。
代码:
\documentclass{standalone}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (origin) at (0, 0);
\filldraw (origin) circle (0.05em);
\draw (origin) circle (6em);
% Two dotted lines
\draw[dotted] (0,8em) coordinate (p_1) -- (0,-8em) coordinate (p_2) node[below] {Bisector};
\draw[dotted] (-9em,-3em) coordinate (q_1) -- (9em,3em) coordinate (q_2) node[above] {Bisector};
% Vertices of the triangle
\coordinate (a) at (5.2em, -3em);
\filldraw (a) circle (0.05em);
\coordinate (b) at (2.35em, 5.5em);
\filldraw (b) circle (0.05em);
\coordinate (c) at (-5.2em, -3em);
\filldraw (c) circle (0.05em);
% Triangle edge with names
\draw[->] (a) node[below] {$3$} to node[right,midway] {$\vec{v}_1$} (b) node[above] {$1$};
\draw[dashed] (b) to node[above] {$\vec{v}_3$} (c) node[left] {$2$};
\draw[->] (a) to node[below,midway] {$\vec{v}_2$} (c);
% $p_c$ vector
\draw[->,thick] (0, 0.5em) to node[right,midway] {$p_c$} (intersection of b--c and p_1--p_2);
% $\vec{v}_4$ vector
\draw[->,thick] ($(q_1)!0.25!(q_2)$) to node[below,midway] {$\vec{v}_4$} ($(q_1)!0.4!(q_2)$);
% Right angle for two intersecting lines
\coordinate (i) at ($(intersection of a--c and p_1--p_2) + (0, 0.25em)$);
\draw (i) to ($(i)!0.25em!90:(p_1)$) coordinate (t) to ($(t)!0.25em!90:(c)$);
\coordinate (j) at ($(intersection of a--b and q_1--q_2) + (-0.25em, -0.083em)$);
\draw (j) to ($(j)!0.25em!90:(q_1)$) coordinate (t) to ($(t)!0.25em!90:(a)$);
\end{tikzpicture}
\end{document}
例子:
答案2
我也在学习 TikZ,所以我想我会尝试一下。我做的事情有些与 m0nhawk 不同,例如,我避免找出三角形的顶点。但我在这方面很新,所以可能有更好的方法来做某些事情(例如,角平分线和它们上的向量)。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary {calc}
\begin{document}
\begin{tikzpicture}
[
scale=3,
>=stealth,
point/.style= {draw, circle, inner sep=1pt, fill=black},
dot/.style= {draw, circle, inner sep=.2pt, fill=black},
]
% the circle
\def\rad{1}
\node (origin) at (0,0) [point, label={below right:$P_c$}]{};
\draw (origin) circle (\rad);
% triangle nodes: just points on the circle
\node (n1) at +(60:\rad) [point, label=above:$1$] {};
\node (n2) at +(-145:\rad) [point, label=below:$2$] {};
\node (n3) at +(-45:\rad) [point, label={below right:$3$ $(0, 0, 0)$}] {};
% triangle edges: connect the vertices, and leave a node at the midpoint
\draw[->] (n3) -- node (a) [label={above right:$\vec{v}_1$}] {} (n1);
\draw[->] (n3) -- node (b) [label={below right:$\vec{v}_2$}] {} (n2);
\draw[dashed] (n2) -- (n1);
% Bisectors
% start at the point lying on the line from (origin) to (a), at
% twice that distance, and then draw a path going to the point on
% the line lying on the line from (a) to the (origin), at 3 times
% that distance.
\draw[dotted]
($ (origin) ! 2 ! (a) $)
node [right] {Bisector 1}
-- ($(a) ! 3 ! (origin)$ );
% similarly for origin and b
\draw[dotted]
($ (origin) ! 2 ! (b) $)
-- ($(b) ! 3 ! (origin)$ )
node [right] {Bisector 2};
% short vectors
\draw[->]
($ (origin) ! -.7 ! (a) $)
-- node [below] {$\vec{u}_4$}
($ (origin) ! -.1 ! (a) $);
\draw[->]
($ (origin) ! -.1 ! (b) $)
-- node [right] {$\vec{u}_3$}
($ (origin) ! -.7 ! (b) $);
% Right angle symbols
\def\ralen{.5ex} % length of the short segment
\foreach \inter/\first/\last in {a/n3/origin, b/n2/origin}
{
\draw let \p1 = ($(\inter)!\ralen!(\first)$), % point along first path
\p2 = ($(\inter)!\ralen!(\last)$), % point along second path
\p3 = ($(\p1)+(\p2)-(\inter)$) % corner point
in
(\p1) -- (\p3) -- (\p2) % path
($(\inter)!.5!(\p3)$) node [dot] {}; % center dot
}
% Remote origin
\coordinate (remote) at +(-130:2*\rad);
\draw (remote) -- +(0, .3);
\draw (remote) -- +(.3, 0);
\draw (remote) -- +(-130:.2);
\draw[dashed] (remote) -- (n3);
\end{tikzpicture}
\end{document}
答案3
老实说,我会从文档 ( texdoc tikz
) 中的教程开始。我以前曾尝试从头开始创建特定文档作为“学习” tikz 的一种方式,但这太令人困惑了。教程会一步一步地指导您,并解释 和path
或draw
和node
之间的区别\node
。从教程 1 开始,然后一路完成。教程 3 中有两个构造(取自欧几里得的“几何原本”)与您正在寻找的非常相似。
正如评论中提到的,您可以在 Inkscape 中执行此操作,并使用 PGF/TikZ 选项将其导出为 PDF。这允许 LaTeX 为您处理文本。这可行,但我发现在创建文档时很难获得文本的精确位置---我必须在 Inkscape 中编辑、导出、排版、在 Inkscape 中调整、导出排版...等等。