如何将 LaTeX 与 Markdown 混合使用?

2024-04-18前端开发问题
76

本文介绍了如何将 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 混合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

“数组中的每个孩子都应该有一个唯一的 key prop"仅在第一次呈现页面时
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)...
2024-04-20 前端开发问题
5

如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?
How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社...
2024-04-20 前端开发问题
6

缩放背景图像以适合 ie8 窗口
Scale background image to fit ie8 window(缩放背景图像以适合 ie8 窗口)...
2024-04-19 前端开发问题
11