%20%E4%BE%86%E8%AE%8A%E6%9B%B4%20pgfplots%20%E4%B8%AD%E8%BB%B8%E3%80%81%E6%A8%99%E7%B1%A4%E7%AD%89%E7%9A%84%E5%AD%97%E9%AB%94%EF%BC%9F.png)
我需要將字體Garamond
應用於軸和標籤以及nodes
.
這是我的MWE
:
\documentclass[12pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{fontspec}
\setmainfont{Garamond}
\begin{document}
\pgfplotsset{every axis/.append style={
line width=.5 pt,
tick style={line width=.6pt}}}
\begin{tikzpicture}
\begin{axis}[
clip mode=individual,
height=8cm,
width=10cm,
xmin=1.9,
ymin=0,
ymax=0.5,
enlarge x limits=.0,
enlarge y limits=.02,
ylabel={YLABEL},
xlabel={XLABEL},
minor x tick num=4,
minor y tick num=4,
tick label style={/pgf/number format/fixed},
every node near coord/.append style={font=\tiny},
]
\addplot[black,dashed] coordinates {(0,0) (3.4,.49)};
\addplot[black,dashed] coordinates {(0,0) (3.44,.44)};
\node[] at (axis cs: 2.7,0.2) {Text with Garamond font 1 2 3 4 5 6 7 8 9 0};
\end{axis}
\end{tikzpicture}
\end{document}
這是輸出:
中的文字node
使用字體列印Garamond
,但軸和標籤沒有改變。
解決這個問題的簡單方法是什麼?
答案1
查看兩個標記位元(否則預設情況下,tic 標籤設定為數學模式)
\documentclass[12pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{fontspec}
\usepackage{ebgaramond}%<=== think you needed this - you presumably have the font locally otherwise
\begin{document}
\pgfplotsset{every axis/.append style={
line width=.5 pt,
tick style={line width=.6pt}}}
\begin{tikzpicture}
\begin{axis}[
clip mode=individual,
height=8cm,
width=10cm,
xmin=1.9,
ymin=0,
ymax=0.5,
enlarge x limits=.0,
enlarge y limits=.02,
ylabel={YLABEL},
xlabel={XLABEL},
minor x tick num=4,
minor y tick num=4,
tick label style={/pgf/number format/assume math mode=true},%<=== this is what you need
every node near coord/.append style={font=\tiny},
]
\addplot[black,dashed] coordinates {(0,0) (3.4,.49)};
\addplot[black,dashed] coordinates {(0,0) (3.44,.44)};
\node[] at (axis cs: 2.7,0.2) {Text with Garamond font 1 2 3 4 5 6 7 8 9 0};
\end{axis}
\end{tikzpicture}
\end{document}