{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5076","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5076/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5076/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5076/events","html_url":"https://github.com/matplotlib/matplotlib/issues/5076","id":106577760,"number":5076,"title":"RuntimeError: LaTeX was not able to process the following string: 'z=$\\\\\\\\mathregular{{}^{}_{\\\\\\\\}}$' in matplotlib","user":{"login":"neuronphysics","id":6558617,"avatar_url":"https://avatars.githubusercontent.com/u/6558617?v=3","gravatar_id":"","url":"https://api.github.com/users/neuronphysics","html_url":"https://github.com/neuronphysics","followers_url":"https://api.github.com/users/neuronphysics/followers","following_url":"https://api.github.com/users/neuronphysics/following{/other_user}","gists_url":"https://api.github.com/users/neuronphysics/gists{/gist_id}","starred_url":"https://api.github.com/users/neuronphysics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neuronphysics/subscriptions","organizations_url":"https://api.github.com/users/neuronphysics/orgs","repos_url":"https://api.github.com/users/neuronphysics/repos","events_url":"https://api.github.com/users/neuronphysics/events{/privacy}","received_events_url":"https://api.github.com/users/neuronphysics/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matplotlib/matplotlib/labels/text","name":"text","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/12","html_url":"https://github.com/matplotlib/matplotlib/milestones/proposed%20next%20point%20release%20(2.1)","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/12/labels","id":534144,"number":12,"title":"proposed next point release (2.1)","description":"Next feature release.\r\n\r\nBig ticket items:\r\n\r\n - MEP 22/27\r\n - traitlets","creator":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"open_issues":404,"closed_issues":238,"state":"open","created_at":"2014-01-13T03:21:09Z","updated_at":"2015-09-15T17:46:56Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-09-15T15:12:14Z","updated_at":"2015-09-15T18:55:50Z","closed_at":null,"body":"I have been trying to generate `Latex` style plots for publication by  \r\n\r\n    from __future__ import unicode_literals\r\n    import matplotlib\r\n    import matplotlib.pyplot as plt\r\n    import matplotlib.colors as mplcol\r\n    import matplotlib.cm as cmx\r\n    import numpy as np\r\n    plt.switch_backend('PS') \r\n    matplotlib.use('PS')\r\n    matplotlib.style.use('ggplot')\r\n    matplotlib.rcParams['axes.edgecolor']='black'\r\n    matplotlib.rcParams['axes.facecolor']= 'white'\r\n    matplotlib.rcParams['axes.grid']= False\r\n    matplotlib.rcParams['ytick.major.size']= 2\r\n    matplotlib.rcParams['ytick.minor.pad']= 0.05\r\n    matplotlib.rcParams['xtick.major.size']= 2\r\n    matplotlib.rcParams['xtick.minor.pad']= 0.25\r\n    matplotlib.rcParams['legend.frameon'] = False\r\n    matplotlib.rcParams['text.usetex']=True\r\n    matplotlib.rcParams['text.latex.unicode']=True\r\n    matplotlib.rcParams['ps.usedistiller']='xpdf'\r\n    matplotlib.rcParams['ps.distiller.res']= 9000\r\n    matplotlib.rcParams['savefig.dpi']= 500\r\n    value = \"{\" + str(round(r.value, 2)) + \"}\"\r\n    upper = \"{+\" + str(round(r.upper_error, 2)) + \"}\"\r\n    lower = \"{\\,-\" + str(round(r.lower_error, 2)) + \"}\"\r\n    # format this in a format LaTeX can parse. Use mathregular so that the\r\n    # font is the same as all the other fonts on the plot.\r\n    ext = r\"z=$\\mathregular{{{value}^{upper}_{lower}}}$\".format(\r\n            value=value, upper=upper, lower=lower)\r\n    save_as_one_pdf(figures, params[\"plot_directory\"] +\r\n                        self.name+'.pdf' )\r\n\r\nwhere I want to plot different figures in multiple pages with this function:\r\n\r\n    def save_as_one_pdf(figs, filename):\r\n        \"\"\"\r\n        Save the figures into one long PDF file\r\n\r\n        :param figs: list of figures to be saved as PDFs\r\n        :param filename: place where the PDFs will be saved\r\n        :return: none\r\n        \"\"\"\r\n\r\n        # Save the pdfs as one file\r\n        pp = PdfPages(filename)\r\n        for fig in figs:\r\n            pp.savefig(fig)\r\n        pp.close()\r\n        for fig in figs:\r\n            plt.close(fig)\r\n\r\nBut when I ran my script I've got the following errors:\r\n\r\n\r\n     File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2431, in savefig\r\n        figure.savefig(self, format='pdf', **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py\", line 1476, in savefig\r\n        self.canvas.print_figure(*args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py\", line 2211, in print_figure\r\n        **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2485, in print_pdf\r\n        self.figure.draw(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py\", line 1085, in draw\r\n        func(*args)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.py\", line 2110, in draw\r\n        a.draw(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py\", line 595, in draw\r\n        bbox, info, descent = self._get_layout(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py\", line 320, in _get_layout\r\n        ismath=ismath)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2044, in get_text_width_height_descent\r\n        renderer=self)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py\", line 670, in get_text_width_height_descent\r\n        dvifile = self.make_dvi(tex, fontsize)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py\", line 417, in make_dvi\r\n        report))\r\n    RuntimeError: LaTeX was not able to process the following string:\r\n    'z=$\\\\\\\\mathregular{{0.27}^{+0.01}_{\\\\\\\\,-0.01}}$'\r\n    Here is the full report generated by LaTeX: \r\n    \r\n    This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)\r\n     restricted \\write18 enabled.\r\n    entering extended mode\r\n    (./384610b05118db25834f6dd15bc90717.tex\r\n    LaTeX2e <2011/06/27>\r\n    Babel <3.9h> and hyphenation patterns for 62 languages loaded.\r\n    (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls\r\n    Document Class: article 2007/10/19 v1.4h Standard LaTeX document class\r\n    (/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))\r\n    (/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)\r\n    (/usr/share/texlive/texmf-dist/tex/latex/psnfss/helvet.sty\r\n    (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty))\r\n    (/usr/share/texlive/texmf-dist/tex/latex/psnfss/courier.sty)\r\n    (/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty\r\n    (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))\r\n    (/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty\r\n    (/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def))\r\n    (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty\r\n    (/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def))\r\n    (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty\r\n    (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)\r\n    (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)\r\n    (/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)\r\n    \r\n    Package geometry Warning: Over-specification in `h'-direction.\r\n        `width' (5058.9pt) is ignored.\r\n    \r\n    \r\n    Package geometry Warning: Over-specification in `v'-direction.\r\n        `height' (5058.9pt) is ignored.\r\n    \r\n    )\r\n    No file 384610b05118db25834f6dd15bc90717.aux.\r\n    (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)\r\n    (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pnc.fd)\r\n    (/usr/share/texlive/texmf-dist/tex/latex/ucs/ucsencs.def)\r\n    *geometry* driver: auto-detecting\r\n    *geometry* detected driver: dvips\r\n    (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1phv.fd)\r\n    ! Undefined control sequence.\r\n    <recently read> \\mathregular \r\n                                 \r\n    l.13 ...0000}{12.500000}{\\sffamily z=$\\mathregular\r\n                                                      {{0.27}^{+0.01}_{\\,-0.01}}$}\r\n    [1] (./384610b05118db25834f6dd15bc90717.aux) )\r\n    (see the transcript file for additional information)\r\n\r\neven after I changed the text to\r\n    text = r\"z=${value}^{upper}_{lower}$\".format(\r\n            value=value, upper=upper, lower=lower)\r\n\r\nI've got the following error:\r\n\r\n     File \"cluster.py\", line 762, in save_as_one_pdf\r\n        pp.savefig(fig)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2431, in savefig\r\n        figure.savefig(self, format='pdf', **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py\", line 1476, in savefig\r\n        self.canvas.print_figure(*args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py\", line 2211, in     print_figure\r\n    **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2485, in print_pdf\r\n        self.figure.draw(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n    draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py\", line 1085, in draw\r\n    func(*args)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.py\", line 2110, in draw\r\n    a.draw(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py\", line 1116, in draw\r\n    renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py\", line 1065, in _get_tick_bboxes\r\n    extent = tick.label1.get_window_extent(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py\", line 798, in get_window_extent\r\n        bbox, info, descent = self._get_layout(self._renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py\", line 311, in _get_layout\r\n    ismath=False)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2044, in get_text_width_height_descent\r\n    renderer=self)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py\", line 670, in get_text_width_height_descent\r\n    dvifile = self.make_dvi(tex, fontsize)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py\", line 417, in make_dvi\r\n    report))\r\n    RuntimeError: LaTeX was not able to process the following string:\r\n    'lp'\r\n    Here is the full report generated by LaTeX: \r\n\r\n    ! Package unicode-math Error: Cannot be run with pdfLaTeX!\r\n    (unicode-math)                Use XeLaTeX or LuaLaTeX instead..\r\n\r\n    See the unicode-math package documentation for explanation.\r\n    Type  H <return>  for immediate help.\r\n\r\nHow can I make this all work or avoid this error?\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/140499796","html_url":"https://github.com/matplotlib/matplotlib/issues/5076#issuecomment-140499796","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5076","id":140499796,"user":{"login":"neuronphysics","id":6558617,"avatar_url":"https://avatars.githubusercontent.com/u/6558617?v=3","gravatar_id":"","url":"https://api.github.com/users/neuronphysics","html_url":"https://github.com/neuronphysics","followers_url":"https://api.github.com/users/neuronphysics/followers","following_url":"https://api.github.com/users/neuronphysics/following{/other_user}","gists_url":"https://api.github.com/users/neuronphysics/gists{/gist_id}","starred_url":"https://api.github.com/users/neuronphysics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neuronphysics/subscriptions","organizations_url":"https://api.github.com/users/neuronphysics/orgs","repos_url":"https://api.github.com/users/neuronphysics/repos","events_url":"https://api.github.com/users/neuronphysics/events{/privacy}","received_events_url":"https://api.github.com/users/neuronphysics/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T18:55:50Z","updated_at":"2015-09-15T18:55:50Z","body":"\r\nWell, in the script I would get this error message\r\n\r\n      File \"/vol/rsz_irac_code/cluster.py\", line 335, in fit_z\r\n        self.name + \".pdf\")\r\n      File \"/vol/rsz_irac_code/cluster.py\", line 762, in save_as_one_pdf\r\n        pp.savefig(fig)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2431, in savefig\r\n        figure.savefig(self, format='pdf', **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py\", line 1476, in savefig\r\n        self.canvas.print_figure(*args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py\", line 2211, in print_figure\r\n        **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2485, in print_pdf\r\n        self.figure.draw(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/figure.py\", line 1085, in draw\r\n        func(*args)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.py\", line 2110, in draw\r\n        a.draw(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/artist.py\", line 59, in draw_wrapper\r\n        draw(artist, renderer, *args, **kwargs)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py\", line 1116, in draw\r\n        renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/axis.py\", line 1065, in _get_tick_bboxes\r\n        extent = tick.label1.get_window_extent(renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py\", line 798, in get_window_extent\r\n        bbox, info, descent = self._get_layout(self._renderer)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/text.py\", line 311, in _get_layout\r\n        ismath=False)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py\", line 2044, in get_text_width_height_descent\r\n        renderer=self)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py\", line 670, in get_text_width_height_descent\r\n        dvifile = self.make_dvi(tex, fontsize)\r\n      File \"/vol/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py\", line 417, in make_dvi\r\n        report))\r\n    RuntimeError: LaTeX was not able to process the following string:\r\n    'lp'\r\n\r\nand this warning at the beginning:\r\n\r\n     /vol/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:1318: UserWarning:  This call to matplotlib.use() has no effect\r\n     because the backend has already been chosen;\r\n     matplotlib.use() must be called *before* pylab, matplotlib.pyplot,\r\n     or matplotlib.backends is imported for the first time.\r\n    \r\n      warnings.warn(_use_error_msg)\r\n\r\n"}}