Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created October 2, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/c7c0fd0f904596cf0e7acf72f5f94c5b to your computer and use it in GitHub Desktop.
Save zr-tex8r/c7c0fd0f904596cf0e7acf72f5f94c5b to your computer and use it in GitHub Desktop.
LaTeX: To refuse (u)pTeX and show an essential-esque error
%%
%% This is file 'dcnoptex.sty'.
%%
%% Copyright (c) 2019 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%
%% package declarations
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3,xparse}
\ProvidesExplPackage{dcnoptex}{2019/10/01}{0.2}{quack}
\str_const:Nn \c_dcnoptex_pkgname { dcnoptex }
%--------------------------------------- main
\bool_if:nTF
{
\sys_if_engine_luatex_p:
|| \sys_if_engine_pdftex_p:
|| \sys_if_engine_xetex_p:
}
{
\NewDocumentCommand \dcnoptexCheck { m } { }
}
{%>>>
\NewDocumentCommand \dcnoptexCheck { m }
{
\msg_new:nnnn { #1 } { incompatible }
{
The~#1~package~is~currently~only~compatible~with~
pdfTeX,~LuaTeX,~and~XeTeX!
}
{
\ ~_____________________________\\
\ (Quack!~Sorry~for~that.~Quack!)\\
\ ~"""""""""""""""""""""""""""""\\
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\string\ \\
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~>()_\\
\ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~\ ~(__)__
}
\msg_error:nn { #1 } { incompatible }
}
\endinput
}%<<<
%--------------------------------------- done
\endinput
%% EOF
@zr-tex8r
Copy link
Author

zr-tex8r commented Oct 2, 2019

For LaTeX package developers who can not read Japanese, it is nearly impossible to provide support for the (u)pTeX engines to the packages they are creating, maily because the (u)pTeX community will not provide any information on the engines in English. Thus it is rather sensible to refuse the (u)pTeX engines in advance and throw an error message when they are used.

Just insert the following code in your great LaTeX package:

\RequirePackage{dcnoptex}
\dcnoptexCheck{<package-name>}

That's all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment