vscode-markdown-pdf icon indicating copy to clipboard operation
vscode-markdown-pdf copied to clipboard

how to export pdf with latex

Open AnubisYe opened this issue 7 years ago • 22 comments

Also I add the js


    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });
    </script>

in template.html, can export correct html ,but not pdf

AnubisYe avatar Apr 10 '17 01:04 AnubisYe

Markdown+Math (https://github.com/goessner/mdmath) uses KaTex (https://khan.github.io/KaTeX/) to format markdown with latex to html5. Would be nice to have this in markdown-pdf as an optional pre-processing step before node-html-pdf (https://github.com/marcbachmann/node-html-pdf).

ThomasBeauduin avatar Jun 11 '17 04:06 ThomasBeauduin

+1 for KaTeX support.

I also use the extension vscode-markdown that supports KaTeX, so it'd be nice to implement it into vscode-markdown-pdf, especially since the only export option vscode-markdown has is to html.

Update: It looks like this was implemented in #36 but there are conflicts preventing it from being merged.

brandoningli avatar Jul 14 '18 05:07 brandoningli

I just insert $\sum_{i=0}^{n}i^2$ ,after the show of the plugin "Markdown All in One", it revievs good. re But this plugin can not print it, it just print "$\sum_{i=0}^{n}i^2$"

Yeba avatar Jul 30 '18 08:07 Yeba

How can I use Latex-format showed in pdf via markdown-pdf? If I can't get pdf with Latex-format, that means I need to download another export prog, which means markdown-pdf is not useful enough.

HsunGong avatar Sep 22 '18 03:09 HsunGong

Any updates? Still the same problem with V1.2

blackTay avatar Dec 28 '18 17:12 blackTay

Add it, end of the your markdown (.md) file to generate PDF with latex

Also I add the js

    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });
    </script>

in template.html, can export correct html ,but not pdf

yemreak avatar May 20 '19 15:05 yemreak

Also I add the js

    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });
    </script>

in template.html, can export correct html ,but not pdf

I have found a problem. Some of the equation symbols are not recognized when exporting to either html or PDF, e.g. $\bar{a}$.

jiang-du avatar Oct 18 '19 04:10 jiang-du

Yeah this is fixed by editing /Users/<username>/.vscode/extensions/yzane.markdown-pdf-1.4.1/template/template.html.

Just add these 2 lines at the bottom of the file, and it should be able to export to pdf.

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });</script>

shivgodhia avatar Nov 22 '19 16:11 shivgodhia

Yeah this is fixed by editing /Users/<username>/.vscode/extensions/yzane.markdown-pdf-1.4.1/template/template.html.

Just add these 2 lines at the bottom of the file, and it should be able to export to pdf.

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });</script>

I can only get the inline formula converted correctly by doing this, the display formulas using '$$ $$' are still converted incorrectly.

LouvenYoung avatar Feb 01 '20 09:02 LouvenYoung

I have the same problem: some '$$ ...... $$' are still converted incorrectly. CANNOT convert '\' to newline

liuxiang0 avatar Feb 02 '20 15:02 liuxiang0

This is developed for github md files, it also works with markdown-pdf : (1) type in you formula here: link, without $$ signs, coy the output in the markdown file (2) You get something like this:

f(x) = x^2

I know this is a makeshift solution but it does the job.

Mekahou avatar Apr 15 '20 03:04 Mekahou

guys, have you ever tried this solution on matrix? they still seem not printed correctly

$$R_y(\theta)=\begin{bmatrix}cos\theta&0&sin\theta\ 0&1&0\ -sin\theta&0&cos\theta\ \end{bmatrix}$$ and it previews as image and it printed as image

VEWOXIC avatar Aug 21 '20 11:08 VEWOXIC

guys, have you ever tried this solution on matrix? they still seem not printed correctly

$$R_y(\theta)=\begin{bmatrix}cos\theta&0&sin\theta
0&1&0
-sin\theta&0&cos\theta
\end{bmatrix}$$ and it previews as image and it printed as image

Try \\ at the end of each row instead of \. It might work

Mekahou avatar Aug 21 '20 18:08 Mekahou

guys, have you ever tried this solution on matrix? they still seem not printed correctly

