![将 XeLaTeX 转换为 ePub](https://linux22.com/image/402714/%E5%B0%86%20XeLaTeX%20%E8%BD%AC%E6%8D%A2%E4%B8%BA%20ePub.png)
大家好,
我有一个 XeLaTeX 文件,一旦编译就会产生这样的 pdf 页面:
我需要的是从 tex 文件中获取ePub 格式而不是pdf版本。
因此,在发布所有这些消息之前,我尝试了一些在网上找到的解决方案,例如 Pandoc、latexml 和其他我不记得的解决方案。但每次我都遇到了错误。所以也许你可以帮助我解决这些错误,或者也许你可以帮我找到一个我不知道的新工具来获取 ePub 格式。
为了让您了解 XeLateX 代码是什么样子,这里是一个很好的预览(MWE):
% !TEX encoding = UTF-8 Unicode
\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{lmodern}
\usepackage{array}
\usepackage{verbatim}
\title{{\myfont ``GA 032''}}
\usepackage{layout}
\usepackage[nomarginpar, margin=0.7in]{geometry}
\pagestyle{plain}
\usepackage{polyglossia}
\setmainlanguage{french}
\setotherlanguage{greek}
\newfontfamily\greekfont{KoineGreek}
\newcommand\Pheader{\rule[-2ex]{0pt}{5ex}}
\newsavebox\TBox
\def\textoverline#1{\savebox\TBox{#1}%
\makebox[0pt][l]{#1}\rule[1.1\ht\TBox]{\wd\TBox}{0.7pt}}
% amélioration : ajouter un "padding" sur le tabular + agrandir le tabular et son contenu.
\usepackage{pageslts}
\usepackage{fancyhdr}
\makeatletter
\newcommand{\nospace}[1]{\nofrench@punctuation\texttt{#1}\french@punctuation}
\makeatother
\let\oldtabular\tabular\renewcommand{\tabular}{\large\selectfont\oldtabular} %fontsize{17pt}{20.5pt}
\usepackage[hidelinks]{hyperref}
\newcounter{gospelbook}
\setcounter{gospelbook}{1}
\newcommand{\mygospelbook}[1]
{\setcounter{gospelchapter}{1}\phantomsection\addcontentsline{toc}{part}{#1}#1}
\newcommand{\agospelbook}[1]{\addtocontents{toc}{\protect\newpage}\mygospelbook{#1}}
\newcounter{gospelchapter}
\newcommand{\mygospelchapter}{\phantomsection\addcontentsline{toc}{section}{\thegospelchapter}\LARGE\bfseries\thegospelchapter\refstepcounter{gospelchapter}}
\begin{document}
\renewcommand{\contentsname}{Sommaire}
\font\myfont=cmr12 at 21pt
%\layout
\maketitle % affiche le nom du manuscrit.
\pagenumbering{roman}
\thispagestyle{empty}\clearpage\setcounter{page}{1}
\newpage
\foreignlanguage{greek}{\tableofcontents}
\clearpage\pagenumbering{arabic}\setcounter{page}{1}
\clearpage
\newpage
{
\setlength\arrayrulewidth{1pt}
\begin{table}
\begin{center}
\begin{tabular}{ccc|l|ccc}
\cline{4-4} \\ [-1em]
\multicolumn{7}{c}{\mygospelbook{\foreignlanguage{greek}{ευαγγελιον κατα μαθθαιον}} \textbf{(\nospace{1:1})} } \\ \\ [-1em] % Si on veut ajouter les bordures latérales, remplacer {7}{c} par {7}{|c|}
\cline{4-4} \\
\cline{4-4}
& & & & & & \\ [-0.9em]
& \mygospelchapter & & \foreignlanguage{greek}{βιβλοϲ γενεϲεωϲ \textoverline{ιυ} \textoverline{χυ} υιου δαυειδ} & 6 & & \\
& & 7 & \foreignlanguage{greek}{υιου αβρααμ αβρααμ εγεννηϲεν τον} & 3 & \textbf{2} & \\
& & 4 & \foreignlanguage{greek}{ιϲαακ ιϲαακ δε εγεννηϲεν τον ια} & 9 & & \\
& & 9 & \foreignlanguage{greek}{κωβ ιακωβ δε εγεννηϲεν τον ιουδαν} & 14 & & \\
& & 15 & \foreignlanguage{greek}{και τουϲ αδελφουϲ αυτου ιουδαϲ δε} & 2 & \textbf{3} & \\
& & 3 & \foreignlanguage{greek}{εγεννηϲεν τον φαρεϲ και τον ζαρα} & 8 & & \\
& & 9 & \foreignlanguage{greek}{εκ τηϲ θαμαρ φαρεϲ δε εγεννηϲεν} & 14 & & \\
& & 15 & \foreignlanguage{greek}{τον εζρωμ εζρωμ δε εγεννηϲεν το̅} & 20 & & \\
& & 21 & \foreignlanguage{greek}{αραμ αραμ δε εγεννηϲεν τον αμινα} & 5 & \textbf{4} & \\
& & 5 & \foreignlanguage{greek}{δαβ αμιναδαβ δε εγεννηϲεν τον} & 9 & & \\
& & 10 & \foreignlanguage{greek}{νααϲϲων νααϲϲων δε εγεννηϲε̅} & 13 & & \\
& & 14 & \foreignlanguage{greek}{τον ϲαλμων ϲαλμων δε εγεννηϲε̅} & 3 & \textbf{5} & \\
& & 4 & \foreignlanguage{greek}{τον βοοζ εκ τηϲ ραχαβ βοοζ δε εγε̅} & 11 & & \\
& & 11 & \foreignlanguage{greek}{νηϲεν τον ωβηδ εκ τηϲ ρουθ ωβηδ} & 17 & & \\
& & 18 & \foreignlanguage{greek}{δε εγεννηϲεν τον ειεϲϲαι ιεϲϲαι δε} & 2 & \textbf{6} & \\
& & 3 & \foreignlanguage{greek}{εγεννηϲεν τον δαυειδ τον βαϲιλεα} & 7 & & \\
& & 8 & \foreignlanguage{greek}{δαυειδ δε ο βαϲιλευϲ εγεννηϲεν το̅} & 13 & & \\
& & 14 & \foreignlanguage{greek}{ϲολομωντα εκ τηϲ του ουριου ϲολο} & 1 & \textbf{7} & \\
& & 1 & \foreignlanguage{greek}{μων δε εγεννηϲεν τον ροβοαμ} & 5 & & \\
& & 6 & \foreignlanguage{greek}{ροβοαμ δε εγεννηϲεν τον αβια αβι} & 11 & & \\
& & 11 & \foreignlanguage{greek}{α δε εγεννηϲεν τον αϲα αϲα δε εγε̅} & 3 & \textbf{8} & \\
& & 3 & \foreignlanguage{greek}{νηϲεν τον ιωϲαφατ ιωϲαφατ δε} & 7 & & \\
& & 8 & \foreignlanguage{greek}{εγεννηϲεν τον ιωραμ ιωραμ δε εγε̅} & 13 & & \\
& & 13 & \foreignlanguage{greek}{νηϲεν τον οζειαν οζειαϲ δε εγεννη} & 3 & \textbf{9} & \\
& & 3 & \foreignlanguage{greek}{ϲεν τον ιωαθαμ ιωαθαμ δε εγεννη} & 9 & & \\
& & 9 & \foreignlanguage{greek}{ϲεν τον αχαζ αχαζ δε εγεννηϲεν} & 14 & & \\
& & 15 & \foreignlanguage{greek}{τον εζεκιαν εζεκιαϲ δε εγεννηϲε̅} & 3 & \textbf{10} & \\
& & 4 & \foreignlanguage{greek}{τον μαναϲϲη μαναϲηϲ δε εγεννη} & 8 & & \\
& & 8 & \foreignlanguage{greek}{ϲεν τον αμων αμων δε εγεννηϲεν} & 13 & & \\
& & 14 & \foreignlanguage{greek}{τον ιωϲιαν ιωϲιαϲ δε εγεννηϲεν το̅} & 4 & \textbf{11} & \\
[0.2em]
\cline{4-4}
\end{tabular}
\end{center}
\end{table}
}
\end{document}
以下是我以前使用的工具可能出现的一些错误:
我在用着macOS Mojave10.14.6
- Pandoc(v 2.7.3):
Error at "source" (line 68, column 65):
unexpected \rule
& \mygospelchapter & & \foreignlanguage{greek}{βιβλοϲ γενεϲεωϲ \textoverline{ιυ} \textoverline{χυ} υιου δαυειδ} & 6 & & \\
- text4h(没有找到版本号,但正常情况下应该是最后一个):
tex4ht.c (2012-07-25-19:36 kpathsea)
tex4ht test.tex
--- warning --- Can't find/open file `test.dvi'
--- error --- Can't find/open file `test.dvi'
- 我不记得从哪里得到这个错误:
Can't locate Alien/Libxml2.pm in @INC (you may need to install the Alien::Libxml2 module) (@INC contains: /usr/local/Cellar/perl/5.30.0/lib/perl5/site_perl/5.30.0/darwin-thread-multi-2level /usr/local/Cellar/perl/5.30.0/lib/perl5/site_perl/5.30.0 /usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0/darwin-thread-multi-2level /usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0 /usr/local/lib/perl5/site_perl/5.30.0/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.30.0) at Makefile.PL line 20.
BEGIN failed--compilation aborted at Makefile.PL line 20.
- 当我
perl Makefile.PL
从 LaTeXML 文件夹中安装 Makefile.PL时latexml。
"/usr/local/Cellar/perl/5.26.1/bin/perl" -MParse::RecDescent - lib/LaTeXML/MathGrammar LaTeXML::MathGrammar Parse::RecDescent
Can't locate Parse/RecDescent.pm in @INC (you may need to install the Parse::RecDescent module) (@INC contains: /usr/local/Cellar/perl/5.26.1/lib/perl5/site_perl/5.26.1/darwin-thread-multi-2level /usr/local/Cellar/perl/5.26.1/lib/perl5/site_perl/5.26.1 /usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level /usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1 /usr/local/lib/perl5/site_perl/5.26.1/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.26.1).
BEGIN failed--compilation aborted.
make: *** [blib/lib/LaTeXML/MathGrammar.pm] Error 2
- 当我尝试执行时latexml(没有找到版本号,但正常情况下应该是最后一个):
Can't locate XML/LibXML.pm in @INC (you may need to install the XML::LibXML module) (@INC contains: /usr/local/Cellar/latexml/0.8.4/libexec/bin/../lib /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/darwin-thread-multi-2level /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5 /usr/local/Cellar/perl/5.30.0/lib/perl5/site_perl/5.30.0/darwin-thread-multi-2level /usr/local/Cellar/perl/5.30.0/lib/perl5/site_perl/5.30.0 /usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0/darwin-thread-multi-2level /usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0 /usr/local/lib/perl5/site_perl/5.30.0/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.30.0) at /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/LaTeXML/Common/Object.pm line 16.
BEGIN failed--compilation aborted at /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/LaTeXML/Common/Object.pm line 16.
Compilation failed in require at /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/LaTeXML/Common/Error.pm line 16.
BEGIN failed--compilation aborted at /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/LaTeXML/Common/Error.pm line 16.
Compilation failed in require at /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/LaTeXML/Core.pm line 18.
BEGIN failed--compilation aborted at /usr/local/Cellar/latexml/0.8.4/libexec/lib/perl5/LaTeXML/Core.pm line 18.
Compilation failed in require at /usr/local/Cellar/latexml/0.8.4/libexec/bin/latexml line 19.
BEGIN failed--compilation aborted at /usr/local/Cellar/latexml/0.8.4/libexec/bin/latexml line 19.
- 当我尝试使用名为 SimpleTeX4ht (v 3.3) 的软件时:
Package: fontspec 2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Fatal fontspec error: "cannot-use-pdftex"
!
! The fontspec package requires either XeTeX or LuaTeX.
!
! You must change your typesetting engine to, e.g., "xelatex" or
! "lualatex"instead of plain "latex" or "pdflatex".
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.28 \msg_fatal:nn {fontspec} {cannot-use-pdftex}
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a fatal error: LaTeX will abort.
|...............................................
谢谢你的帮助!
答案1
您的文档使用 编译时没有任何问题tex4ht
,您只需提供一个小型配置文件并请求支持XeTeX
,默认情况下不使用。如果您想要 ePub 文件,您可以使用tex4ebook
基于 的 LaTeX 到电子书转换器tex4ht
。我发现了一个额外的问题,它本身不受影响tex4ht
,但会影响tex4ebook
。
\myfont
我不得不稍微修改一下你的文档,特别是在第一次使用之前我移动了定义:
\font\myfont=cmr12 at 21pt
\title{{\myfont ``GA 032''}}
需要声明用于tex4ht
XeTeX 支持的 Unicode 块,因此我创建了一个添加对希腊语支持的配置文件:
\Preamble{xhtml}
\xeuniuseblock{Greek}
\begin{document}
\makeatletter
\nofrench@punctuation%
\makeatother
\EndPreamble
修复\nofrench@punctuation
了tex4ebook
目录中使用活动字符的问题。
可以使用以下方法转换文档:
tex4ebook -xc config.cfg filename.tex
结果如下: