Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol-based escape codes for special characters in markdown to TeX #2880

Closed
ashiklom opened this issue Apr 28, 2016 · 3 comments
Closed

Symbol-based escape codes for special characters in markdown to TeX #2880

ashiklom opened this issue Apr 28, 2016 · 3 comments

Comments

@ashiklom
Copy link

ashiklom commented Apr 28, 2016

LaTeX special character escape codes don't work if the codes are based on symbols rather than letters in the conversion of Markdown to TeX.

In other words, the following Markdown...

Rendered correctly:  

* Hungarian umlaut -- \H{o}
* slashed o -- \o
* tie over -- \t{oo}
* barred l -- \l
* cedilla -- \c{c}
* ogonek -- \k{a}
* dot under -- \d{o}
* ring over -- \r{a}
* breve over -- \u{o}
* caron over -- \v{s}
* bar under -- \b{b}

Rendered incorrectly:

* Grave accent -- \`{o}
* Acute accent -- '{o}
* Circumflex -- \^{o}
* Umlaut -- \"{o}
* Tilde -- \~{n}
* macron -- \={o}
* dot over -- \.{o}

...produces the following TeX output...

Rendered correctly:

  Hungarian umlaut -- \H{o}
  slashed o -- \o
  tie over -- \t{oo}
  barred l -- \l
  cedilla -- \c{c}
  ogonek -- \k{a}
  dot under -- \d{o}
  ring over -- \r{a}
  breve over -- \u{o}
  caron over -- \v{s}
  bar under -- \b{b}

Rendered incorrectly:

  Grave accent -- `\{o\}
  Acute accent -- '\{o\}
  Circumflex -- \^{}\{o\}
  Umlaut -- "\{o\}
  Tilde -- \textasciitilde{}\{n\}
  macron -- =\{o\}
  dot over -- .\{o\}

Note that escape codes based on letters are always interpreted correctly, while escape codes based on symbols always fail.

This also naturally propagates to PDFs generated by the default latex engine.

@jgm
Copy link
Owner

jgm commented Apr 28, 2016

This isn't a bug, I think.

Pandoc's Markdown tries to pass on things it recognizes as
LaTeX commands. But backslash-escaping of symbols takes
precedence over this -- as it should, since it's essential
that there be ways of escaping any special markup. So
the LaTeX commands that have the form BACKSLASH +
PUNCTUATION CHARACTER will not be interpreted as LaTeX,
but rather as an escaped punctuation character.

If you want to force interpretation as LaTeX, you can create
a \wrap macro and wrap them:

\newcommand[1]{\wrap}{#1}

\wrap{\'{o}}

Though I suspect it's less work simply to use the unicode
character!

+++ Alexey Shiklomanov [Apr 27 16 20:42 ]:

[1]LaTeX special character escape codes don't work if the codes are
based on symbols rather than letters in the conversion of LaTeX to
Markdown.

In other words, the following Markdown...
Rendered correctly:

  • Hungarian umlaut -- \H{o}
  • slashed o -- \o
  • tie over -- \t{oo}
  • barred l -- \l
  • cedilla -- \c{c}
  • ogonek -- \k{a}
  • dot under -- \d{o}
  • ring over -- \r{a}
  • breve over -- \u{o}
  • caron over -- \v{s}
  • bar under -- \b{b}

Rendered incorrectly:

  • Grave accent -- `{o}

  • Acute accent -- '{o}

  • Circumflex -- ^{o}

  • Umlaut -- "{o}

  • Tilde -- ~{n}

  • macron -- ={o}

  • dot over -- .{o}

    ...produces the following TeX output...
    Rendered correctly:

    Hungarian umlaut -- \H{o}
    slashed o -- \o
    tie over -- \t{oo}
    barred l -- \l
    cedilla -- \c{c}
    ogonek -- \k{a}
    dot under -- \d{o}
    ring over -- \r{a}
    breve over -- \u{o}
    caron over -- \v{s}
    bar under -- \b{b}

Rendered incorrectly:

Grave accent -- `{o}
Acute accent -- '{o}
Circumflex -- ^{}{o}
Umlaut -- "{o}
Tilde -- \textasciitilde{}{n}
macron -- ={o}
dot over -- .{o}

Note that escape codes based on letters always render correctly, while
escape codes based on symbols always fail.

This also naturally propagates to PDFs generated by the default latex
engine.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or [2]view it on GitHub

References

  1. https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Escaped_codes
  2. Symbol-based escape codes for special characters in markdown to TeX #2880

@ashiklom
Copy link
Author

Thanks for the quick reply!

I didn't realize Pandoc automatically switches to xelatex if it detects unicode characters (at least, I think it does?) -- that's pretty awesome! 👍 I assumed I had to set it manually as an argument.

I'm also satisfied with the newcommand workaround -- that also worked like a charm!

I'll go ahead and close this, but mention your response in my related Stack Overflow question in case other people come across the same edge case.

@jgm
Copy link
Owner

jgm commented Apr 28, 2016

+++ Alexey Shiklomanov [Apr 27 16 21:27 ]:

Thanks for the quick reply!

I didn't realize Pandoc automatically switches to xelatex if it detects
unicode characters (at least, I think it does?) -- that's pretty

No, it doesn't. It just emits a warning suggesting you try
--latex-engine=xelatex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants