组织模式 html 导出
我有一个包含源代码、文档和乳胶代码的组织文件。 Latex 的东西画了一堆图表来解释函数如何相互作用。根据
http://orgmode.org/manual/LaTeX-fragments.html
组织-mode 在使用 html 导出时应将 Latex 代码导出为图像。
#+TITLE: Test
#+AUTHOR: Blah
#+LATEX_HEADER: \usepackage{tikz}
#+OPTIONS: LaTeX:dvipng
#+begin_latex
\begin{tikzpicture}
\draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle;
\end{tikzpicture}
#+end_latex
如果我使用 pdf 导出,那么我的乳胶设置可以正常工作,并且 dvipng 也存在于我的系统上,但是当导出到 html 乳胶块时,上面的工作将被完全忽略。
I have a org file with source, documentation and latex code. Latex stuff draws a bunch of graphs explaining how functions interact with each other. According to,
http://orgmode.org/manual/LaTeX-fragments.html
org-mode should export latex code as images when using html export.
#+TITLE: Test
#+AUTHOR: Blah
#+LATEX_HEADER: \usepackage{tikz}
#+OPTIONS: LaTeX:dvipng
#+begin_latex
\begin{tikzpicture}
\draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle;
\end{tikzpicture}
#+end_latex
Above works if I use pdf export so my latex setup is working also dvipng is present on my system but when exporting to html latex block is completely ignored.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我能够将 tikz 图片从 org 导出到 html(实际上,
Reveal.js 使用 org 8.2.5h 中的 [org-reveal][1] ),并包含以下内容,
希望对您有所帮助。如果没有
#+LaTeX_Header
行,LaTeX进程不知道包含 tikz,因此构建失败。如果我尝试
tex:dvipng
而不是tex:imagemagick
,然后我得到一个图像,但是错误地渲染了一个。
I was able to export a tikz picture from org to html (actually, to
reveal.js using [org-reveal][1] ) from org 8.2.5h with the following
I hope that's helpful. Without the
#+LaTeX_Header
line, the LaTeXprocess doesn't know to include tikz, and the build fails. If I try
tex:dvipng
instead oftex:imagemagick
, then I get an image, but anincorrectly rendered one.
使用最新版本的 Org-mode(还早于版本 9 --- 请参阅下面的编辑),您可以使用类似以下内容的内容,它可以导出到 LaTeX 以及 HTML。在后一种情况下,
convert
(来自 ImageMagick 工具包)用于将从 tikz 代码片段生成的 PDF 转换为大小为 100px x 100px 的 PNG 图像。此外,还可以添加标题,并将图片插入到 LaTeX 中的浮动
figure
环境中,方法是:注意
:width
属性设置为要擦除的空字符串Org-mode 的默认行为,导出到 LaTeX 时将图片的宽度设置为 0.9\textwidth。根据此页面,也是可能的要以 SVG 而不是 PNG 格式导出图片,只需将
diamond.png
替换为diamond.svg
并删除与 ImageMagick 相关的标头,如下所示:但请注意,此解决方案不支持数学宏在 tikz 代码中。
htlatex
应该支持基本的数学结构(通过取消注释上面的 2 条 tikz 和 lisp 行来尝试),但此功能显然需要一些返工,因为生成的 SVG 无效。编辑
从版本 9 开始,上面的代码变成了(出于说明目的,参考了图):
主要区别在于“COMMENT”变成了设置部分的“:noexport”标签(请参阅此答案)、
by-backend
宏的代码以及“graphics " 结果的属性乳胶代码块。With recent versions of Org-mode (yet, older than version 9 --- see edit below), you could use something like the following, that can export to LaTeX as well as to HTML. In the latter case,
convert
(from the ImageMagick toolkit) is used to translate a PDF generated from the tikz code snippet into a PNG image of size 100px by 100px.Besides, one can add a caption, and insert the picture in a floating
figure
environment in LaTeX, by using:Note the
:width
attribute is set to the empty string to erase the default behavior of Org-mode, which sets the width of the picture to0.9\textwidth
when exporting to LaTeX.According to this page, it is also possible to export pictures in SVG instead of PNG, simply by replacing
diamond.png
bydiamond.svg
and removing ImageMagick-related headers, as in:Note however that this solution does not support mathematical macros in tikz code as is.
htlatex
ought to support basic mathematical constructs (to be tried by un-commenting the 2 tikz and lisp lines above), but this feature needs some rework apparently, as the resulting SVG is invalid.Edit
Since version 9, the code above becomes (with a reference to the figure, for illustrative purposes):
The main differences are in the "COMMENT" becoming a ":noexport" tag for the setup section (see this answer), the code of
by-backend
macro, and the "graphics" attribute for the result of the latex code block.dvipng 不处理 tikz。我在安装中通过将 dvipng 替换为以下 shell 脚本来解决这个问题:
现在,我可以使用 Cx Cc Cl 预览 tikz 片段,或将其导出为 HTML。这不是一个理想的解决方案,但它对我有用。
dvipng does not handle tikz. I've worked around this on my installation by replacing dvipng with the following shell script:
Now, I can preview a tikz snippet with C-x C-c C-l, or export it to HTML. Not an ideal solution, but it works for me.
我无法使 tikzpicture 块正常工作,但不应使用
#+begin_latex
和#+end_latex
,正如您在 Org-Mode 文档的链接中所述,仅需要\begin{...} LATEX_CODE end{...}
。这个片段应该可以工作。
I wasn't able to make tikzpicture blocks working but
#+begin_latex
and#+end_latex
shouldn't be use, as said in your link to the Org-Mode documentation, only\begin{...} LATEX_CODE end{...}
is required.This snippet should work.