当我的文档中有figure
带有\label{aa--bb}
或任何其他使用两个连字符 (-) 的标签 (--) 时,tex4ht
会产生损坏的.odt
文件。有没有办法修复此错误?
平均能量损失
使用与我在先前的问题,连接head.tex
,,main.tex
然后tail.tex
使用 Michal Hoftich(@michal.h21)在回答该问题时给出的命令对其进行编译。
main.tex
:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[12pt]{memoir}
\usepackage{ifmtarg}
\usepackage{calc}
%Greek
\newcommand{\greek}[1]{#1}
\newcommand{\gk}[1]{#1}
%Arabic
\newcommand{\ar}[1]{#1}
\newenvironment{arab}{}{}
% Bibliography etc
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[notes,
alldates= comp,
backend= biber,
bibwarn= false,
cmsdate= both, % reprints: print `origdate` as well as `year`
compresspages= true,
doi= false,
eprint= false,
ibidtracker= true,
inheritshorthand, % feature added for me by D.Fussner
isbn= false,
mincrossrefs = 2,
shorthandibid,
strict= true,
url= true,
usetranslator= true,
uniquename= true
]{biblatex-chicago}
\addbibresource{/Users/alexandre/Dropbox/bib-dbs/alexhistory.bib}
\addbibresource{/Users/alexandre/Dropbox/bib-dbs/alexhistory-NEW.bib}
\usepackage{textcomp} % For angle brackets `\textlangle` and `\textrangle`
\begin{document}
%%%%%%%%%%%%%%%%%%%%
%%% My text goes here: %%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
Fig.~\ref{aa--bb}.
\begin{figure}[p]
\begin{center}
\label{aa--bb}
\end{center}
\end{figure}
%%%%%%%%%%%%%%%%%%%%
%%% My text ends here: %%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
\end{document}
然后,我在目录中包含myconfig.cfg
(再次来自 Michal Hoftich,目的是使阿拉伯语文本正确显示):
\Preamble{xhtml}
\xeuniuseblock{Greek}
\xeuniuseblock{Arabic}
\makeatletter
\ConfigureEnv{arab}{\@rltrue}{\@rlfalse}{}{}
\makeatother
\begin{document}
\EndPreamble
然后我运行命令:
make4ht -ux -f odt -c myconfig.cfg main.out.tex
答案1
问题是使用的标签打印在生成的文件的注释中(t4htlink
由后处理脚本替换为正确的元素):
<!--l. 48--><text:p text:style-name="Text-body">Fig. <t4htlink
href="#x1-1doc"><!--tex4ht:ref: aa--bb --></t4htlink>.
这会导致 XML 无效,因为注释不能包含字符串--
。最简单的解决方案是不在注释中打印标签。尝试以下 cfg 文件:
\Preamble{xhtml}
\xeuniuseblock{Greek}
\xeuniuseblock{Arabic}
\makeatletter
\ConfigureEnv{arab}{\@rltrue}{\@rlfalse}{}{}
\Configure{ref}{\Link}{\EndLink}{}
\makeatother
\begin{document}
\EndPreamble
最重要的一行是:
\Configure{ref}{\Link}{\EndLink}{}
它将\ref
命令配置为仅打印链接,不打印注释。