make4ht 中的数学和德语字符

make4ht 中的数学和德语字符

我在使用 make4ht 编译包含数学符号和特殊德语字符的文件时遇到了问题。如果我使用选项 -u,我会在 head 部分获得 charset="utf-8",数学可以正确显示,但德语字母 (Umlaute) 只是奇怪的符号。如果我在 head 部分插入(使用单独的编辑器)charset="iso-8859-1",我可以正确看到德语字母,但数学却很糟糕。有人知道怎么做吗?这样 Umlaute 就可以在文本中正确显示,数学也可以正确显示?下面是更多信息,我会提供我所拥有的一切。祝好,克里斯蒂安

在 tex 代码中我使用以下包:

\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[ngerman]{babel}
\usepackage{eurosym}
\usepackage{amsfonts}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{minitoc}
\usepackage{verbatim}
\usepackage{hyperref}
\usepackage{textcomp}
\usepackage{tabularx}
\usepackage{etoc}

命令是

make4ht dynvwl.tex minitoc,fn-in,0,index=4,frames,section+,next -c dynvwl.cfg -e dynvwl.mk4 "mathml,mathjax"

(我尝试过使用和不使用选项 -u)。

该cfg文件是:

\Preamble{xhtml,mathml,mathjax}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{
    \HCode{
    <meta http-equiv="Content-Type" content="text/html" charset="iso-8859-1" />\Hnewline % Das Charset sollte auf iso-8859-1 gestellt werden, damit die Umlaute richtig angezeigt werden.
    <link type="text/css" rel="stylesheet" media="all" href="https://dynamische-vwl.de/style.css" />\Hnewline %Haupt-Stylesheet
%    <link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>\Hnewline
    <link rel="stylesheet" type="text/css" href="https://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />\Hnewline
    <script charset="UTF-8" src='https://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js' type='text/javascript'></script>\Hnewline
    <script src='https://jsxgraph.uni-bayreuth.de/distrib/GeonextReader.js' type='text/javascript'></script>\Hnewline
    <link type="text/css" rel="stylesheet" href="protex/style.css" />\Hnewline %Eigenes Stylesheet für notwendige Anpassungen.
}}

%ersetzten der \initJXGBOARD Varaiblen

%Einfügen des VG-Wort-Zählpixels auf jeder Seite
\Configure{@BODY}{\HCode{<img src="https://vg08.met.vgwort.de/na/ac8bfb254cff4060b2808f78a90a5da5" width="1" height="1" alt="" />}}

%Einfügen der Navigationssidebar/des Inhaltsverzeichnisses auf jeder Seite
\Configure{@BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="mainnavigation"><a href="https://dynamische-vwl.de/"><img src="protex/images/logo.png" /></a><a href="./englisch/"><img src="protex/images/FlagEng.png" /></a>}\TableOfContents\HCode{</div>}}
    % Der gesamte Text wird in das Blockelement "textkoerper" gepackt, um ihn sauber vom Inhaltsverzeichnis trennen zu können.
    \Configure{@BODY}{\HCode{<div class="textkoerper">}}

%Einfügen der Fußzeile und Schließen des textkoerper-div
\Configure{@/BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{<div id="fusszeile"><hr />}(c) by Christian Bauer\\Prof. Dr. Christian Bauer\\Lehrstuhl für monetäre Ökonomik\\Universität Trier\\D-54296 Trier\\Tel.: +49 (0)651/201-2743\\E-mail: [email protected]\\URL: \url{https://www.cbauer.de}\HCode{</div></div>}}

%Umbeschriften der "Mini-Navigation" über und unter dem Text %\Configure{crosslinks} {left-delimiter} {right-delimiter} {next} {prev} {prev-tail} {front} {tail} {up}
\Configure{crosslinks}{\space[}{]}{Weiter}{Zurück}{Zurück (Ende)}{Anfang}{Ende}{Hoch}

% Einteilung des Buches in mehrere HTML-Seiten. Funktionsweise am Beispiel des ersten Eintrags: 
%   \CutAt{part,likepart,appendix}
%    Jeder \part erzeugt eine neue HTML-Datei, welche grundsätzlich alles bis zum nächsten \part umfasst. Die Optionen likepart und appendix geben an, dass \part* und \appendix dennoch nicht eingefasst werden, ergo wiederum einen Cut erzeugen.
\CutAt{part,likepart,appendix}
\CutAt{chapter,appendix,part,likepart}
% \Configure{endchapter}{chapter,section}
\CutAt{section,likesection}
\CutAt{subsection,likesubsection}

\Configure{paragraph}{}{}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="paragraphHead">}}{\HCode{</div>}}

\TocAt{part,chapter,section}
\TocAt{chapter,section}
% \def\Tocchapter{\TableOfContents[chapter]}
\TocAt{section,subsection}

%Sorgt glaube ich dafür, dass nicht jeder <p> intendiert.
\Configure{HtmlPar}
{\EndP\Tg<p>}
{\EndP\Tg<p>}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}

 \begin{document}
 \EndPreamble

答案1

问题出在你的命令上:

make4ht dynvwl.tex minitoc,fn-in,0,index=4,frames,section+,next -c dynvwl.cfg -e dynvwl.mk4 "mathml,mathjax"

您有两组不同的选项要传递给 TeX4ht:"minitoc,fn-in,0,index=4,frames,section+,next""mathml,mathjax"。第二组选项被误解了,它会覆盖正确 Unicode 输出的选项。正确的调用是:

make4ht  -c dynvwl.cfg -e dynvwl.mk4  dynvwl.tex "minitoc,fn-in,0,index=4,frames,section+,next,mathml,mathjax"

总是把make4ht选项放在 TeX 文件名之前,把 TeX4ht 选项放在之后,以避免出现这样的意外。

示例文件如下所示:

\documentclass{article}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[ngerman]{babel}
\usepackage{eurosym}
\usepackage{amsfonts}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{minitoc}
\usepackage{verbatim}
\usepackage{hyperref}
\usepackage{textcomp}
\usepackage{tabularx}
\usepackage{etoc}
\begin{document}
äüöůw

\"u\"a

$\"a=2$

\end{document}

结果:

在此处输入图片描述

丢失的图片在您的 .cfg 文件中使用,它们在我的计算机上不起作用,因为我无法访问它们。

相关内容