3

I was told by Latex experts to use \usepackage{fontspec} with Lualatex. It works ok with lualatex, but now my files do not compile with make4ht any more after I changed to \usepackage{fontspec}. Before I used to use

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 

But now I only use \usepackage{fontspec} as recommended to do. So I do not know why make4ht gives an error when compiling in lualatex mode:

\documentclass[11pt]{article}% 

\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
\usepackage{fontspec}

\begin{document}
test
\end{document}

error

>make4ht --lua  foo7_1.tex
Output dir:     
Compiler:   dvilualatex
Latex options:   -jobname=foo7_1 
tex4ht.sty :    xhtml,
tex4ht  
build_file  foo7_1.mk4
Cannot open config file foo7_1.mk4
setting param correct_exit
setting param correct_exit
setting param correct_exit
setting param ext
Adding:     ext dvi
LaTeX call: dvilualatex  -jobname=foo7_1  '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode xhtml,.a.b.c.\input foo7_1'
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 restricted system commands enabled.
LaTeX2e <2016/03/31> patch level 1
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(./foo7_1.tex (/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size11.clo))
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/tex4ht.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/usepackage.4ht)
(/usr/local/texlive/2016/texmf-dist/tex/generic/luatex85/luatex85.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.sty
 .
 .
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo7_1.aux) (/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3cmr.fd)

! LaTeX Error: Command `\acute' already defined in `'.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.6 \begin{document}

? 

When I tried the suggestion in fontspec-package-accents-bezos-latex-error-command-acute-already

\documentclass[11pt]{article}% 

\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
\usepackage[no-math]{fontspec}
\usepackage{accents}    

\begin{document}
test
\end{document}

I get new error

---------------------------------------------------
--- error --- Can't find/open file `file:lmroman10-regular:script=latn;+trep;+tlig;.tfm'
Make4ht: Fatal error. Command tex4ht returned exit code 256

but lualatex still compiles ok.

Only when I go back to

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 

will now lualatex and make4ht are happy.

I really do not know anything about all these packages, and fonts and all that, I simply want to know what is the correct thing to use, that is all so I do not get errors.

TL 2016 on Linux. I am only using lualatex now. Not pdflatex.

  • 1
    tex4ht probably wants its special font setup so use fontspec for pdf and t1 fontenc (not inputenc) for dviluatex/tex4ht – David Carlisle Jun 29 '16 at 20:50
7

Edit:

Fontspec support have been just added to tex4ht, you can get it after TL update. Both XeLaTeX and LuaLaTeX are supported, although the implementation is different for both engines.

If you use non-latin scripts, you need to use a correct Script option in your font declaration, because all Unicode characters used in the document must be declared first. It is done automatically when you use the Script option.

\documentclass{article}
\usepackage{fontspec}
% \setmainfont{TeX Gyre Termes}
\usepackage{polyglossia}
\setmainlanguage{czech}
\setotherlanguages{greek,russian,hindi}
\newfontfamily\greekfont{Linux Libertine O}[Script=Greek]
\newfontfamily\russianfont{Linux Libertine O}[Script=Cyrillic]
\newfontfamily\hindifont{Siddhanta}[Script=Devanagari]
\begin{document}
Příliš \textit{žluťoučký} kůň \textbf{úpěl} \textsc{ďábelské} ódy.

\begin{greek} 
  Η Πράγα (τσέχικα: Praha), είναι η πρωτεύουσα και μεγαλύτερη πόλη
  της Τσεχίας. Χτισμένη στον ποταμό Μολδάβα (Vltava), στην κεντρική Βοημία,
  έχει 1,2 εκατομμύριο κατοίκους. Αποκαλείται επίσης «η χρυσή πόλη» και «μητέρα
  των πόλεων». Από το 1992, το ιστορικό κέντρο της Πράγας ανήκει στον κατάλογο
  μνημείων παγκόσμιας κληρονομιάς της UNESCO.
\end{greek}

\begin{russian}
  Пра́га (чеш. Praha [ˈpraɦa]) — город и столица Чехии; административный центр
  Среднечешского края и двух его районов — Прага-Восток и Прага-Запад. Образует
  самостоятельную административную единицу страны.
\end{russian}

\begin{hindi}
प्राग युरोप के चेकोस्लोवाकिया देश की राजधानी है।
\end{hindi}


\end{document}

The resulting HTML document:

enter image description here


[Old answer] The convertor from DVI to HTML doesn't support OpenType fonts, which is automatically selected when the Fontspec package is loaded. This is well known tex4ht bug and also one which is hardest to fix.

There are two possible workarounds, both of them require modification of the document, unfortunately.

First is to use conditionally luainputenc package:

\documentclass[11pt]{article}% 

\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
\ifdefined\HCode
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\else
\usepackage{fontspec}
\fi

\begin{document}
test

příliš žluťoučký kůň úpěl \textit{ďábelské ódy}

\end{document}

the other option is to use alternative4ht package from helpers4ht bundle, which contains special configuration for fontspec with tex4ht:

\documentclass[11pt]{article}% 

\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
\usepackage{alternative4ht}
\altusepackage{fontspec}

\begin{document}
test

příliš žluťoučký kůň úpěl \textit{ďábelské ódy}

\end{document}

you can see more features in this document

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.