编辑

编辑

以下代码TikZ绘制了平行线 $\ell$ 和 $m$ 以及相交线 $k$。我首先将原点(标记为 O)定位在 $m$ 上,然后使用\coordinate[left=of O](P);\coordinate[label={[fill=white]right:$m$},right=of O](Q);将另外两个点定位在 $m$ 上,并发出绘制线的命令,\draw[draw=blue!30,latex-latex] (P) -- (Q);从而绘制了线 $m$。默认情况下,这会使线长 2 厘米。如果我将 P 进一步向左移动,将 Q 进一步向右移动,显示效果会更好。我如何将其作为选项输入?

角度 $z_{1}$ 和 $z_{3}$ 距离线 $k$ 有点太近了。我该如何水平移动它们?

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}

\begin{document}

\begin{tikzpicture}

\coordinate(O) at (0,0);
\coordinate[left=of O](P);
\coordinate[label={[fill=white]right:$m$},right=of O](Q);
\coordinate(A) at (110:2);
\coordinate[left=of A](R);
\coordinate[label={[fill=white]right:$\ell$},right=of A](S);

\draw[draw=blue!30,latex-latex] (P) -- (Q);
\draw[draw=blue!30,latex-latex] (R) -- (S);
\draw (O) -- (A);
\draw[-latex] (O) -- (-70:1) coordinate (C);
\draw[-latex] (A) -- +(110:1) coordinate[label={[fill=white]above left:$k$}] (B);

\node[above right] at (A) {$\scriptstyle{x}$};
\node[below left] at (A) {$\scriptstyle{y}$};
\node[above left] at (O) {$\scriptstyle{z_{1}}$};
\node[above right] at (O) {$\scriptstyle{z_{2}}$};
\node[below right] at (O) {$\scriptstyle{z_{3}}$};
\node[below left] at (O) {$\scriptstyle{z_{4}}$};

\end{tikzpicture}

答案1

你可以说

[right=<dimension> of <coordinate>]

而不是仅仅使用[right] at (<coordinate>)。例如,

\node [above left=12mm and 15mm of A] {P};

P将创建位于 上方 12 毫米和 左侧 15 毫米处的节点A

因此,您可能会移动PQ发生类似以下的情况:

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc,angles,positioning,intersections,quotes}

\begin{document}
  \begin{tikzpicture}
    \coordinate(O) at (0,0);
    \coordinate[left=20mm of O](P);
    \coordinate[label={[fill=white]right:$m$},right=15mm of O](Q);
    \coordinate(A) at (110:2);
    \coordinate[left=of A](R);
    \coordinate[label={[fill=white]right:$\ell$},right=of A](S);

    \draw[draw=blue!30,latex-latex] (P) -- (Q);
    \draw[draw=blue!30,latex-latex] (R) -- (S);
    \draw (O) -- (A);
    \draw[-latex] (O) -- (-70:1) coordinate (C);
    \draw[-latex] (A) -- +(110:1) coordinate[label={[fill=white]above left:$k$}] (B);

    \node[above right] at (A) {$\scriptstyle{x}$};
    \node[below left] at (A) {$\scriptstyle{y}$};
    \node[above left] at (O) {$\scriptstyle{z_{1}}$};
    \node[above right] at (O) {$\scriptstyle{z_{2}}$};
    \node[below right] at (O) {$\scriptstyle{z_{3}}$};
    \node[below left] at (O) {$\scriptstyle{z_{4}}$};
  \end{tikzpicture}
\end{document}

移动 P 和 Q

编辑

您也可以考虑使用angles库来使绘制角度变得更容易一些。例如:

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,angles}

\begin{document}
  \begin{tikzpicture}
    [
      every label/.append style={fill=white},
      my blue/.style={draw=blue!30}
    ]
    \coordinate (O) at (0,0);
    \coordinate [left=20mm of O] (P);
    \coordinate [label={right:$m$}, right=15mm of O] (Q);
    \coordinate (A) at (110:2);
    \coordinate [left=of A] (R);
    \coordinate [label={right:$\ell$}, right=of A] (S);

    \draw [my blue, latex-latex] (P) -- (Q);
    \draw [my blue, latex-latex] (R) -- (S);
    \draw (O) -- (A);
    \draw [-latex] (O) -- (-70:1) coordinate (C);
    \draw [-latex] (A) -- +(110:1) coordinate [label={above left:$k$}] (B);

    \path pic ["$\scriptstyle{z_{1}}$", my blue, angle radius=5mm] {angle=A--O--P}
      pic ["$\scriptstyle{z_{2}}$", my blue, angle radius=5.5mm] {angle=Q--O--A}
      pic ["$\scriptstyle{z_{3}}$", my blue, angle radius=5mm] {angle=C--O--Q}
      pic ["$\scriptstyle{z_{4}}$", my blue, angle radius=5.5mm] {angle=P--O--C}
      pic ["$\scriptstyle{x}$", my blue, angle radius=5mm] {angle=S--A--B}
      pic ["$\scriptstyle{y}$", my blue, angle radius=5mm] {angle=R--A--O}
    ;

  \end{tikzpicture}
\end{document}

角度

然后,您可以更改angle radius和/或angle eccentricity调整标记的位置。有关详细信息,请参阅第 519 页第 39 节(角度库)。

编辑2

或者,你可以做这样的事情:

\path
  (135:2.5mm) node [xshift=-1mm] {$\scriptstyle{z_{1}}$}
  (45:2.5mm) node {$\scriptstyle{z_{2}}$}
  (-45:2.5mm) node [xshift=1.5mm] {$\scriptstyle{z_{3}}$}
  (-135:2.5mm) node {$\scriptstyle{z_{4}}$}
  ;

调整角度

相关内容