If I create a package, is it correct to use \RequirePackage[utf8]{inputenc} to support utf8. I guess not, but how do I state that this package must (should) be used with inputenc utf8?

  • 1
    well inputenc is only required when using LaTeX or pdfLaTeX. if one uses the newer XeLaTeX or LuaLaTeX, UTF-8 is already required as the input and works natively.
    – ArTourter
    Commented Nov 25, 2012 at 14:49

1 Answer 1


This is what I do in newunicodechar that requires the utf8 option either to inputenc or inputenx and wouldn't work with other options and without either of those packages:

  {This package won't work without loading\MessageBreak
   `inputenc' or `inputenx' with the `utf8' option}%

The \let\newunicodechar\@gobbletwo is just to enable processing the file nonetheless. If you want to require usage of utf8 you can modify it like this:

% Define an error message
  {`inputenc' or `inputenx' loaded with wrong option.\MessageBreak
   This is a fatal error}
  {This package won't work if either `inputenc' or `inputenx'\MessageBreak
   are loaded with the `utf8' option. The LaTeX run will be terminated}%
   \fi\@@end} % the `\fi` is to match `\if@tempswa`
% Check for inputenx or inputenc
% Check for the right option

So if the user types


nothing will be done. But if inputenc (or inputenx) is not loaded before it, xyz will load it. If a wrong option is passed to inputenc, the package will terminate the LaTeX run.

You must log in to answer this question.

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