@@ -154,8 +154,7 @@ def get_font_config(self):
154154 self ._fonts ['monospace' ][1 ]]
155155 if self .font_family == 'cursive' :
156156 cmd .append (self ._fonts ['cursive' ][1 ])
157- self ._font_preamble = '\n ' .join (
158- [r'\usepackage{type1cm}' , * cmd , r'\usepackage{textcomp}' ])
157+ self ._font_preamble = '\n ' .join ([r'\usepackage{type1cm}' , * cmd ])
159158
160159 return '' .join (fontconfig )
161160
@@ -188,10 +187,16 @@ def _get_preamble(self):
188187 self ._font_preamble ,
189188 r"\usepackage[utf8]{inputenc}" ,
190189 r"\DeclareUnicodeCharacter{2212}{\ensuremath{-}}" ,
191- # Needs to come early so that the custom preamble can change the
192- # geometry, e.g. in convert_psfrags .
190+ # geometry is loaded before the custom preamble as convert_psfrags
191+ # relies on a custom preamble to change the geometry .
193192 r"\usepackage[papersize=72in,body=70in,margin=1in]{geometry}" ,
194193 self .get_custom_preamble (),
194+ # textcomp is loaded last (if not already loaded by the custom
195+ # preamble) in order not to clash with custom packages (e.g.
196+ # newtxtext) which load it with different options.
197+ r"\makeatletter"
198+ r"\@ifpackageloaded{textcomp}{}{\usepackage{textcomp}}"
199+ r"\makeatother" ,
195200 ])
196201
197202 def make_tex (self , tex , fontsize ):
0 commit comments