Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Last active January 9, 2016 10:36
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/150f826f564bd875c3c9 to your computer and use it in GitHub Desktop.
Save zr-tex8r/150f826f564bd875c3c9 to your computer and use it in GitHub Desktop.
TeX: Yet Another Quine on TeX
!
\catcode13=12!
\toks0{\output{\setbox0\box255 \shipout\hbox{%
\special{ps::(!
\catcode13=12!
\toks0{\the\toks0}%
\noexpand\the\toks0\end)pop}}}}%
\the\toks0\end
@zr-tex8r
Copy link
Author

zr-tex8r commented Jan 9, 2016

The file teqgen.tex is the quine generator. First run:

tex -output-comment="" -translate-file=./teq teqgen

and then rename the output file teqgen.dvi to teq.tex.
This is the Quine source file.

When teq.tex is compiled with the command:

tex -output-comment="" -translate-file=./teq teq

it will output the DVI file teq.dvi which completely coincides with teq.tex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment