Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Last active April 14, 2022 15:27
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/e3b1e10fb810b6a8d5a364ed5f7f9c24 to your computer and use it in GitHub Desktop.
Save zr-tex8r/e3b1e10fb810b6a8d5a364ed5f7f9c24 to your computer and use it in GitHub Desktop.
LaTeX: HiTeXでgraphicxパッケージしたいやつ

HiTeXでgraphicxパッケージしたいやつ

これらのファイルをTeXから見える場所に置く。
HiTeXでgraphics/xパッケージを読み込むと自動的にzrhitex.defが適用される。

注意

あまり期待しないように🙃

  • 現状のHINTフォーマットではカラーは未サポートのため、カラー指定は無視される。
  • 画像ファイル形式については、少なくともPNGとJPEGはサポートされているようだ。
  • 画像サイズは自動判定されないので、bbオプションまたは.xbbファイルの利用が必須である。
  • 画像ファイルはフルパスで指定する必要がある。

A dumb graphicx driver file for HiTeX

Put these files in the directory where TeX can find files.
Then zrhitex.def will be automatically applied when graphic/x package is loaded on HiTeX engine.

Note

Don’t expect too much!🙃

  • The current HINT format does not support color. Color is simply ignored.
  • THe supported image file type seems to include PNG and JPEG.
  • The image size is not auto-determined. You must use the bb option or .xbb files created by the extractbb utility.
  • Image files need to be given in full path.
\ProvidesFile{color.cfg}[2022/04/10 v0.1]
\begingroup
\chardef\x=0\relax
% check luatex
\ifx\luatexversion\@undefined
% check pdfTeX
\@ifundefined{pdfoutput}{}{%
\ifnum\pdfoutput<1 %
\else
\chardef\x=1\relax
\fi
}%
% check VTeX
%\@ifundefined{OpMode}{}{%
% \chardef\x=2\relax
%}%
% check HiTeX
\@ifundefined{HINTversion}{}{%
\chardef\x=2\relax
}%
% check XeTeX
\@ifundefined{XeTeXversion}{}{%
\chardef\x=3\relax
}%
\else
\ifnum\luatexversion>85
\ifnum\outputmode>0
\chardef\x=4\relax
\fi
\else
\ifnum\pdfoutput>0
\chardef\x=1\relax
\fi
\fi
\fi
\expandafter\endgroup
\ifcase\x
% default case
\def\Gin@driver{dvips.def}%
\ExecuteOptions{dvips}%
\or
% pdfTeX is running in pdf mode
\def\Gin@driver{pdftex.def}%
\ExecuteOptions{pdftex}%
\or
% VTeX is running
%\def\Gin@driver{vtex.def}%
%\ExecuteOptions{vtex}%
% HiTeX is running
\DeclareOption{zrhitex}{\def\Gin@driver{zrhitex.def}}
\ExecuteOptions{zrhitex}%
\or
% XeTeX is running
\def\Gin@driver{xetex.def}%
\ExecuteOptions{xetex}%
\or
% luatex (> 0.85)
\def\Gin@driver{luatex.def}%
\ExecuteOptions{luatex}%
\else
\PackageError{color}{Unexpected configuration}{}
\fi
\DeclareOption{dviout}{\def\Gin@driver{dviout.def}}
\endinput
\ProvidesFile{graphics.cfg}[2022/04/10 v0.1]
\begingroup
\chardef\x=0\relax
% check luatex
\ifx\luatexversion\@undefined
% check pdfTeX
\@ifundefined{pdfoutput}{}{%
\ifnum\pdfoutput<1 %
\else
\chardef\x=1\relax
\fi
}%
% check VTeX
%\@ifundefined{OpMode}{}{%
% \chardef\x=2\relax
%}%
% check HiTeX
\@ifundefined{HINTversion}{}{%
\chardef\x=2\relax
}%
% check XeTeX
\@ifundefined{XeTeXversion}{}{%
\chardef\x=3\relax
}%
\else
\ifnum\luatexversion>85
\ifnum\outputmode>0
\chardef\x=4\relax
\fi
\else
\ifnum\pdfoutput>0
\chardef\x=1\relax
\fi
\fi
\fi
\expandafter\endgroup
\ifcase\x
% default case
\def\Gin@driver{dvips.def}%
\ExecuteOptions{dvips}%
\or
% pdfTeX is running in pdf mode
\def\Gin@driver{pdftex.def}%
\ExecuteOptions{pdftex}%
\or
% VTeX is running
%\def\Gin@driver{vtex.def}%
%\ExecuteOptions{vtex}%
% HiTeX is running
\DeclareOption{zrhitex}{\def\Gin@driver{zrhitex.def}}
\ExecuteOptions{zrhitex}%
\or
% XeTeX is running
\def\Gin@driver{xetex.def}%
\ExecuteOptions{xetex}%
\or
% luatex (> 0.85)
\def\Gin@driver{luatex.def}%
\ExecuteOptions{luatex}%
\else
\PackageError{graphics}{Unexpected configuration}{}
\fi
\DeclareOption{dviout}{\def\Gin@driver{dviout.def}}
\endinput
% zrhitex.def
\ProvidesFile{zrhitex.def}[2022/04/10 v0.1 ZR's dumb HiTeX driver]
\def\color@rgb#1#2{\def#1{.}}
\def\color@cmyk#1#2{\def#1{.}}
\def\color@gray#1#2{\def#1{.}}
\def\color@named#1#2{\def#1{.}}
\def\current@color{.}
\def\set@color{}
\def\reset@color{}
\def\set@page@color{}
\@namedef{Gin@rule@*}#1{{hitex}{.xbb}{#1}}
\def\Ginclude@hitex#1{\message{<#1>}%
\HINTimage #1%
\space width \Gin@req@width
\space height \Gin@req@height}
% Suppress default search on graphic files
% to make \graphicspath work.
\AtBeginDocument{\let\bxqhg@Gin@getbase\Gin@getbase
\let\Gin@getbase\bxqhg@getbase}
\def\bxqhg@getbase{\let\bxqhg@l@IfFileExists\IfFileExists
\let\IfFileExists\bxqhg@IfFileExists
\bxqhg@Gin@getbase}
\def\bxqhg@IfFileExists{\let\IfFileExists\bxqhg@l@IfFileExists
\ifx\input@path\@undefined \def\input@path{{./}}\fi
\@iffileonpath}
\endinput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment