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

Include a markdown style mermaid diagram inside a LaTeX source #448

Open
anubane opened this issue Jun 11, 2024 · 1 comment
Open

Include a markdown style mermaid diagram inside a LaTeX source #448

anubane opened this issue Jun 11, 2024 · 1 comment
Labels
feature request plaintex Related to the plain TeX interface and implementation themes Related to Markdown themes

Comments

@anubane
Copy link

anubane commented Jun 11, 2024

I love to write in LaTeX for creating publish-quality documents. However, for quick note taking and diagramming, I prefer markdown due the the ease of use.

The problem that I face is how to include the diagrams I have made in markdown into my LaTeX source? To give a concrete example, consider the following two file:

  1. test.md
## This is a mindmap diagram
I use mindmap diagrams for aiding thought building. In mermaid I would write it like this:
```mermaid
mindmap
    root )base-idea(
        sub<br/>idea 1
            ((?))
        sub<br/>idea 2
            ((?))
        sub<br/>idea 3
            ((?))
        sub<br/>idea 4
            ((?))
```
  1. test.tex
\documentclass[a4paper]{article}
\usepackage[]{markdown}

\markdownSetup{}    % We can include 'mermaid' as a setup option?


\begin{document}
    \begin{markdown}
        ## This is a mindmap diagram
        I use mindmap diagrams for aiding thought building. In mermaid I would write it like this:
        ```mermaid
        mindmap
            root )base-idea(
                sub<br/>idea 1
                    ((?))
                sub<br/>idea 2
                    ((?))
                sub<br/>idea 3
                    ((?))
                sub<br/>idea 4
                    ((?))
        ```
    \end{markdown}
\end{document}

As of now, I am using latexmk command to compile my .tex file, and it is simply showing the mermaid code as, well, code.

How can I have the mermaid diagram render inside the LaTeX generated pdf?

@Witiko Witiko added feature request plaintex Related to the plain TeX interface and implementation labels Jun 11, 2024
@Witiko
Copy link
Owner

Witiko commented Jun 11, 2024

Hi and thanks for using the Markdown package. In order to add support for mermaid diagrams, you would need to run a command such as mmdc that would render each diagram, similar to how the theme witiko/dot typesets GraphViz diagrams:

image

See also the implementation of the theme witiko/dot and another example of how you would use it. Hopefully, you should be able to adapt it to mermaid diagrams with little effort. Please, feel free to ask if anything is unclear!

@Witiko Witiko added the themes Related to Markdown themes label Jun 12, 2024
@Witiko Witiko changed the title [Feature Request]: Include a markdown style mermaid diagram inside a LaTeX source Include a markdown style mermaid diagram inside a LaTeX source Jun 18, 2024
@Witiko Witiko modified the milestones: 3.8.0, 3.7.0 Jul 1, 2024
@Witiko Witiko removed this from the 3.7.0 milestone Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request plaintex Related to the plain TeX interface and implementation themes Related to Markdown themes
Projects
None yet
Development

No branches or pull requests

2 participants