Language: TeX Author: Denis Hirschfeldt Notes: This first one is a LaTeX2e document which produces a printout of its own source code. The first character is a space. But shouldn't a printout of source code be in a fixed width font? \documentclass{book}\pagestyle {empty}\def\a{\ensuremath{\backslash}}\def\f {\def\b{\a}\def\c{\{}\def\d{\}}\def \e{\\}\noindent\g\b def\b g\c\def\b{\a b }\def\c{\a c }\def\d{\a d}\def\e{\a e \\}\g\}\a begin\{document\}\a f\a end \{document\}}\def\g{ \b documentclass\c book\d\b pagestyle\e \c empty\d\b def\b a\c \b ensuremath\c \b backslash\d\d\b def\b f\e \c \b def\b b\c \b a\d\b def\b c\c \b \c \d\b def\b d\c \b \d\d\b def\e \b e\c \b \b \d\b noindent\b g\b b def\b b g\b c\b def\b b\c \b a b\e \d\b def\b c\c \b a c \d\b def\b d\c \b a d\d\b def\b e\c \b a e\e \b \b \d\b g\b \d\b a begin\b \c document\b \d\b a f\b a end\e \b \c document\b \d\d}\begin{document}\f\end{document} Author: Joe Miller Notes: The following TeX document produces a printout of its own source code. The printout is in cmtt10. The reference to character codes is machine independent since it refers to the positions of characters in a standard TeX font. On behalf of the purists (i.e. Chris), Joe had it omit the page number from the printout. \obeylines\nopagenumbers\tt\def\[#1]#2[#3[#4 #5{#1obeylines#1nopagenumbers#1tt#1def#1[#21]#22[#23[#24 #25#3#5#4#1[#1char92]#1#2[#1char123[#1char125 #3#1[#1#21]#1#22[#1#23[#1#24 #3#1#25#4#4#1bye}\[\char92]\#[\char123[\char125 {\[\#1]\#2[\#3[\#4 {\#5}}\bye Author: Michael Downes Note: prints copy in the middle of TeX's built-in messages {\gdef \selfcopy {\message {{\the \errhelp }}\message {{\the \errhelp }}\end } \aftergroup \errhelp \afterassignment \selfcopy } {\gdef \selfcopy {\message {{\the \errhelp }}\message {{\the \errhelp }}\end } \aftergroup \errhelp \afterassignment \selfcopy } Author: Michael Downes Note: writes itself to disk, not stdout \immediate \openout 0=\jobname .cpy {\gdef ~#112{\errhelp {#112}\immediate \write 0{\the \errhelp }\immediate \write 0{\the \errhelp }\immediate \closeout 0 \end}} \newlinechar 13 \catcode `\#=3 \afterassignment ~\catcode 13=12 \immediate \openout 0=\jobname .cpy {\gdef ~#112{\errhelp {#112}\immediate \write 0{\the \errhelp }\immediate \write 0{\the \errhelp }\immediate \closeout 0 \end}} \newlinechar 13 \catcode `\#=3 \afterassignment ~\catcode 13=12 Author: Peter Schmitt Note: as above, in INITeX \catcode `\{1 \catcode `\}2 \catcode `\#6 \def \run {\immediate \openout 1=out-ini.out% \def \select ##1:->##2{##2}\immediate \write 1{\catcode `\noexpand \{1 \catcode `\noexpand \}2 \catcode `\noexpand \#6 \noexpand \def \noexpand \run{\expandafter \select \meaning \run }\noexpand \run }\immediate \closeout 1\end }\run