我意识到发布整个文档太多了。这里只是文档的一小部分,它只是在各个章节中不断重复。抱歉,这是我能压缩到的最小示例大小。
\documentclass[a4paper,12pt]{article}
%\usepackage[left=0.15in,right=0.15in,top=0.75in,bottom=0.75in]{geometry}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{polyglossia}
\usepackage{longtable}
\usepackage[doublespacing]{setspace}
\usepackage{verse}
\usepackage{varwidth}
\AtBeginEnvironment{Verse}{\singlespacing}
\AtBeginEnvironment{longtable}{\onehalfspacing}
\newcommand{\blt}{\begin{longtable}{p{1.5cm}p{0.05cm}p{3.5cm}|p{1.5cm}p{0.05cm}p{3.5cm}|p{1.5cm}p{0.05cm}p{3.5cm}}}
\newcommand{\elt}{\end{longtable}}
\newcommand{\bv}{\begin{Verse}\large}
\newcommand{\ev}{\end{Verse}}
\newcommand{\bfns}{\begin{footnotesize}}
\newcommand{\efns}{\end{footnotesize}}
\newcommand{\sz}{\\[\normalbaselineskip]}
\newcommand{\csec}[1]{\section{#1}}
\newenvironment{Verse}
{\center\varwidth{\linewidth}}
{\endvarwidth\endcenter}
\setmainfont[Script=Devanagari]{Sanskrit 2003}
\begin{document}
\bv
तपः स्वाध्यायनिरताम् तपस्वी वाग्विदाम् वरम् | \\
नारदम् परिपप्रच्छ वाल्मीकिर्मुनिपुङ्गवम् ॥ १.१.१ ॥
\ev
\bfns \blt \hline
तपस्वी & = & sagacious thinker & वाल्मीकि: & = & Sage [Poet] वाल्मीकि & तपः & = & in thoughtful-meditation \\
स्व अध्याय & = & in self, study of scriptures & निरतम् & = & always - who is eternally studious in scriptures& वाक् & = & in speaking [in enunciation] \\
विदाम् & = & among expert enunciators & वरम् & = & sublime one - with नारद & मुनि पुन्गवम् & = & with sage, paragon, with such a paragon sage Naarada \\
नारदम् & = & with [such a sage] Naarada & परिपप्रच्छ & = & verily [inquisitively,] inquired about
\elt \efns
सर्व गुण समिष्टि रूपम् पुरुषम् all, merited endowments, composite, in form - about such a man.]
A thoughtful-meditator, an eternally studious sage in scriptures about the Truth and Untruth, a sagacious thinker, and a sublime enunciator among all expert enunciators is नारद, and with such a Divine Sage नारद, the Sage-Poet वाल्मीकि is inquisitively enquiring about a man who is a composite for all merited endowments in his form and calibre. [1-1-1]\\
\end{document}
这是我运行的命令:htxelatex bala.tex # generate html
。现在我收到以下错误:
(/usr/local/texlive/2011/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./bala.aux)
! LaTeX Error: Command `\acute' already defined in `'.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.33 \begin{document}
?
fontspec
我把包选项改成了\usepackage[no-math]{fontspec}
,但出现了这个错误:
----------------------------------------------------
(--- xdv font = [/usr/local/texlive/2011/texmf-dist/fonts/opentype/public/lm/lmmono10-regular.otf] (not implemented) ---)
--- warning --- Couldn't find font `[/usr/local/texlive/2011/texmf-dist/fonts/opentype/public/lm/lmmono10-regular.otf].htf' (char codes: 0--255)
(--- xdv font = Sanskrit2003 (not implemented) ---)
--- warning --- Couldn't find font `Sanskrit2003.htf' (char codes: 0--255)
(--- xdv font = Sanskrit2003 (not implemented) ---)
--- error --- Illegal storage address
----------------------------
t4ht.c (2010-12-16-08:47 kpathsea)
t4ht -.xdv
-f/Bala
(/usr/local/texlive/2011/texmf-dist/tex4ht/base/unix/tex4ht.env)
Entering Bala.lg
答案1
tex4ht
我知道您最终找到了解决方案,但是如果有人感兴趣的话,那么有一个解决方案。
存在三个问题:
- 你运行
htxelatex bala.tex # generate html
- 应该没有# generate html
,这只是一些注释。htlatex bala.tex "xhtml, charset=utf-8" " -cunihtf -utf8"
在unicode输入的情况下,正确的命令是。似乎对xetex的支持有限,所以最好运行htlatex
而不是htxelatex
! tex4ht
在这种情况下,与某些 xelatex 包不兼容,xlxtra, fontspec and polyglossia
因此您必须编辑序言以在tex4ht
运行时不包括它们。这个问题非常有趣 - 如果你使用 或 运行你的文件
htlatex, htxelatex
,htlualatex
字符devanagari
就会丢失 - 我不知道正确的解决方案,但你可以在宏的帮助下inputenc's
DeclareUnicodeCharacter
直接使用输入:character codes
tex4ht
\HChar
\DeclareUnicodeCharacter{0904}{\HChar{224}\HChar{164}\HChar{132}} % ऄ
您可以在文件中找到所有代码devng4ht.sty
所以现在你的序言应该是这样的:
\documentclass[a4paper,12pt]{article}
\usepackage{etoolbox}
\makeatletter
\@ifpackageloaded{tex4ht}{
\usepackage[utf8]{inputenc}
\usepackage{devng4ht}
}{%
\usepackage{fontspec}
\usepackage{xltxtra}
\setmainfont[Script=Devanagari]{Sanskrit 2003}
\usepackage{polyglossia}
}
\newcommand{\bv}{\begin{Verse}}
\newcommand{\ev}{\end{Verse}}
\usepackage{longtable}
\usepackage[doublespacing]{setspace}
\usepackage{verse}
\usepackage{varwidth}
\AtBeginEnvironment{Verse}{\singlespacing}
\AtBeginEnvironment{longtable}{\onehalfspacing}
\newcommand{\blt}{\begin{longtable}{p{1.5cm}p{0.05cm}p{3.5cm}|p{1.5cm}p{0.05cm}p{3.5cm}|p{1.5cm}p{0.05cm}p{3.5cm}}}
\newcommand{\elt}{\end{longtable}}
\newcommand{\bfns}{\begin{footnotesize}}
\newcommand{\efns}{\end{footnotesize}}
\newcommand{\sz}{\\[\normalbaselineskip]}
\newcommand{\csec}[1]{\section{#1}}
\newenvironment{Verse}
{\center\varwidth{\linewidth}}
{\endvarwidth\endcenter}
存在一些限制 - 您不能使用像large
或这样的更改开关\footnotesize
- 由于某种原因,它们会破坏天城文的正确渲染。
html
但是您可以使用私有配置文件来使用标签和css
代码调整您的宏。文件devng.cfg
:
\Preamble{xhtml, charset=utf-8}
\Css{
.verse{
font-size:large;
margin:2em;
width:auto;
}
.bfns{
font-size:small;
}
}
\begin{document}
\let\old@bv\bv
\renewcommand\bv{\leavevmode\EndP\NoFonts\HtmlParOff\HCode{\Hnewline<div class="verse">\Hnewline}\old@bv}
\let\old@ev\ev
\renewcommand\ev{\NoFonts\HCode{\Hnewline</div>\Hnewline}\old@ev\HtmlParOn\EndNoFonts}
\let\old@bfns\bfns
\renewcommand\bfns{\leavevmode\SaveEndP\NoFonts\Tg<div class="bfns">\old@bfns}
\let\old@efns\efns
\renewcommand\efns{\NoFonts\Tg</div>\old@efns\EndNoFonts}
\EndPreamble
我使用\NoFonts
来抑制字符代码的处理,这会导致梵文字符消失。现在你终于可以编译你的文件了:
htlatex bala.tex devng " -cunihtf -utf8"
答案2
尝试TeX4ht。这似乎是目前最好的解决方案。