@@ -1272,7 +1272,14 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
12721272 if orientation == 'landscape' : angle = 90
12731273 else : angle = 0
12741274
1275- print >> latexh , r"""\documentclass{article}
1275+ if rcParams ['text.latex.unicode' ]:
1276+ unicode_preamble = """\usepackage{ucs}
1277+ \usepackage[utf8x]{inputenc}"""
1278+ else :
1279+ unicode_preamble = ''
1280+
1281+ s = r"""\documentclass{article}
1282+ %s
12761283%s
12771284%s
12781285\usepackage[dvips, papersize={%sin,%sin}, body={%sin,%sin}, margin={0in,0in}]{geometry}
@@ -1288,8 +1295,21 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
12881295\includegraphics*[angle=%s]{%s}
12891296\end{figure}
12901297\end{document}
1291- """ % (font_preamble , custom_preamble , paperWidth , paperHeight , paperWidth , paperHeight ,
1292- '\n ' .join (psfrags ), angle , os .path .split (epsfile )[- 1 ])
1298+ """ % (font_preamble , unicode_preamble , custom_preamble , paperWidth , paperHeight ,
1299+ paperWidth , paperHeight ,
1300+ '\n ' .join (psfrags ), angle , os .path .split (epsfile )[- 1 ])
1301+
1302+ if rcParams ['text.latex.unicode' ]:
1303+ latexh .write (s .encode ('utf8' ))
1304+ else :
1305+ try :
1306+ latexh .write (s )
1307+ except UnicodeEncodeError , err :
1308+ verbose .report ("You are using unicode and latex, but have "
1309+ "not enabled the matplotlib 'text.latex.unicode' "
1310+ "rcParam." , 'helpful' )
1311+ raise
1312+
12931313 latexh .close ()
12941314
12951315 # the split drive part of the command is necessary for windows users with
0 commit comments