$$R_y(\theta)=\begin{bmatrix}cos\theta&0&sin\theta
0&1&0
-sin\theta&0&cos\theta
\end{bmatrix}$$ and it previews as image and it printed as image

I have the same problem. Seems like the extension dosen't support multi-line formula?

Sumsky21 avatar Oct 28 '20 17:10 Sumsky21

guys, have you ever tried this solution on matrix? they still seem not printed correctly

$$R_y(\theta)=\begin{bmatrix}cos\theta&0&sin\theta 0&1&0 -sin\theta&0&cos\theta \end{bmatrix}$$ and it previews as image and it printed as image

I have the same problem. Seems like the extension dosen't support multi-line formula?

Hi, I used //// at the end of each row instead of //. it works in the output of PDF.

$$ R_y(\theta)= \begin{bmatrix} cos\theta&0&sin\theta\\ 0&1&0\\ -sin\theta&0&cos\theta \end{bmatrix} $$

GeorgeWildboarman avatar Feb 06 '21 01:02 GeorgeWildboarman

I have a similer problem

$$D^2_N = \left\{\begin{array}{c}
    D^2_{N-1} + 2D_{N-1} + 1\\
    or\\
    D^2_{N-1} - 2D_{N-1} + 1
\end{array}\right. \tag{6.7}$$

preview is preview

pdf is pdf

ichisemasashi avatar Mar 26 '21 17:03 ichisemasashi

Awesome!

WenboKou avatar May 02 '21 14:05 WenboKou

guys, have you ever tried this solution on matrix? they still seem not printed correctly

$$R_y(\theta)=\begin{bmatrix}cos\theta&0&sin\theta 0&1&0 -sin\theta&0&cos\theta \end{bmatrix}$$ and it previews as image and it printed as image

I have the same problem. Seems like the extension dosen't support multi-line formula?

Hi, I used //// at the end of each row instead of //. it works in the output of PDF.

$$ R_y(\theta)= \begin{bmatrix} cos\theta&0&sin\theta\ 0&1&0\ -sin\theta&0&cos\theta \end{bmatrix} $$

Thanks !! It worked well for me !!

shimamorieiki avatar Nov 22 '21 01:11 shimamorieiki

Also I add the js

    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });
    </script>

in template.html, can export correct html ,but not pdf

That worked for me.

juanmamaffei avatar Mar 04 '22 20:03 juanmamaffei

Also I add the js

    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });
    </script>

in template.html, can export correct html ,but not pdf

Cannot print \{ and \} in Katex.

The formula of Katex in Markdown

$$
E_{CFG} = \{ \langle G \rangle | G \text{ is a CFG and } L(G) = \emptyset \}
$$

Preview of VSCode

image

Result of PDF

As we can see, \{ and \} disappear.

image

hwhsu1231 avatar Apr 28 '22 10:04 hwhsu1231

Also I add the js

    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });
    </script>

in template.html, can export correct html ,but not pdf

Cannot print \{ and \} in Katex.

The formula of Katex in Markdown

$$
E_{CFG} = \{ \langle G \rangle | G \text{ is a CFG and } L(G) = \emptyset \}
$$

Preview of VSCode

image

Result of PDF

As we can see, \{ and \} disappear.

image


This also solved by adding '\' one more time I don't know how to solve VSCode Preview but it works in PDF

MD code (1)

$$
D^2_N = \left\\{\begin{array}{c}
D^2_{N-1} + 2D_{N-1} + 1 = 10\\\\
or\\\\
D^2_{N-1} - 2D_{N-1} + 1 = 20\\
\end{array}\right.
\tag{6.7}
$$

Previous of VSCode (1)

image

Result of PDF (1)

image

MD code (2)

$$
E_{CFG} = \\{ \langle G \rangle | G \text{ is a CFG and } L(G) = \emptyset \\}
$$

Previous of VSCode (2)

image

Result of PDF (2)

image

@ichisemasashi @hwhsu1231

miercat0424 avatar Nov 13 '22 15:11 miercat0424

I've already managed to export PDF with latex formula(I added the javascript code to the html document and thank god it worked), but only by default conversion mode. When I tried to implement another style, say Turing Style(a document which codes this format and was downloaded on Typora webpage), I can only get a PDF document IN STYLE but Latex lines unrecognized.

image

How can I fix this?

HippoGrasshopper avatar Mar 01 '24 07:03 HippoGrasshopper