这是针对 tex4ht 专家的一个问题。
我正在用德语写合同。MWE:
\documentclass[pagesize, ngerman, fontsize=12pt, parskip=half, ref=nosentence]{scrartcl}
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
\usepackage{babel, scrjura, xspace}
\usepackage{lmodern}
\usepackage{microtype}
\DisableLigatures[f]{encoding = *, family = * }
\begin{document}
\begin{contract}
\Clause{title=First of seven}
\label{CLA:first}
This is some text.
Some more text.\label{PAR:second-par}
And.
\Clause{title=Second of seven}
\label{CLA:second}
We refer to \ref{CLA:first}.
We refer to \ref{PAR:second-par}.
We refer to \refPar{PAR:second-par}.
We refer to \refParN[arabic]{PAR:second-par}.%%% <= Issue !
\end{contract}
\end{document}
scrjura 软件包附带许多命令来引用合同的不同位置。有些命令不适用于 tex4ht。
如果使用此命令将此示例文件转换为 html:
htlatex example.tex "scrjura" " -cunihtf"
该命令\refParN[arabic]{PAR:second-par}
将不会被转换。链接缺失。
scrjura 是配置文件的名称非常有帮助的灵魂曾经为我写过。这是 scrjura.cfg 的代码(对于测试用例,只需将其存储在 example.tex 所在的同一文件夹中):
\catcode`\:=11
\makeatletter
\Preamble{html,charset=utf-8}
\begin{document}
\def\qtchr{\expandafter\@gobble\string\"}
\
\ConfigureList{contract}
{\HCode{<div class=\qtchr contract\qtchr>}}
{\HCode{</div>}}
{}{}
\append:def\contract@paragraph@font{\a:contract@paragraph@font}
\append:def\contract@paragraph@font{\b:contract@paragraph@font}
\NewConfigure{contract@paragraph@font}{2}
\Configure{contract@paragraph@font}
{\HCode{<div class=\qtchr paragraph\qtchr>}}
{\Tg</div>}
\pend:def\parformat{\a:parformat}
\append:def\parformat{\b:parformat}
\NewConfigure{parformat}{2}
\Configure{parformat}
{\EndP\HCode{<p class=\qtchr para\qtchr>
<span class=\qtchr sentence\qtchr>}}
{\Tg</span>}
\Css{.sentence{margin-left:2em; padding-top: .5em;}}
\Css{.paragraph{margin: 1em;}}
\Css{.para{margin: .5em;}}
\EndPreamble
\catcode`\:=12
\makeatother
\endinput
如果有人知道如何修改 scrjura.cfg 以获得\refPar
转换后的链接,我将不胜感激。
顺便说一句,scrjura.sty 几年前使用的\Paragraph{title=First of seven}
是现在的\Clause{title=...}
。
答案1
我已经scrjura.4ht
为创建了一个适当的配置文件tex4ht
:
\def\qtchr{\expandafter\@gobble\string\"}
\ConfigureEnv{contract}
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class=\qtchr contract\qtchr>}}
{\ifvmode\IgnorePar\fi\end:prevpara\HCode{</div>}}
{}{}
\pend:def\contract@paragraph@font{\a:contract@paragraph@font}
\append:def\contract@paragraph@font{\b:contract@paragraph@font\gdef\end:prevpara{}}
\NewConfigure{contract@paragraph@font}{2}
\Configure{contract@paragraph@font}
{\ifvmode\IgnorePar\fi\end:prevpara\HCode{<div class=\qtchr paragraph\qtchr>}}
{\Tg</div>}
% \end:prevpara is needed to correctly handle paragraphs
\def\end:prevpara{}
\pend:def\parformat{\end:prevpara\a:parformat}
\append:def\parformat{\b:parformat\global\let\end:prevpara\c:parformat}
\NewConfigure{parformat}{3}
\Configure{parformat}
{\EndP\HCode{<p class=\qtchr para\qtchr>\Hnewline
<span class=\qtchr sentence\qtchr>}}
{\Tg</span>}{\Tg</p>}
% this is a modified version of original macro from scrjura.sty
\renewcommand*{\ref@Par}[2]{%
\expandafter\ifx\csname r@#2\endcsname\relax
\ref#1{#2}%
\else
\begingroup
% this definitions are needed to get correct content from the \csname r@#2\endcsname
\def\rEfLiNK##1##2{##2}
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\@tempb
\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter{%
\expandafter\expandafter\expandafter\@gobble\csname r@#2\endcsname}%
\def\@tempc##1##2\@nil{##1}%
\let\scrjura@separator\@gobble
\protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
\csname r@#2\endcsname\noexpand\@nil}%
\def\@tempc##1##2##3\@nil{##2}%
\protected@edef\@tempa{\expandafter\expandafter\expandafter\@tempc
\@tempa{%
\protect\G@refundefinedtrue
\nfss@text{\reset@font\bfseries ??}%
\@latex@warning{Reference `#2' on page \thepage \space
with undefined par number}%
}\noexpand\@nil}%
\let\@@protect\protect
\let\protect\noexpand
\expandafter\edef\csname r@#2\endcsname{{\@tempa}\@tempb}%
\let\protect\@@protect
\ref#1{#2}%
\endgroup
\fi
}
\Css{.sentence{margin-left:2em; padding-top: .5em;}}
\Css{.paragraph{margin: 1em;}}
\Css{.para{margin: .5em;}}
\refPar
和宏的问题\refParN
在于它们依赖于特定的交叉引用结构,这与 不同tex4ht
。我已经修补了交叉引用处理宏,\ref@Par
使其以某种方式兼容。唯一的问题是这些命令的链接不起作用,但至少文本看起来不错: