Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
bilby
bilby
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 25
    • Issues 25
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 12
    • Merge Requests 12
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • lscsoft
  • bilbybilby
  • Issues
  • #482

Closed
Open
Opened May 02, 2020 by Marc Arene@marc.areneDeveloper

latex_plot_format error with \mathdefault{}

The new @latex_plot_format decorator, coming from the core.utils file, is very handy but it sometimes bugged some of my plots with the following error:

[...]
  File "/anaconda3/envs/hmc/lib/python3.7/site-packages/matplotlib/texmanager.py", line 307, in _run_checked_subprocess
    exc=exc.output.decode('utf-8')))
RuntimeError: latex was not able to process the following string:
b'$\\\\times\\\\mathdefault{10^{5}}\\\\mathdefault{}$'
[...]
! Undefined control sequence.
l.14 ...}{15.000000}{\sffamily $\times\mathdefault
                                                  {10^{5}}\mathdefault{}$}
[...]

This bit of latex string would appear at the top of an x/y-axis as shown in the image I attached.mathdefault_on_axis

I am not entirely sure whether this error is specific to my installation of python/latex but I don't think so. However I found a way around this thanks to this stackoverflow post. As explained there, "\mathdefault is a command defined in python, and not as a base command of Latex.". Hence the solution is to define this command in matplotlib's rcParams with:

rcParams['text.latex.preamble'] = r'\newcommand{\mathdefault}[1][]{}'

So I would add this line to the latex_plot_format() function.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: lscsoft/bilby#482