Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Newlines should not be scaped when using setting usetex=True #29628

Open
Labels
Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesDifficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuestopic: text/usetex
@juanep97

Description

@juanep97

The documentation mentions this behavior, but only as a passing note in the middle of the tutorial.

.. note::
For consistency with the non-usetex case, Matplotlib special-cases newlines,
so that single-newlines yield linebreaks (rather than being interpreted as
whitespace in standard LaTeX).
Matplotlib uses the underscore_ package so that underscores (``_``) are
printed "as-is" in text mode (rather than causing an error as in standard
LaTeX). Underscores still introduce subscripts in math mode.

When passing slightly complex latex code to matplotlib, a user might be tempted to use multi-line strings, and the error that matplotlib produces is quite cryptic. For example,

ax.annotate(text=r"""\begin{tabular}{cc}        a & b \\        c & d    \end{tabular}""",xy=(0.5,0.5),xycoords="figure fraction",xytext=(0,0))

produces

RuntimeError: latex was not able to process the following string: b'\\\\begin{tabular}{cc} '

I think it would be better to fix this behavior, but if not, it would be nice to give more visibility to it or include it in thetroubleshooting at the end of the same page, at least.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesDifficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuestopic: text/usetex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp