我一直在尝试用 LaTeXML 生成小文档片段 - 慢慢地构建更复杂的文档,而第一个绊脚石就是包含希腊字符。我观察到,当在 Internet Explorer 中打开 html 文件或通过右键单击 -> 编辑(在 MS Word 中打开)打开 html 文件时,会插入希腊字符,但紧接着是生成它们的代码。几乎与此处列出的希腊字符表格中观察到的各个元素相同: http://web.ift.uib.no/Teori/KURS/WRK/TeX/sym1.html 然而在歌剧中没有出现任何符号,只有 \alpha 等。
doc.Tex 文件(内容如下)使用以下命令通过 bat 文件进行编译:
latexml --includestyles --noparse --dest=doc.xml doc.tex | latexmlpost --dest=doc.html doc.xml
在装有 miktex 和 strawberry perl 的 Windows 机器上
\documentclass[letter]{report}
\begin{document}
\chapter{Math Test}
\section{A few Greek characters}
$\alpha$
$\beta$
$\gamma$
$\Gamma$
$\delta$
$\Delta$
$\pm$
How did these display?
\end{document}
生成的 HTML 代码:不幸的是,当我粘贴代码时,选项和 4 个空格标签不会阻止代码的解析,因此我可能需要在此处进行编辑以显示未解析形式的代码。
<!DOCTYPE html><html>
<head>
<title></title>
<!--Generated on Mon Dec 22 13:10:57 2014 by LaTeXML (version 0.8.0) http://dlmf.nist.gov/LaTeXML/.-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="LaTeXML.css" type="text/css">
<link rel="stylesheet" href="ltx-report.css" type="text/css">
</head>
<body>
<div class="ltx_page_main">
<div class="ltx_page_content">
<section class="ltx_document">
<section id="Ch1" class="ltx_chapter">
<h1 class="ltx_title ltx_title_chapter">
<span class="ltx_tag ltx_tag_chapter">Chapter 1 </span>Math Test</h1>
<section id="Ch1.S1" class="ltx_section">
<h1 class="ltx_title ltx_title_section">
<span class="ltx_tag ltx_tag_section">1.1 </span>A few Greek characters</h1>
<div id="Ch1.S1.p1" class="ltx_para">
<p class="ltx_p"><math id="Ch1.S1.p1.m1" class="ltx_Math" alttext="\alpha" display="inline"><semantics><mi>α</mi><annotation encoding="application/x-tex">\alpha</annotation></semantics></math><math id="Ch1.S1.p1.m2" class="ltx_Math" alttext="\beta" display="inline"><semantics><mi>β</mi><annotation encoding="application/x-tex">\beta</annotation></semantics></math><math id="Ch1.S1.p1.m3" class="ltx_Math" alttext="\gamma" display="inline"><semantics><mi>γ</mi><annotation encoding="application/x-tex">\gamma</annotation></semantics></math><math id="Ch1.S1.p1.m4" class="ltx_Math" alttext="\Gamma" display="inline"><semantics><mi mathvariant="normal">Γ</mi><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math><math id="Ch1.S1.p1.m5" class="ltx_Math" alttext="\delta" display="inline"><semantics><mi>δ</mi><annotation encoding="application/x-tex">\delta</annotation></semantics></math><math id="Ch1.S1.p1.m6" class="ltx_Math" alttext="\Delta" display="inline"><semantics><mi mathvariant="normal">Δ</mi><annotation encoding="application/x-tex">\Delta</annotation></semantics></math></p>
</div>
<div id="Ch1.S1.p2" class="ltx_para">
<p class="ltx_p"><math id="Ch1.S1.p2.m1" class="ltx_Math" alttext="\pm" display="inline"><semantics><mo>±</mo><annotation encoding="application/x-tex">\pm</annotation></semantics></math></p>
</div>
<div id="Ch1.S1.p3" class="ltx_para">
<p class="ltx_p">How did these display?</p>
</div>
</section>
</section>
</section>
</div>
<footer class="ltx_page_footer">
<div class="ltx_page_logo">Generated on Mon Dec 22 13:10:57 2014 by <a href="http://dlmf.nist.gov/LaTeXML/">LaTeXML <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAOCAYAAAD5YeaVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wKExQZLWTEaOUAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAdpJREFUKM9tkL+L2nAARz9fPZNCKFapUn8kyI0e4iRHSR1Kb8ng0lJw6FYHFwv2LwhOpcWxTjeUunYqOmqd6hEoRDhtDWdA8ApRYsSUCDHNt5ul13vz4w0vWCgUnnEc975arX6ORqN3VqtVZbfbTQC4uEHANM3jSqXymFI6yWazP2KxWAXAL9zCUa1Wy2tXVxheKA9YNoR8Pt+aTqe4FVVVvz05O6MBhqUIBGk8Hn8HAOVy+T+XLJfLS4ZhTiRJgqIoVBRFIoric47jPnmeB1mW/9rr9ZpSSn3Lsmir1fJZlqWlUonKsvwWwD8ymc/nXwVBeLjf7xEKhdBut9Hr9WgmkyGEkJwsy5eHG5vN5g0AKIoCAEgkEkin0wQAfN9/cXPdheu6P33fBwB4ngcAcByHJpPJl+fn54mD3Gg0NrquXxeLRQAAwzAYj8cwTZPwPH9/sVg8PXweDAauqqr2cDjEer1GJBLBZDJBs9mE4zjwfZ85lAGg2+06hmGgXq+j3+/DsixYlgVN03a9Xu8jgCNCyIegIAgx13Vfd7vdu+FweG8YRkjXdWy329+dTgeSJD3ieZ7RNO0VAXAPwDEAO5VKndi2fWrb9jWl9Esul6PZbDY9Go1OZ7PZ9z/lyuD3OozU2wAAAABJRU5ErkJggg==" alt="[LOGO]"></a>
</div></footer>
</div>
</body>
</html>
Firefox 渲染 html
答案1
latexml 使用 mathml 生成 html,因此需要支持 mathml 的浏览器,例如 firefox 或 safari。遗憾的是 IE 和 Chrome 不支持数学。
在所有浏览器中启用 MatHML 的最简单方法是使用 mathjax,这只需添加<script>
如下所示的元素行。
Probalby Latexml 可以配置为在生成输出时添加此项。
<!DOCTYPE html><html>
<head>
<title></title>
<!--Generated on Mon Dec 22 13:10:57 2014 by LaTeXML (version 0.8.0) http://dlmf.nist.gov/LaTeXML/.-->
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_HTMLorMML"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="LaTeXML.css" type="text/css">
<link rel="stylesheet" href="ltx-report.css" type="text/css">
</head>
答案2
由于您已将问题标记为tex4ht,为什么不将 htlatex 用于此目的?
跑步
htlatex doc.tex html
你会得到以下结果
这是内容doc.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html -->
<meta name="src" content="test.tex">
<meta name="date" content="2014-12-22 07:12:00">
<link rel="stylesheet" type="text/css" href="test.css">
</head><body
>
<h2 class="chapterHead"><span class="titlemark">Chapter 1</span><br /><a
id="x1-10001"></a>Math Test</h2>
<h3 class="sectionHead"><span class="titlemark">1.1 </span> <a
id="x1-20001.1"></a>A few Greek characters</h3>
<!--l. 5--><p class="noindent" ><span
class="cmmi-10">α β γ </span>Γ <span
class="cmmi-10">δ </span>Δ <span
class="cmsy-10">± </span>How did these display?
</body></html>
相反,如果你想要xhtml
输出,请运行
html 文档.tex xhtml
这将是doc.html
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->
<html xmlns="http://www.w3.org/1999/xhtml"
>
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
<!-- xhtml,html -->
<meta name="src" content="doc.tex" />
<meta name="date" content="2014-12-22 08:54:00" />
<link rel="stylesheet" type="text/css" href="doc.css" />
</head><body
>
<h2 class="chapterHead"><span class="titlemark">Chapter 1</span><br /><a
id="x1-10001"></a>Math Test</h2>
<h3 class="sectionHead"><span class="titlemark">1.1 </span> <a
id="x1-20001.1"></a>A few Greek characters</h3>
<!--l. 5--><p class="noindent" ><span
class="cmmi-10">α β γ </span>Γ <span
class="cmmi-10">δ </span>Δ <span
class="cmsy-10">± </span>How did these display? </p>
</body></html>