Return the complete TeX source for processing a TeX string.
(cls, tex, fontsize)
| 206 | |
| 207 | @classmethod |
| 208 | def _get_tex_source(cls, tex, fontsize): |
| 209 | """Return the complete TeX source for processing a TeX string.""" |
| 210 | font_preamble, fontcmd = cls._get_font_preamble_and_command() |
| 211 | baselineskip = 1.25 * fontsize |
| 212 | return "\n".join([ |
| 213 | r"\RequirePackage{fix-cm}", |
| 214 | r"\documentclass{article}", |
| 215 | r"% Pass-through \mathdefault, which is used in non-usetex mode", |
| 216 | r"% to use the default text font but was historically suppressed", |
| 217 | r"% in usetex mode.", |
| 218 | r"\newcommand{\mathdefault}[1]{#1}", |
| 219 | font_preamble, |
| 220 | r"\usepackage[utf8]{inputenc}", |
| 221 | r"\DeclareUnicodeCharacter{2212}{\ensuremath{-}}", |
| 222 | r"% geometry is loaded before the custom preamble as ", |
| 223 | r"% convert_psfrags relies on a custom preamble to change the ", |
| 224 | r"% geometry.", |
| 225 | r"\usepackage[papersize=72in, margin=1in]{geometry}", |
| 226 | cls.get_custom_preamble(), |
| 227 | r"% Use `underscore` package to take care of underscores in text.", |
| 228 | r"% The [strings] option allows to use underscores in file names.", |
| 229 | _usepackage_if_not_loaded("underscore", option="strings"), |
| 230 | r"% Custom packages (e.g. newtxtext) may already have loaded ", |
| 231 | r"% textcomp with different options.", |
| 232 | _usepackage_if_not_loaded("textcomp"), |
| 233 | r"\pagestyle{empty}", |
| 234 | r"\begin{document}", |
| 235 | r"% The empty hbox ensures that a page is printed even for empty", |
| 236 | r"% inputs, except when using psfrag which gets confused by it.", |
| 237 | rf"\fontsize{{{fontsize}}}{{{baselineskip}}}%", |
| 238 | r"\ifdefined\psfrag\else\hbox{}\fi%", |
| 239 | rf"{{{fontcmd} {tex}}}%", |
| 240 | r"\end{document}", |
| 241 | ]) |
| 242 | |
| 243 | @classmethod |
| 244 | def make_tex(cls, tex, fontsize): |