Skip to content

Instantly share code, notes, and snippets.

Last active Feb 12, 2022
What would you like to do?
LaTeX: Which kind of “LaTeX” am I using?
%% This is file 'hello.tex'.
%% Copyright (c) 2018-2020 Takayuki YATO (aka. "ZR")
%% GitHub:
%% Twitter: @zr_tex8r
%% This file is distributed under the MIT License.
\makeatletter %!!!!!!!!!!!!!!!!!!!!!!!!! TeX code BEGIN
%--------------------------------------- engine check
%% \my@if@primitive
\ifx\my@tmpa\my@tmpb \expandafter\@firstoftwo
\else \expandafter \@secondoftwo \fi}
%% \my@engine : TeX engine type
%% \ifmy@pdf
\ifnum\@tempcnta>\z@ \my@pdftrue \fi
\if X\my@engine \my@pdftrue \fi
\if A\my@engine \my@pdftrue \fi
%% LuaTeX variants
\if L\my@engine \ifx\luatexbanner\@undefined\else
local s = "\luaescapestring{\luatexbanner}"
if s:match("LuajitTeX") then tex.write("1")
elseif s:match("HarfTeX") then tex.write("2")
elseif s:match("LuaHBTeX") then tex.write("3")
else tex.write("0")
\or \let\my@engine=I % LuajitTeX
\or \let\my@engine=F % HarfTeX
\or \let\my@engine=H % HarfTeX
%% \my@lmodern
\if X\my@engine
\expandafter\ifx\csname T@TU\endcsname\relax
%%<+> \myEngineName
% Prints the name of the *LaTeX* engine in use.
\ifx P\my@engine
\ifmy@pdf pdf\/\fi \LaTeX
\else\ifx o\my@engine Lamed% forget about Lambda
\else\ifx L\my@engine Lua\LaTeX
\else\ifx I\my@engine Luajit\LaTeX
\else\ifx F\my@engine Lua\LaTeX\ (on Harf\TeX)%
\else\ifx H\my@engine Lua\LaTeX\ (on LuaHB\TeX)%
\else\ifx X\my@engine \begingroup
\my@lmodern X\kern-.125em\lower.5ex\hbox{\char"018E}%
\else\ifx p\my@engine p\LaTeX
\else\ifx u\my@engine up\LaTeX
\else\ifx A\my@engine Ap\LaTeX
\else\ifx j\my@engine
\leavevmode\lower.5ex\hbox{J}\kern-.1em \LaTeX
\else \LaTeX % good old...
%--------------------------------------- dvips or dvipdfmx
%% \my@hedge
%% \my@ps
%% \my@F
\def\my@F{gsave newpath F grestore 0 () gsave p grestore pop }
%% \my@dvips@or@pdf{<dvips>}{<dvipdfmx>}
\my@ps{currentpoint pop /F exch def}%
\my@ps{currentpoint pop \my@F sub /F exch def \my@F neg 0 translate}%
\kern-\my@hedge \hb@xt@\z@{#2\hss}%
\my@ps{\my@F 0 translate}}
%%<+> \myDviPsOrPdf{<trailer>}
% Would print either 'dvips' or 'dvipdfm' plus the trailer, according
% to the DVI driver actually in use. Note that the reference point
% does not advance.
%--------------------------------------- main
%%<+> \myWorkflowName{<trailer>}
\ifmy@pdf #1%
\else \space+\space \myDviPsOrPdf{#1}%
\par}% avoid the influence of zero-advance
\makeatother %!!!!!!!!!!!!!!!!!!!!!!!!! TeX code END
Hello, \myWorkflowName{!}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment