Skip to content

Instantly share code, notes, and snippets.

@rmcelreath
Created February 27, 2015 21:16
Show Gist options
  • Save rmcelreath/1e3fb52480ae7c79931d to your computer and use it in GitHub Desktop.
Save rmcelreath/1e3fb52480ae7c79931d to your computer and use it in GitHub Desktop.
TeX code for dumping code boxes to a common plain text file
\newwrite\tempfile
\usepackage{verbatim}
\makeatletter
\newwrite\Code@out % temp file for writing out and reading back in for display
\newcommand\VerbSaver{\obeylines\expandafter\VerbSaverArg\noexpand}
\newcommand\VerbSaverArg[1][code.txt]{%
\gdef\FName{xcodetempx.txt}%
\begingroup
\@bsphack%
\immediate\openout\Code@out\FName%
\let\do\@makeother\dospecials%
\catcode`\^^M\active%
\def\verbatim@processline{%
\immediate\write\tempfile{\the\verbatim@line}
\immediate\write\Code@out{\the\verbatim@line}}%
\verbatim@start}
\def\endVerbSaver{%
\immediate\write\tempfile{}
\immediate\closeout\Code@out\@esphack
\endgroup
\verbatiminput{\FName}}
\makeatother
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment