Is there an equivalent way to write the body of my environment to a file without filecontents using TeX primatives?
morewrites or filecontents limitation
I suspect a limitation that these packages do not play well together. Using the paired macros from filecontents package shown below, I can write the contents (body) of an environment to a file called tmp.tex:
\@tempswafalse\filec@ntents{tmp}
end
\endfilecontents
For another part of my project, I ran out of writes, so I added \usepackage{morewrites}. This works for my TeX primative writes, but it does not help when using the filecontents package.
Example Code:
One too many writes...
\documentclass{article}
\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{verbatimbox}
\usepackage{tikz}
\usepackage{filecontents}
\usepackage{morewrites}% Does not support extend filecontents package, limited \@tempswafalse\filec@ntents{tmp} writes
% I tried putting this into a loop, but I failed
\newwrite\writeA
\newwrite\writeB
\newwrite\writeC
\newwrite\writeD
\newwrite\writeE
\newwrite\writeF
\newwrite\writeG
\newwrite\writeH
\newwrite\writeI
\newwrite\writeJ
\newwrite\writeK
\newwrite\writeL % Comment this out to compile, one too many writes
%\newwrite\writeM
%\newwrite\writeN
%\newwrite\writeO
%\newwrite\writeP
%\newwrite\writeQ
%\newwrite\writeR
% Environments
\makeatletter
\newenvironment{environment}[2]
{\gdef\environame{#1}\gdef\envirodescription{#2}%
\@tempswafalse\filec@ntents{tmp}
}%
{\endfilecontents}
\makeatother
\AfterEndEnvironment{environment}{\setenviro}
\newcommand\setenviro{%
\def\hrulespacedist{2mm}
\vspace{\hrulespacedist}\hrule\vspace{\hrulespacedist}
\texttt{\environame}
\hfill
\begin{minipage}[t]{.75\textwidth}
\envirodescription
\end{minipage}\par\bigskip
\textcolor{green!30!black}{\textbf{Example:}}\par\bigskip
\input{tmp}
\par\bigskip
\textcolor{red!80!black}{\textbf{Code:}}\par\bigskip
\verbfilebox[\footnotesize]{tmp}
\theverbbox
\vspace{\hrulespacedist}\hrule\vspace{\hrulespacedist}
}
\begin{document}
\begin{environment}{enumerate}{An enumerated/numbered list.}
\begin{enumerate}
\item First item
\end{enumerate}
\end{environment}
\end{document}
