Skip to content

Instantly share code, notes, and snippets.

%! TEX program = pdflatex
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\ExplSyntaxOn
\cs_new_protected:Npn \__uniscript_continue_superscript:w {
\peek_meaning_remove:NTF \egroup {
\expandafter \__uniscript_continue_superscript_aux:w \exp:w \exp_end_continue_f:w
@user202729
user202729 / TeX-benchmark-lines.tex
Created April 8, 2023 03:04
TeX benchmark how much time each line takes. Refer to https://tex.stackexchange.com/a/632367/250119
\usepackage{luacode}
\begin{luacode*}
require "socket"
lasttime=socket.gettime()
luatexbase.add_to_callback('process_input_buffer',
function()
local newtime=socket.gettime()
local delta=newtime-lasttime
if delta >= 0.001 then
print(("\n%.4f\t%s:%d"):format(delta, token.get_macro("currfilename"), tex.inputlineno))
% [REDUNDANT refer to https://tex.stackexchange.com/questions/590362/how-to-get-the-row-height-and-column-width-within-a-tabular?noredirect=1&lq=1 ]
%! TEX program = lualatex
\documentclass{article}
\begin{document}
\pagenumbering{gobble}
\halign{%
#&#&#\cr
12&34&56\cr
%\hrulefill
@user202729
user202729 / watching-mupdf.py
Last active September 30, 2025 08:35
watching-mupdf script: Wrapper around mupdf to allow automatically refreshing on file change, see also https://unix.stackexchange.com/questions/425907/how-to-make-mupdf-automatically-refresh-a-document
#!/bin/python3
from pathlib import Path
import sys
import argparse
parser=argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("filename", type=Path)
args=parser.parse_args()
if not args.filename.is_file():
" https://vi.stackexchange.com/questions/34557/how-can-i-use-let-gnetrw-keepdir-0-for-folders-and-autochdir-for-files
set noautochdir " otherwise it conflict with netrw. Implement manually
let g:netrw_keepdir = 0 " i.e. pwd = current browsing directory
function NetrwCheckAcd()
" could also be "terminal" or something in which case do nothing
if &buftype==""
if isdirectory(expand("%"))
call chdir(expand("%")) " this is still necessary even with g:netrw_keepdir when triggered through remote vim...? TODO
@user202729
user202729 / note on zathura exec.md
Created January 21, 2023 03:46
note on zathura exec with file name contain special characters

All of the existing answers have some quirk, so I decide to dig into the source code and see what I can come up with.

The result:

It does handle # as a comment character, which mean if a file name is something like ' # ' # " # " # then it's impossible to escape it properly, as far as I can see.

@user202729
user202729 / README.md
Last active January 11, 2023 08:15
Backup version 0.0.0 of pythonimmediate TeX package
%! TEX program = lualatex
\documentclass{article}
\usepackage{pythonimmediate}
\usepackage[linguistics]{forest}
\begin{pycode}
from pythonimmediate import newcommand, get_arg_str, get_optional_arg_str, print_TeX
@newcommand
def coolphase():
%! TEX program = lualatex
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\catcode `\^^L \active
\outer\def ^^L {}