TikZ 節點形狀取決於內部文本

TikZ 節點形狀取決於內部文本

我之前的答案之一,我的第一個建議

\documentclass[tikz]{standalone}
\usetikzlibrary{quotes,angles}
\begin{document}
\begin{tikzpicture}
\draw (0,-4)--(0,4) node[above] {$Im$} (-4,0)--(4,0) node[right] {$Re$};
\draw[dashed] (0,0) circle (3) circle (2);
\coordinate (a) at (80:3);
\coordinate (b) at (3,0);
\coordinate (m) at (25:2);
\coordinate (n) at (-95:2);
\coordinate (p) at (145:2);
\coordinate (o) at (0,0);
\fill[black] (a) circle (2pt) (b) circle (2pt) (m) circle (2pt) (n) circle (2pt) (p) circle (2pt) (2,0) circle (2pt);
\draw (a) node[above right] {$z=|z|e^{i\theta}$};
\draw (b) node[below] {$|z|$};
\draw (2,0) node[below] {$|z|^{1/3}$};
\draw (m) node[right] {$|z|^{1/3}e^{i\theta/3}$};
\draw (n) node[below] {$|z|^{1/3}e^{i(\theta+4\pi)/3}$};
\draw (p) node[above] {$|z|^{1/3}e^{i(\theta+2\pi)/3}$};
\draw (.1,1.5)--(0,1.5) node[left] {$i$};
\draw (1.5,.1)--(1.5,0) node[below] {$1$};
\draw (0,0)--(a) (0,0)--(m) (0,0)--(n) (0,0)--(p);
\draw[dashed] (m)--(n)--(p)--cycle;
\pic[draw,dashed,thick,"$\theta$",angle radius=0.8cm,angle eccentricity=1.3] {angle=b--o--a};
\end{tikzpicture}
\end{document}

給出這個輸出

看到讀取某些節點有點困難(例如 |z| 1/3e(θ+ 2π)/3 one),我重新定義inner sep並設定fill節點的顏色。最終我得到

\documentclass[tikz]{standalone}
\usetikzlibrary{quotes,angles,positioning}
\begin{document}
\begin{tikzpicture}
\begin{scope}[every node/.style={fill=white,inner sep=2pt}]
\draw (0,-4)--(0,4) node[above] {$\Im$} (-4,0)--(4,0) node[right] {$\Re$};
\draw[dashed] (0,0) circle (3) circle (2);
\coordinate (a) at (80:3);
\coordinate (b) at (3,0);
\coordinate (m) at (80/3:2);
\coordinate (n) at ({80/3-120}:2);
\coordinate (p) at ({80/3+120}:2);
\coordinate (o) at (0,0);
\draw (a) node[above right] {$z=|z|e^{i\theta}$};
\draw (b) node[below right] {$|z|$};
\draw (2,0) node[below left=0cm and -2em] {$|z|^{1/3}$};
\draw (m) node[right] {$|z|^{1/3}e^{i\theta/3}$};
\draw (n) node[below] {$|z|^{1/3}e^{i(\theta+4\pi)/3}$};
\draw (p) node[above] {$|z|^{1/3}e^{i(\theta+2\pi)/3}$};
\draw (.1,1.5)--(0,1.5) node[left] {$i$};
\draw (1.5,.1)--(1.5,0) node[below] {$1$};
\draw (0,0)--(a) (0,0)--(m) (0,0)--(n) (0,0)--(p);
\draw[dashed] (m)--(n)--(p)--cycle;
\end{scope}
\pic[draw,dashed,thick,"$\theta$",angle radius=0.8cm,angle eccentricity=1.3] {angle=b--o--a};
\fill[black] (a) circle (2pt) (b) circle (2pt) (m) circle (2pt) (n) circle (2pt) (p) circle (2pt) (2,0) circle (2pt);
\end{tikzpicture}
\end{document}

恕我直言,節點和路徑的分離現在非常好,除了某些情況下分離過度:

解決方案是更改預設的矩形節點形狀

像這樣的事情

抱歉,我不擅長畫畫,尤其是用電腦滑鼠畫畫。

換句話說,我想我必須創造一個新的TikZ節點形狀取決於最大值和最小值"y-所有字符的座標」。

這對我來說太複雜了,我還沒有找到這方面的提示。

你能幫助我嗎?任何幫助深表感謝。

答案1

也許該contour包是您的解決方案(另請參閱這個答案)?

\documentclass[tikz, border=2mm]{standalone}

\usepackage[outline]{contour}
\contourlength{2pt}  % increase the white space

\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
\draw [step=.25] (-2,-.5) grid (2,.5);

\node[] at (0,0) {\contour{white}{$|z|^{1/3}e^{i(\theta+2\pi)/3}$}};

\end{tikzpicture}

\end{document}

在此輸入影像描述


筆記:以上不適用於 XeLaTeX 或 LuaLaTeX。在這種情況下,您需要刪除該outline選項並添加例如\contournumber{60}(或更高的數字,具體取決於空白邊緣所需的平滑度,請參閱包的文檔)。

相關內容