引用环境和 tex4ht

引用环境和 tex4ht

我正在尝试转换一些包含引用环境,使用 html乳胶。这里有一个小例子,其排版没有任何问题:

\documentclass{scrbook}
\usepackage{quoting}

\begin{document}
\chapter{Chapter one}
Here is a para

Here is a second para

\begin{quoting}
one para inside a small block.

another para inside the block.
\end{quoting}

Now for a para after the quote.

And another para after the quote.

What has happened? In the HTML version there are no para breaks!

\chapter{Chapter two}
Let's try after a chapter break.

That's good -- para breaks work now.

But what happened after the quoting environment in the previous chapter?
\end{document}

当我尝试在这个文件上运行 htlatex 时,它不知道引用环境,所以我创建了这个 tex4ht 配置文件配置示例.cfg

\Preamble{html}

\begin{document} 
\ConfigureEnv{quoting}
    {\HCode{<blockquote>}}
    {\HCode{</blockquote>}}{}{}

\EndPreamble 

运行这个程序似乎htlatex example.tex "configexample.cfg"有效,并且它创建例子.html,甚至在其中获得了 blockquote 标签。但是在引用环境结束后,我没有得到我期望的 p 标签。也就是说,直到章节中断之后才得到。

我不知道这是 tex4ht 的问题,还是引用包。我可以回到使用引用环境,但如果可以的话,我想先让它工作。有什么想法吗?

(在 MiKTeX 下运行)

答案1

好的,看起来这quoting非常积极地重新定义了\everypar用于tex4ht插入<p>标签的令牌寄存器。因此,我们必须创建quoting.4ht将自动加载的文件quoting.sty

\newtoks\quoting@parht
\NewConfigure{quoting}{2}
\Configure{quoting}
{\ifvmode \IgnorePar\fi \EndP\HCode{<blockquote>}\HtmlParOn}
{\ifvmode \IgnorePar\fi \EndP\HCode{</blockquote>}\HtmlParOn\par}

\ConfigureEnv{quoting}
{\quoting@parht=\everypar%
\a:quoting\par\ShowPar}
{\par%
\b:quoting%
\everypar=\quoting@parht\par\ShowPar}
{}{}

\ConfigureList{quoting}{}{}
{%
\everypar=\quoting@parht\par\ShowPar%
}{}

首先,我们定义新的令牌寄存器quoting@parht,其中\everypar保存了的值,然后quoting创建新的配置,因此我们可以仅配置要插入的标签。

然后\ConfigureEnv我们用 保存 的值\everypar,然后插入开始和结束标记,并恢复 的值everypar,这样 html 段落就会被打印出来。我们还必须使用\ConfigureList,这样段落在环境中也能正常工作。结果:

<?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="quot.tex" /> 
<meta name="date" content="2013-10-29 15:45:00" /> 
<link rel="stylesheet" type="text/css" href="quot.css" /> 
</head><body 
>


  <h2 class="chapterHead"><span class="titlemark">1</span>&#x00A0;&#x00A0;<a 
 id="x1-10001"></a>Chapter one</h2>
<!--l. 6--><p class="noindent" >Here is a para
</p><!--l. 8--><p class="indent" >  Here is a second para
</p>
  <blockquote>
     <!--l. 11--><p class="indent" >
     one para inside a small block.
     </p><!--l. 13--><p class="indent" >  another para inside the block.
     </p><!--l. 15--><p class="indent" >  and another para
</p>
  </blockquote>
<!--l. 18--><p class="indent" >  Now for a para after the quote.
</p><!--l. 20--><p class="indent" >  And another para after the quote.
</p><!--l. 22--><p class="indent" >  What has happened? In the HTML version there are no para breaks!


</p>
  <h2 class="chapterHead"><span class="titlemark">2</span>&#x00A0;&#x00A0;<a 
 id="x1-20002"></a>Chapter two</h2>
<!--l. 25--><p class="noindent" >Let&apos;s try after a chapter break.
</p><!--l. 27--><p class="indent" >  That&apos;s good &#8211; para breaks work now.
</p><!--l. 29--><p class="indent" >  But what happened after the quoting environment in the previous chapter? </p> 
</body></html> 

相关内容