我需要制作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}