I'm building a cloud system to which people will upload their LaTeX sources and it will compile them. This is not a general purpose system - it is tied to a specific .cls file for a journal. The system is built around texlive with lualatex and our own .cls file. We decided that we cannot use pdflatex because it seems incapable of producing UTF-8 encoded files with \write and this is necessary for our workflow. Unfortunately in spite of the advice given to authors, some authors still by habit insert \usepackage[T1]{fontenc} into their uploaded files, and the outcome is that some UTF-8 characters in their original files become mangled by the T1 font encoding. In our .cls file I would like to issue a ClassError if this is used, but for some reason fontenc evades detection from \@ifpackageloaded (presumably so it can be loaded multiple times). I have instead settled upon using etoolbox with

    \ClassError{jcls}{The fontenc package is not allowed. Please use unicode font encoding.}{}}{}

I don't really like this method because it feels like a hack (but maybe no worse than fontenc itself). Another way to do this is to have the .cls file require lualatex, but some authors will prefer to develop with pdflatex because it's faster and we only need it for the final versions of the papers. As an alternative I thought about just removing fontenc from our texlive installation. Can anyone suggest a better way to do this?

1 Answer 1


pdflatex because it seems incapable of producing UTF-8 isn't right but there are lots of other good reasons.

You can't easily remove or disable fontenc as it is needed to build the formats and is input if you use fontspec to load any fonts in luatex or xetex.

What you can do is complain at begin document if the current encoding is not TU, or simply force that it is TU;


% in your class

\usepackage[T1]{fontenc} % bad in luatex but auto-corrected



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .