如何在 Tikz 中为角度标签添加白色背景?

如何在 Tikz 中为角度标签添加白色背景?

我正在为一个项目绘制图表,但是由于 n 向量穿过角度标签,因此不太清晰,我想为 alpha 标签添加白色背景,以便更容易看到。谢谢,请参阅下面的 MWE。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes,arrows}

\begin{document}
\begin{figure}
        \begin{center}
        \begin{tikzpicture}
            %Define coordinates
            \coordinate (origin) at (0,0);
            \coordinate (bhat) at (0,5);
            \coordinate (zetahat) at (5,0);
            \coordinate (vector) at (3,4);
            \coordinate (normal) at (1.581,4.743);

            %Draw axes
            \draw[thick, <->] (bhat) node[above]{$\hat{b}$} -- (origin) -- (zetahat) node[right]{$\hat{\zeta}$};

            %Draw vector
            \draw[thick, ->, blue] (origin) -- (vector) node[above]{$\vec{v_r}$};

            %N vector
            \draw[thick, dotted, ->] (origin) -- (normal) node[above]{$\hat{n}$};

            %Draw angle
            \pic [draw, "$\alpha$", angle eccentricity = 1.2, angle radius = 1.5cm, thick] {angle = vector--origin--bhat};

        \end{tikzpicture}
        \caption{Pitch angle $\alpha$ is equal to $2\theta_{bn}$, showing specular reflection}
        \label{fig:Pitch Angle}
        \end{center}
    \end{figure}
\end{document}

答案1

使用"$\alpha$"{fill=white}"$\alpha$"不是\pic

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes,arrows}

\begin{document}
\begin{figure}
        \begin{center}
        \begin{tikzpicture}
            %Define coordinates
            \coordinate (origin) at (0,0);
            \coordinate (bhat) at (0,5);
            \coordinate (zetahat) at (5,0);
            \coordinate (vector) at (3,4);
            \coordinate (normal) at (1.581,4.743);

            %Draw axes
            \draw[thick, <->] (bhat) node[above]{$\hat{b}$} -- (origin) -- (zetahat) node[right]{$\hat{\zeta}$};

            %Draw vector
            \draw[thick, ->, blue] (origin) -- (vector) node[above]{$\vec{v_r}$};

            %N vector
            \draw[thick, dotted, ->] (origin) -- (normal) node[above]{$\hat{n}$};

            %Draw angle
            \pic [draw,  "$\alpha$"{fill=white}, angle eccentricity = 1.2, angle radius = 1.5cm, thick] {angle = vector--origin--bhat};

        \end{tikzpicture}
        \caption{Pitch angle $\alpha$ is equal to $2\theta_{bn}$, showing specular reflection}
        \label{fig:Pitch Angle}
        \end{center}
    \end{figure}
\end{document}

答案2

PSTricks 解决方案仅用于比较目的。单个*解决方案即可完成工作(使标签背景变得纯色)。

\documentclass[pstricks,12pt]{standalone}
\begin{document}
\pspicture(-1,-1)(6,6)
    \psline{<->}(0,5)(0,0)(5,0)
    \psline{->}(5;60)
    \psline[linestyle=dotted,dotsep=1pt]{->}(5;75)
    \uput[90](0,5){$\hat{b}$}
    \uput[0](5,0){$\hat{\zeta}$}
    \uput[60](5;60){$\vec{v}_r$}
    \uput[75](5;75){$\hat{n}$}
    \uput*{2.5}[75](0,0){$\alpha$}
    \psarc(0,0){2}{60}{90}
\endpspicture
\end{document}

enter image description here

相关内容