Markdown-preview-enhanced: How to use tikz latex code in markdown?

Created on 24 Nov 2017  ·  7Comments  ·  Source: shd101wyy/markdown-preview-enhanced

Hi...was trying use tikz latex code snippet in markdown. I followed the instructions provided in the package-manual, but the diagram is not generated.

Below is the sample markdown

# Hello

This is the body of the text

Figure is below...

```latex {cmd=true hide=true}
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
  \matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
  {
     F & B \\
      & A \\};
  \path[-stealth]
    (m-1-1) edge node [above] {$\beta$} (m-1-2)
    (m-1-2) edge node [right] {$\rho$} (m-2-2)
    (m-1-1) edge node [left] {$\alpha$} (m-2-2);
\end{tikzpicture}
\end{document}

(Note: Here, while writing about the issue, I am not able to close the blockquote [```] in the above sample code properly)

Can you please guide where I am going wrong?

PS: I have installed pdf2svg

Most helpful comment

I just tried on my Ubuntu machine.
So I installed TexLive and pdf2svg:

sudo apt-get install texlive pdf2svg  texlive-latex-extra

Then I copied your code to my markdown file, pressed shift+enter to run the code chunk:

screenshot from 2017-11-29 22-06-56

All 7 comments

Do you have latex engine installed? Which operating system are you using?

https://www.latex-project.org/get/

Yes. I do have the complete texlive installed in Manjaro linux.

The above code works fine in a tex file when compiled. But when embedded in a markdown file, in the preview nothing comes up...

Did you press shift+enter (or ctrl+shift+enter) to run the code chunk?

I just tried on my Ubuntu machine.
So I installed TexLive and pdf2svg:

sudo apt-get install texlive pdf2svg  texlive-latex-extra

Then I copied your code to my markdown file, pressed shift+enter to run the code chunk:

screenshot from 2017-11-29 22-06-56

Oh! I had completely missed the magic spell shift+enter.

Now when i see the document package document, this command is mentioned at the beginning. But, I had just searched for latex & tikz and seen how to implement them. In these sections, shift+enter is not mentioned.

Excuse for this overlook. And thanks for your patience :)

Hi I know this is an old issue, but i tried running shift+enter but nothing happened. I'm also using an ubuntu machine. It's only formatting the code as latex

Was this page helpful?
0 / 5 - 0 ratings