LaTeXML 中的希臘字符

LaTeXML 中的希臘字符

我一直在嘗試用 LaTeXML 生成小文檔片段 - 慢慢地構建出更複雜的文檔,第一個絆腳石是包含希臘字符。我觀察到,當在 Internet Explorer 中打開 html 文件或通過右鍵單擊 -> 編輯(在 MS Word 中打開)打開 html 文件時,會插入希臘字符,但緊接著生成它們的代碼。與此處列出的希臘字元表格表示中觀察到的各個元素幾乎相同: http://web.ift.uib.no/Teori/KURS/WRK/TeX/sym1.html 然而在 Opera 中沒有出現任何符號,只有 \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

既然你已經用標籤標記了你的問題,為什麼不使用 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&#x00A0;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">&#x03B1; &#x03B2; &#x03B3; </span>&#x0393; <span
class="cmmi-10">&#x03B4; </span>&#x0394; <span
class="cmsy-10">± </span>How did these display?
</body></html>

相反,如果您想要xhtml輸出,請運行

htlatex doc.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&#x00A0;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">&#x03B1; &#x03B2; &#x03B3; </span>&#x0393; <span
class="cmmi-10">&#x03B4; </span>&#x0394; <span
class="cmsy-10">± </span>How did these display? </p>
</body></html> 

相關內容