Using receipt of "LaTeX3: unable to convert space separated list into clist" I elaborated the following code for my needs:
\documentclass{book}
...
\usepackage{expl3}
\begin{document}
\newcommand{\PrintAnswer}[1]{%
\InputIfFileExists{#1}{\refstepcounter{subsection}}{\typeout{*** #1 not found ***}}}
\ExplSyntaxOn
\cs_new:Nn\PrintAnswerList:n{
\clist_set:Nx\l_csv_clist{#1}
\clist_map_inline:Nn\l_csv_clist{
\typeout{**** Printing ##1.ans}
\ExplSyntaxOff
\PrintAnswer{##1.ans}
\ExplSyntaxOn
}
}
\PrintAnswerList:n{\inputfiles}
\ExplSyntaxOff
\end{document}
It is intended for conditional compilation of a textbook, every chapter of which (eg, 01.tex, 02.tex) writes answers to problems to the file named after the name of the chapter source file, (eg, 01.ans, 02.ans etc). Near the end of the book these files are read in by the macro \PrintAnswer
. Usually, I compile only few chapters using the following trick to keep desired chapters in \inputfiles
macro:
\typein[\inputfiles]{^^JEnter filename(s) for \protect\includeonly:}
All that works fine, but I was forced to switch off experimental syntax before \PrintAnswer{##1.ans}
because otherwise answer files are not processed correctly (in particular, LaTeX complains that the commands for greek letters are not defined and hyphenation is broken). Therefore my question is How can one rewrite the above code using user-level LaTeX3 commands? I found \SplitList
command in xparse
package. Can it help?
\inputfiles
\typein
is apparently built into LaTeX.\inputfiles
is produced by\typein
; it just keeps the user reply; it my case it is a comma separated list to be passed to\includeonly
.