LatexExpr and apostrophe

asked 2022-11-10 12:18:25 +0200

Cyrille gravatar image

updated 2022-11-10 18:19:41 +0200

How to type set apostrophe in this context

show(LatexExpr(r'\text{L' élément}'))

obviously connot work. (I hope not to have already ask the question but I do not know how to find the answer)

edit retag flag offensive close merge delete

Comments

2

Use double quotes?

show(LatexExpr(r"\text{L' élément}"))
Max Alekseyev gravatar imageMax Alekseyev ( 2022-11-10 13:39:54 +0200 )edit
1

If you don't want to use double quotes, then you can "escape" the single quote with a backslash. This means not using the "r" prefix for the string, so that a backslash can still serve as an escape: LatexExpr('\\text{L\'élément}').

John Palmieri gravatar imageJohn Palmieri ( 2022-11-10 18:17:50 +0200 )edit
1

Another option is to use triple quotes: LatexExpr(r'''\text{L'élément}''') or LatexExpr(r"""\text{L'élément}"""). These are useful if you want to use both ' and " in the string.

John Palmieri gravatar imageJohn Palmieri ( 2022-11-10 18:19:16 +0200 )edit