pgfplot の目盛りとラベルに同じフォントを使用するにはどうすればよいでしょうか?

pgfplot の目盛りとラベルに同じフォントを使用するにはどうすればよいでしょうか?

私は、pgf プロット内の可能なすべての場所で同じフォントを使用しようとします。このフォーラムで何時間も過ごし、書面による解決策を試しましたが、わかりません。

ご協力をよろしくお願いいたします。

よろしく、Th。

\documentclass{scrartcl}

\usepackage{fontspec}
\setmainfont{Arial}

\usepackage{etoolbox}
% change fonts to sans serif then `tikzpicture' environment is started
\BeforeBeginEnvironment{tikzpicture}{
    \begingroup
        \changeFonts
}
% end scope (for font change)
\AfterEndEnvironment{tikzpicture}{
    \endgroup
}
\usepackage{sansmath}
% create a command to switch fonts in `tikzpicture' environments to a
% sans serif font
\newcommand*\changeFonts{
   \sffamily\sansmath
}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

10 <> $\mathsf 10$!

\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}[xlabel={Abscissa, $x_\mathsf{10}$}, ylabel={Ordinate, $y$}]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\caption{A figure with a \texttt{pgfplots} axis.}
\end{figure}

\end{document}

答え1

すべての目盛りラベルのフォントをサンセリフに変更するには、

\pgfplotsset{my style/.append style={xticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$},

 yticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$} } }

次にmy style軸オプションを追加します:

begin{axis}[my style, xlabel={Abscissa, $x_\mathsf{10}$}, ylabel={Ordinate, $y$}]

関連情報