我有以下代码,可在绘制的每一行左侧添加文本。如何使文本显示在右侧?谢谢。
\begin{center}
\begin{tikzpicture}[auto]
\node (Q1) at (1,1) {\(\mathbb{Q}\)};
\node (Q2) at (1,3) {\(\mathbb{Q}(\sqrt[3]{2})\)};
\node (Q3) at (1,5) {\(\mathbb{Q}(\sqrt[3]{2},\alpha)\)};
\draw[-] (Q1) to node {basis\(\{1,\sqrt[3]{2},(\sqrt[3]{2})^2\}\)} (Q2);
\draw[-] (Q2) to node {basis\(\{1,\alpha\}\)} (Q3);
\end{tikzpicture}
\end{center}
答案1
您可以将其用作[right]
节点的选项。此外,=distance
您还可以精确设置到线的距离:
\documentclass{article}
\usepackage{tikz}
\usepackage{amssymb}
\begin{document}
\begin{center}
\begin{tikzpicture}[auto]
\node (Q1) at (1,1) {\(\mathbb{Q}\)};
\node (Q2) at (1,3) {\(\mathbb{Q}(\sqrt[3]{2})\)};
\node (Q3) at (1,5) {\(\mathbb{Q}(\sqrt[3]{2},\alpha)\)};
\draw[-] (Q1) to node[right=0.2cm] {basis\(\{1,\sqrt[3]{2},(\sqrt[3]{2})^2\}\)} (Q2);
\draw[-] (Q2) to node[right=0.2cm] {basis\(\{1,\alpha\}\)} (Q3);
\end{tikzpicture}
\end{center}
\end{document}