从markdown转换为pandoc时的\ newcommand环境 [英] \newcommand environment when convert from markdown to pandoc
问题描述
我使用ipython笔记本键入数学,然后转换为乳胶.为了使mathjax理解\newcommand
,我必须将其放入$...$
中.例如,$\newcommand{\cl}{\operatorname{cl}}$
与mathjax一起很好地工作.问题是,当我使用pandoc转换为tex文件时,它仍然在$\newcommand{\cl}{\operatorname{cl}}$
那里,但是我想要的只是\newcommand{\cl}{\operatorname{cl}}
(没有$...$
).有没有人请教我如何解决这个问题?
I use ipython notebook to type math and then convert to latex. To make mathjax understand \newcommand
, I have to put it inside $...$
. For example, $\newcommand{\cl}{\operatorname{cl}}$
works well with mathjax. The problem is that when I convert to tex file using pandoc, it is still $\newcommand{\cl}{\operatorname{cl}}$
there, but what I want is just \newcommand{\cl}{\operatorname{cl}}
(no $...$
). Is there anyone please show me how to solve this problem?
非常感谢您!
推荐答案
一个简单的选择是使用乳胶魔术在ipython中使用乳胶环境.
One easy option is to use latex magic to use latex environments within ipython.
例如,这是一个示例
%%latex
\begin{aligned}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{aligned}
%%latex
\begin{aligned}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{aligned}
或者,在降价单元中使用完整的乳胶的唯一解决方案是使用配置文件在MathJax中创建tex宏,而不是重载$ ... $.
Alternatively, the only solution to using full blown latex within markdown cells is to use a configuration file for creating tex Macros in MathJax instead of overloading $...$.
第一
-
创建本地MathJax安装(请参阅ipython docs )
使用自定义配置文件和tex宏修改本地MathJax安装. (下面提供了参考)
Modify the local MathJax installation with a custom configuration file and tex macros. (References provided below)
告诉ipython使用通过以下方式进行本地修改的MathJax安装
Tell ipython to use your local-modified MathJax installation using
python -m IPython.external.mathjax -d /some/other/mathjax
修改MathJax安装
以下是MathJax中的相关摘录文档
如果您有许多这样的定义要在 一页,您可以将它们放入配置文件中 与主配置文件一起加载.例如,您可以 在MathJax/config/local中创建一个名为local.js的文件,其中包含 您的宏定义:
If you have many such definitions that you want to use on more than one page, you could put them into a configuration file that you can load along with the main configuration file. For example, you could create a file in MathJax/config/local called local.js that contains your macro definitions:
MathJax.Hub.Config({
TeX: {
Macros: {
RR: "{\\bf R}",
bold: ["{\\bf #1}",1]
} } });
MathJax.Ajax.loadComplete("[MathJax]/config/local/local.js");接着 将其与您的主要配置文件一起加载到脚本上 加载MathJax.js:
MathJax.Ajax.loadComplete("[MathJax]/config/local/local.js"); and then load it along with your main configuration file on the script that loads MathJax.js:
<script src="/MathJax/MathJax.js?config=TeX-AMS_HTML,local/local.js"></script>
如果使用CDN,则可以在以下位置创建本地配置文件: 您自己的服务器,并从CDN和您的计算机中加载MathJax本身 服务器中的配置文件.请参阅使用本地配置 向CDN提交以获取详细信息.
If you are using the CDN, you can make a local configuration file on your own server, and load MathJax itself from the CDN and your configuration file from your server. See Using a Local Configuration File with the CDN for details.
这篇关于从markdown转换为pandoc时的\ newcommand环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!