MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _usepackage_if_not_loaded

Function _usepackage_if_not_loaded

lib/matplotlib/texmanager.py:38–52  ·  view source on GitHub ↗

Output LaTeX code that loads a package (possibly with an option) if it hasn't been loaded yet. LaTeX cannot load twice a package with different options, so this helper can be used to protect against users loading arbitrary packages/options in their custom preamble.

(package, *, option=None)

Source from the content-addressed store, hash-verified

36
37
38def _usepackage_if_not_loaded(package, *, option=None):
39 """
40 Output LaTeX code that loads a package (possibly with an option) if it
41 hasn't been loaded yet.
42
43 LaTeX cannot load twice a package with different options, so this helper
44 can be used to protect against users loading arbitrary packages/options in
45 their custom preamble.
46 """
47 option = f"[{option}]" if option is not None else ""
48 return (
49 r"\makeatletter"
50 r"\@ifpackageloaded{%(package)s}{}{\usepackage%(option)s{%(package)s}}"
51 r"\makeatother"
52 ) % {"package": package, "option": option}
53
54
55class TexManager:

Callers 1

_get_tex_sourceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…