2

I could not find exactly where the error is generated, but I've made a small example to reproduce it.

The example file is:

\documentclass{example}
\begin{document}
\keywords{ábaba \sep Abba2 \sep Ababa3}
\end{document}

Using the following example template:

\ProvidesClass{example}[2022/03/16 Example class]
\ProcessOptions\relax
\ExecuteOptions{}
\LoadClass{article}
\RequirePackage{mfirstuc}
% KEYWORDS % requires: mfirstuc
\def\sep{\unskip. }%
\newcommand{\capitalizekeywords}[2][\sep]{%
    \def\dolist##1{\expandafter\@dolist##1#1\@eol}%
    \def\@dolist##1#1##2\@eol{%
        \begingroup\setbox0=\hbox{##1\unskip}\ifdim\wd0=0pt\endgroup\else\endgroup\ignorespaces\makefirstuc{##1}\unskip\sep\fi%
    \ifx\@eol##2\@eol\else\@dolist##2\@eol\fi}%
    \dolist{#2}%
}
\newcommand{\keywords}[1]{%
    \emph{Keywords}: \capitalizekeywords{#1}\par
}

Compiling with XeLaTeX works fine, but make4ht crashes with the following error:

[ERROR]   htlatex: ./example.tex        3        Missing \endcsname inserted.
[ERROR]   htlatex: ./example.tex        3        Undefined control sequence.
[ERROR]   htlatex: ./example.tex        3        Undefined control sequence.[ERROR]   htlatex: ./example.tex        3        Undefined control sequence.
[ERROR]   htlatex: ./example.tex        3        Undefined control sequence.
[ERROR]   htlatex: ./example.tex        3        Use of \\capitalizekeywords doesn't match its definition.
[ERROR]   htlatex: ./example.tex        3        Use of \\capitalizekeywords doesn't match its definition.
[ERROR]   htlatex: ./example.tex        3        Use of \\capitalizekeywords doesn't match its definition.
[ERROR]   htlatex: ./example.tex        3        Argument of \@dolist has an extra }.[ERROR]   htlatex: ./example.tex        3        Paragraph ended before \@dolist was complete.[ERROR]   htlatex: ./example.tex        3        Extra \else.

Note 1: When the commands are defined directly in the .tex file, no error is generated.

Note 2: When there is no diacritical mark in the first character, for example: \keywords{abába \sep Abba2 \sep Ababa3}, no error occurs.

1
  • 1
    I don't know the answer to your question i.e., why it doesn't work with make4ht or make4ht -x, but from playing around with your samples, it seems like it works when compiling with the lua backend: make4ht -l test.tex.
    – frabjous
    Mar 16 at 19:03

1 Answer 1

3

Try this version of example.cls:

\ProvidesClass{example}[2022/03/16 Example class]
\ProcessOptions\relax
\ExecuteOptions{}
\LoadClass{article}
%\RequirePackage{mfirstuc}
% KEYWORDS % requires: mfirstuc
\def\sep{\unskip. }%
\ExplSyntaxOn
\newcommand{\capitalizekeywords}[2][\sep]{%
    \def\dolist##1{\expandafter\@dolist##1#1\@eol}%
    \def\@dolist##1#1##2\@eol{%
      \begingroup\setbox0=\hbox{##1\unskip}\ifdim\wd0=0pt\endgroup\else\endgroup\ignorespaces\text_titlecase_first:n{##1}\unskip\sep\fi%
    \ifx\@eol##2\@eol\else\@dolist##2\@eol\fi}%
    \dolist{#2}%
}
\ExplSyntaxOff
\newcommand{\keywords}[1]{%
    \emph{Keywords}: \capitalizekeywords{#1}\par
}

It uses a new LaTeX internal command, text_titlecase_first:n. It seems to work better in this case. The sample file can be compiled with all LaTeX engines supported by TeX4ht without runtime error. With LuaLaTeX and LaTeX, you will also get correct uppercase words. With XeLaTeX though, you will not get uppercase for accented characters. This is caused by the way how TeX4ht handles accented characters with XeLaTeX, and I am not sure that it can be fixed.

The result with make4ht -l sample.tex (LuaLaTeX):

enter image description here

Result with make4ht -x sample.tex (XeLaTeX):

enter image description here

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.