class_docstr: Convert strings to dvi files using TeX, caching the results to a directory.
  
  The cache directory is called ``tex.cache`` and is located in the directory
  returned by `.get_cachedir`.
  
  Repeated calls to this constructor always return the same instance.
class_docstr_tok: ["Convert","strings","to","dvi","files","using","TeX",",","caching","the","results","to","a","directory",".","The","cache","directory","is","called","``","tex.cache","``","and","is","located","in","the","directory","returned","by","`",".get_cachedir","`",".","Repeated","calls","to","this","constructor","always","return","the","same","instance","."]
docstr: Return the complete TeX source for processing a TeX string.
docstr_tok: ["Return","the","complete","TeX","source","for","processing","a","TeX","string","."]
code: def _get_tex_source(cls, tex, fontsize):
      """Return the complete TeX source for processing a TeX string."""
      font_preamble, fontcmd = cls._get_font_preamble_and_command()
      baselineskip = 1.25 * fontsize
      return "\n".join(
          [
              r"\documentclass{article}",
              r"% Pass-through \mathdefault, which is used in non-usetex mode",
              r"% to use the default text font but was historically suppressed",
              r"% in usetex mode.",
              r"\newcommand{\mathdefault}[1]{#1}",
              font_preamble,
              r"\usepackage[utf8]{inputenc}",
              r"\DeclareUnicodeCharacter{2212}{\ensuremath{-}}",
              r"% geometry is loaded before the custom preamble as ",
              r"% convert_psfrags relies on a custom preamble to change the ",
              r"% geometry.",
              r"\usepackage[papersize=72in, margin=1in]{geometry}",
              cls.get_custom_preamble(),
              r"% Use `underscore` package to take care of underscores in text.",
              r"% The [strings] option allows to use underscores in file names.",
              _usepackage_if_not_loaded("underscore", option="strings"),
              r"% Custom packages (e.g. newtxtext) may already have loaded ",
              r"% textcomp with different options.",
              _usepackage_if_not_loaded("textcomp"),
              r"\pagestyle{empty}",
              r"\begin{document}",
              r"% The empty hbox ensures that a page is printed even for empty",
              r"% inputs, except when using psfrag which gets confused by it.",
              r"% matplotlibbaselinemarker is used by dviread to detect the",
              r"% last line's baseline.",
              rf"\fontsize{{{fontsize}}}{{{baselineskip}}}%",
              r"\ifdefined\psfrag\else\hbox{}\fi%",
              rf"{{{fontcmd} {tex}}}%",
              r"\end{document}",
          ]
      )
  
imports: import functools
  import hashlib
  import logging
  import os
  from pathlib import Path
  import subprocess
  from tempfile import TemporaryDirectory
  import numpy
  import matplotlib
  from matplotlib import _api, cbook, dviread
label_desc: Use image node_id 7 for calling the TexManager obj's underlying member method code with example usage: obj._get_tex_source(cls, tex, fontsize) and returns: str