Last active
February 11, 2026 23:09
-
-
Save statzhero/ea4e485e7ab1b0cc2e76ba4f6de94579 to your computer and use it in GitHub Desktop.
Zalgo-style glitch text for latex: \glitch{ANY TEXT}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Zalgo-style glitch text: \glitch{ANY TEXT} | |
| \makeatletter | |
| \newcount\g@cnt | |
| \def\zm#1#2#3{\rlap{\raisebox{#1}{\hspace{#2}\scriptsize#3}}}% | |
| \def\g@rand{\ifcase\pdfuniformdeviate14 % | |
| \~{}\or\^{}\or\v{}\or\'{}\or\`{}\or\={}\or\H{}\or | |
| \r{}\or\u{}\or\.{}\or\d{}\or\b{}\or\c{}\or\t{}\fi}% | |
| \def\g@scat#1#2#3{\g@cnt=#1\relax | |
| \loop\ifnum\g@cnt>0 | |
| \zm{\the\numexpr#2+\pdfuniformdeviate#3\relax pt}% | |
| {\the\numexpr\pdfuniformdeviate9-4\relax pt}{\g@rand}% | |
| \advance\g@cnt-1\repeat}% | |
| \def\glitch@char#1{% | |
| \g@scat{\numexpr5+\pdfuniformdeviate4\relax}{1}{5}% | |
| \g@scat{\numexpr1+\pdfuniformdeviate3\relax}{8}{10}% | |
| \g@scat{\numexpr4+\pdfuniformdeviate4\relax}{-6}{5}% | |
| \g@scat{\numexpr1+\pdfuniformdeviate2\relax}{-16}{8}% | |
| #1}% | |
| \newcommand{\glitch}[1]{% | |
| \leavevmode | |
| \hbox to 0pt{\textcolor{magenta!80}{\raisebox{1pt}{\hspace{-1pt}#1}}\hss}% | |
| \hbox to 0pt{\textcolor{green!70}{\raisebox{-0.8pt}{\hspace{1pt}#1}}\hss}% | |
| \smash{\@tfor\zchar:=#1\do{\glitch@char{\zchar}}}\vphantom{#1}} | |
| \makeatother |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment