Sub-issue of #50.
Problem
Matplotlib formats negative axis labels with U+2212 (−), which pdfLaTeX
rejects:
! Package inputenc Error: Unicode char \u8:− not set up for use with LaTeX.
Every string flowing through draw_text must normalize U+2212 → ASCII
-, plus other Unicode punctuation commonly produced by Matplotlib
formatters (en/em dashes, prime marks, non-breaking space).
Proposed fix
_UNICODE_FIXES = str.maketrans({
'\u2212': '-', # MINUS SIGN
'\u2013': '--', # EN DASH
'\u2014': '---', # EM DASH
'\u00a0': '~', # NO-BREAK SPACE
})
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
safe = s.translate(_UNICODE_FIXES)
body = f'${safe}$' if ismath else safe
self._commands.append(
rf'\node[anchor=base, rotate={angle:.1f}] at '
rf'({x*self.scale:.4f},{y*self.scale:.4f}) {{{body}}};'
)
Acceptance criteria
Sub-issue of #50.
Problem
Matplotlib formats negative axis labels with U+2212 (
−), which pdfLaTeXrejects:
Every string flowing through
draw_textmust normalize U+2212 → ASCII-, plus other Unicode punctuation commonly produced by Matplotlibformatters (en/em dashes, prime marks, non-breaking space).
Proposed fix
Acceptance criteria
without Unicode errors.
ismath=True) is wrapped in$...$; plain textis not.
−5 to 5 and asserts the emitted
.texcontains no U+2212.