Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r zr-tex8r/bxexpl3ptex.sty
Last active Dec 19, 2018

Embed
What would you like to do?
LaTeX: To correct the engine detection of expl3 in using pLaTeX
% bxexpl3ptex.sty
%% package declaration
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bxexpl3ptex}[2015/07/28 v0.3]
%% hack for \ifpdfprimitive
\let\bxqxp@postproc\relax
\expandafter\ifx\csname ifpdfprimitive\endcsname\relax
\expandafter\@firstofone
\else \expandafter\@gobble
\fi {%
\let\bxqxp@ifpdfprimitive\ifpdfprimitive
\let\ifpdfprimitive\ifdefined
\def\bxqxp@postproc{%
\let\ifpdfprimitive\bxqxp@ifpdfprimitive
\let\bxqxp@ifpdfprimitive\@undefined
\let\bxqxp@postproc\relax
}%
}
%% do it
\RequirePackageWithOptions{expl3}
\bxqxp@postproc
\ExplSyntaxOn
%--------------------------------------- adjustments
\cs_new_eq:NN \ptex_if_engine:T \use_none:n
\cs_new_eq:NN \ptex_if_engine:F \use:n
\cs_new_eq:NN \ptex_if_engine:TF \use_ii:nn
\cs_new_eq:NN \ptex_if_engine_p: \c_false_bool
\cs_new_eq:NN \uptex_if_engine:T \use_none:n
\cs_new_eq:NN \uptex_if_engine:F \use:n
\cs_new_eq:NN \uptex_if_engine:TF \use_ii:nn
\cs_new_eq:NN \uptex_if_engine_p: \c_false_bool
\str_if_eq_x:nnT { \token_to_meaning:N \kanjiskip }
{ \token_to_str:N \kanjiskip }
{
% I'm pTeX! The current judge is:
% pdftex_if_engine = true
% luatex_if_engine = false
% xetex_if_engine = false
\cs_gset_eq:NN \ptex_if_engine:T \use:n
\cs_gset_eq:NN \ptex_if_engine:F \use_none:n
\cs_gset_eq:NN \ptex_if_engine:TF \use_i:nn
\cs_gset_eq:NN \ptex_if_engine_p: \c_true_bool
% I'm not pdfTeX.
\cs_gset_eq:NN \pdftex_if_engine:T \use_none:n
\cs_gset_eq:NN \pdftex_if_engine:F \use:n
\cs_gset_eq:NN \pdftex_if_engine:TF \use_ii:nn
\cs_gset_eq:NN \pdftex_if_engine_p: \c_false_bool
}
\str_if_eq_x:nnT { \token_to_meaning:N \forcecjktokens }
{ \token_to_str:N \forcecjktokens }
{
% I'm upTeX!
\cs_gset_eq:NN \uptex_if_engine:T \use:n
\cs_gset_eq:NN \uptex_if_engine:F \use_none:n
\cs_gset_eq:NN \uptex_if_engine:TF \use_i:nn
\cs_gset_eq:NN \uptex_if_engine_p: \c_true_bool
}
%--------------------------------------- done
\ExplSyntaxOff
\endinput
%% EOF
@zr-tex8r

This comment has been minimized.

Copy link
Owner Author

commented Nov 27, 2014

Usage

  • Load this package instead of expl3. This package loads internally expl3, passing all the given options.
  • If there is a package that internally loads expl3, then load this package before such package.

How to use the media9 package on pLaTeX + dvipdfmx:

\documentclass[...,dvipdfmx]{article}
\usepackage{bxexpl3ptex}% at the beginning of preamble
\usepackage{media9}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.