如何将 LaTeX 与 Markdown 混合使用? [英] How can I mix LaTeX in with Markdown?

查看:30
本文介绍了如何将 LaTeX 与 Markdown 混合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Markdown 做课堂笔记,非常棒.我什至对 Markdown 做了一些预处理,这样我就可以做表格之类的事情了.但是这个学期我正在教一门数学课,我希望能够将 LaTeX 公式与 Markdown 结合起来,如下所示:

细化关系写成$a sqsubseteq b$,可以是发音为$a$ 近似于 $b$"或$b$ 至少定义为 $a$".

我希望能够获取 LaTeX 的每个片段并将其预处理为一个很好的抗锯齿 PNG 文件,然后我可以通过 HTML <img> 标签将其包含在我的 Markdown 中.但是我完全不知道如何获取 LaTeX 的片段并获得一个漂亮的图像

  • 有正确的边界框
  • 抗锯齿

我只知道如何获取 DVI、PostScript 或 PDF 格式的完整页面.

我确信这个问题已经得到解决,但我无法猜出正确的搜索词.有任何建议如何解决它或在哪里寻找现有的解决方案?

<小时>

编辑:安装了 mathTeX 后,我可以说代码不灵活,它违反了 Linux 文件系统层次结构标准,而且它是业余的工作——无论从好坏的意义上说单词.代码非常复杂,没有明显的错误.我会寻找替代品.

此外,很明显,在底部,解决方案基于

最后,有一些像这样的开源 LaTeX 模板:https://github.com/Wandmalfarbe/pandoc-latex-template,可用于更好的格式化.

与往常一样,如果读者的用例没有此处介绍的那么琐碎,则应该深入挖掘.

I've been using Markdown for class notes, and it's great. I even do some preprocessing on the Markdown so I can do things like tables. But this term I'm teaching a class with a lot of math, and I'd love to be able to put LaTeX formulas with Markdown, something like this:

The refinement relation is written $a sqsubseteq b$, which can be 
pronounced "$a$ approximates $b$" or "$b$ is at least as defined as $a$".

I'd like to be able to take each fragment of LaTeX and preprocess it into a nice antialiased PNG file which I could then include in my Markdown via the HTML <img> tag. But I have absolutely no idea how to take a fragment of LaTeX and get a nice image that

  • Has the right bounding box
  • Is antialiased

All I know how to do is get full pages in DVI, PostScript, or PDF formats.

I'm sure this problem has been addressed, but I haven't been able to guess the right search terms. Any suggestions how to solve it or where to look for an existing solution?


EDIT: Having installed mathTeX, I can say that the code is inflexible, that it violates the Linux Filesystem Hierarchy standard, and that it is amateur work—in both the good and bad senses of that word. The code is so complex that there are no obvious faults. I will be looking for alternatives.

Also, it's clear that at bottom, solutions are based on dvipng.


ONE YEAR LATER: I never did get the seamless integration I had been hoping for, but I am limping along on a script of my own devising. It turns out that instead of dvipng it is a little easier to use dvips -E and the convert program of ImageMagick. The benefits are slightly more control of things like scaling, and ease of making a transparent background. The curious can inspect this example.

I can't recommend this solution to anyone. But I can't recommend MathTeX either.

解决方案

Have you tried with Pandoc?

EDIT:

Although the documentation has become a bit complex, pandoc has supported inline LaTeX and LaTeX templates for 10 years.

Documents like the following one can be written in Markdown:

---
title: Just say hello!
author: My Friend
header-includes: |
    usepackage{tikz,pgfplots}
    usepackage{fancyhdr}
    pagestyle{fancy}
    fancyhead[CO,CE]{This is fancy}
    fancyfoot[CO,CE]{So is this}
    fancyfoot[LE,RO]{	hepage}
abstract: This is a pandoc test with Markdown + inline LaTeX
---

Just say hello!
===============

This could be a good example or inlined LaTeX:

egin{tikzpicture}
egin{axis}
addplot[color=red]{exp(x)};
end{axis}
end{tikzpicture}
%Here ends the furst plot
hskip 5pt
%Here begins the 3d plot
egin{tikzpicture}
egin{axis}
addplot3[
    surf,
]
{exp(-x^2-y^2)*x};
end{axis}
end{tikzpicture}

And now, just a few words to terminate:

> Goodbye folks!

Which can be converted to LaTeX using commands like this: pandoc -s -i Hello.md -o Hello.tex

Following is an image of the converted Hello.md to Hello.pdf file using MiKTeX as LaTeX processor with the command: pandoc -s -i Hello.md -o Hello.pdf

Finally, there are some open source LaTeX templates like this one: https://github.com/Wandmalfarbe/pandoc-latex-template, that can be used for better formatting.

As always, the reader should dig deeper if he has less trivial use cases than presented here.

这篇关于如何将 LaTeX 与 Markdown 混合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