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

Skip backslash escape in some blocks for Latex #734

Open
hegwin opened this issue Feb 23, 2023 · 0 comments
Open

Skip backslash escape in some blocks for Latex #734

hegwin opened this issue Feb 23, 2023 · 0 comments

Comments

@hegwin
Copy link

hegwin commented Feb 23, 2023

Hi!

I'm writing my blog with redcarpet to render Markdown and Ketax (a JS lib) to render Latex. Redcarpet comes first at backend, then Ketax renders after HTML is rendered

I met some issue for writing multiple line equations. For example:

I wrote this; The \\ means a line break in the formula:

\begin{align*}
  I_n &= \int_{0}^{\frac{\pi}{2}} \sin^n{x} dx \\
  &= \sin{x} \cdot \sin^{n-1}{x}
\end{align*}

Expected:

Screen Shot 2023-02-23 at 10 16 48 PM

Actual: as \ is used to escape chars in redcarpet, the two \\ became one \, so it becomes

Screen Shot 2023-02-23 at 10 19 21 PM

Workaround

In order to make it work, I have to use three \\\ or four \\\\ to make it render two \\:

\begin{align*}
  I_n &= \int_{0}^{\frac{\pi}{2}} \sin^n{x} dx \\\
  &= \sin{x} \cdot \sin^{n-1}{x}
\end{align*}

or

\begin{align*}
  I_n &= \int_{0}^{\frac{\pi}{2}} \sin^n{x} dx \\\\
  &= \sin{x} \cdot \sin^{n-1}{x}
\end{align*}

However, this is just a workaround; Because two \\ is standard in Latex, it works globally, I have to manually add extra \ to make it work together with redcarpet.

Question

  1. Is it possible to stop \ escaping under some conditions: for example between \begin and \end?

  2. Otherwise, I can use some extra symbols to isolate them. I can use $$$ to wrap all Latex thing like:

$$$
\begin{align*}
  I_n &= \int_{0}^{\frac{\pi}{2}} \sin^n{x} dx \\
  &= \sin{x} \cdot \sin^{n-1}{x}
\end{align*}
$$$

Is there any way I can make $$$ work like three ```s? Just wrap it with a <p> and keep everything as-is.

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

1 participant