0

I have libertine as my base font. While using pgfplots to plot a graph, the axis labels do appear in the base font, but the tick label numbers revert to default computer modern. I have tried using tick label style={font=\normalfont} but no avail. How can I get the base font of the document on the tick label numbers?

MWE

\documentclass{article}

\usepackage{libertine}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture} \begin{axis} [xlabel={Time 123(s)} ,ylabel={Distance (in)}, tick label style={font=\normalfont}] \addplot [red,mark=*,line width=1.pt] coordinates { (1,0.25) (2,1) (3,2.25) (4,4) (5,6.25) (6,9) }; \end{axis} \end{tikzpicture}

\end{document}

enter image description here

Damitr
  • 1,889
  • 1
    From the proposed duplicate: tick label style={/pgf/number format/assume math mode=true}. – Marijn Apr 30 '21 at 13:30
  • Also consider to use centimeters instead of inches :) – Marijn Apr 30 '21 at 13:31
  • thanks for the reply, but why doesn't it choose the base font of the document, and defaults to cm? – Damitr May 01 '21 at 02:52
  • PGFPlots uses the math font by default for the tick numbers. The libertine package changes only the text font, but the math font remains as Computer Modern (try 123 $123$ somewhere in your document to confirm). The code that solves the issue (assume math mode=true) switches off math mode for the tick numbers, causing the text font to be used. Many font packages change only the text font, because the math font contains a lot of special characters that normal fonts don't provide so it would require many new characters to be designed in the style of the replacement font. – Marijn May 01 '21 at 08:11
  • 1
    Ok, thanks for the explanation. It is also resolved by using \usepackage{libertinust1math} so that default math font is set in libertine – Damitr May 07 '21 at 03:10

0 Answers0