Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created January 21, 2022 13:47
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/ef5f55c08cd3fa92558183cbe8bb3983 to your computer and use it in GitHub Desktop.
Save zr-tex8r/ef5f55c08cd3fa92558183cbe8bb3983 to your computer and use it in GitHub Desktop.
TeX: Make the TeX error messages cute. (for LuaLaTeX)
%%
%% This is file 'scluamessages.sty'.
%%
%% Copyright (c) 2022 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%
%% package declaration
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{scluamessages}[2022/01/21 v0.2]
\def\sczlm@pkgname{scluamessages}
%--------------------------------------- Check environment
\RequirePackage{iftex}
\RequireLuaTeX
%--------------------------------------- Apply Lua hooks
\begingroup \catcode`\#=12 \catcode`\~=12 \catcode`\^=7
\catcode`\^^\=0 \catcode10=12 \endlinechar=10
\catcode32=12\catcode`\\=12{}^^\directlua{
local message = [[
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
____
___HHHH _____ WOW!
/ . . \ |YEAH!| You've got a great TeX error!!
\ --- / |~~~~~
V :#######: Y
\/ o*"*\/
{ o }
\_______/ HURRAY!!
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::]]
luatexbase.add_to_callback("show_error_hook", function()
texio.write("", ".")
texio.write_nl("", message)
end, "improve TeX error messages")
}^^\endgroup%
%--------------------------------------- All done
\endinput
%% EOF
%#!lualatex
\documentclass[a4paper]{article}
\usepackage{scluamessages}% NICE!!!
\begin{document}
This is a test.
\parbox{t}{6em}{Hello,\\\TeX\\world!}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment