atom-community / markdown-preview-plus

Markdown Preview + Community Features
https://atom.io/packages/markdown-preview-plus
Other
370 stars 85 forks source link

Render raw latex in preview #453

Closed biocyberman closed 5 years ago

biocyberman commented 5 years ago

I have MPP version 3.8.0 in Atom 1.35, and I get math equations displayed correctly. But this chunk of latex does not render as expected (a picture should show up instead of echoing latex code). How do I get MPP to render the latex code as well? I understand that the preview is actually a live HTML document. So, there should be live Latex preview of some short for this to work.

FWIW, I am previewing with pandoc with default "Markdown Flavor": markdown-raw_tex+tex_math_single_backslash And I am generating PDF with pandoc: pandoc -o test.pdf test.md

---
title: Test Markdown and Raw latex
date: April 2019
author: Vang Le-Quy
geometry: "left=2cm,right=2cm,top=2cm,bottom=2cm"
numbersections: true
header-includes:
  - \usepackage{graphicx}
output: pdf_document
---

# Markdown header, test with latex picture
This is normal markdown text
$y=x^2$

\begin{center}
\includegraphics[width=250pt]{images/test.png}
\begin{figure}[!h]
\caption{Test Image}
\end{figure}
\end{center}

Normal text again.

Screenshot 2019-04-02 at 12 16 06

lierdakil commented 5 years ago

Hello. MPP doesn't support raw LaTeX unfortunately. To be fair, Markdown doesn't either. Math is rendered using MathJax, which only handles math specifically.

Depending on your requirements, you could get away with using just Markdown syntax. For instance, captioned figures can be represented using Markdown image syntax. For more involved applications, you might want to use a more rich Markdown dialect, like, for instance Pandoc Markdown. MPP supports using pandoc as a rendering engine, and you can use pandoc filters as well (although position synchronisation only works well with markdown-it renderer).

If you really need LaTeX, then Atom has packages that work with it specifically, including a preview (not live though) etc.

вт, 2 апр. 2019 г., 13:18 Vang Le notifications@github.com:

I have MPP version 3.8.0 in Atom 1.35, and I get math equations displayed correctly. But this chunk of latex does not render as expected (a picture should show up instead of echoing latex code). How do I get MPP to render the latex code as well? I understand that the preview is actually a live HTML document. So, there should be live Latex preview of some short for this to work.


title: Test Markdown and Raw latex date: April 2019 author: Vang Le-Quy geometry: "left=2cm,right=2cm,top=2cm,bottom=2cm" numbersections: true header-includes:

  • \usepackage{graphicx} output: pdf_document

Markdown header, test with latex picture

This is normal markdown text $y=x^2$

\begin{center} \includegraphics[width=250pt]{images/test.png} \begin{figure}[!h] \caption{Test Image} \end{figure} \end{center}

Normal text again.

[image: Screenshot 2019-04-02 at 12 16 06] http://url

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/atom-community/markdown-preview-plus/issues/453, or mute the thread https://github.com/notifications/unsubscribe-auth/AG8EZqQw3IhB9-d1ppGM9n5eRDFrJViCks5vcy5ngaJpZM4cXqz7 .

lierdakil commented 5 years ago

To be clear: pandoc doesn't handle LaTeX in Markdown either -- with +raw_tex it just passes raw TeX through. This obviously works if you're targeting LaTeX or PDF via LaTeX, but not in any other output formats.

lierdakil commented 5 years ago

That said, you could concievably write a pandoc filter to convert some subset of LaTeX into HTML.

biocyberman commented 5 years ago

Using latex is my last resort for the lack of markdown's figure positioning. I can not use HTML because my final output is mainly PDF. It's just a quick check if some configuration tricks can help. But if it takes more than that, I will live with it for now.