I have a big file having the following structure :
\begin{exo}
...
\end{exo}
\begin{exo}
...
\end{exo}
My aim is to create different files containing just one exercice. How can I do this ? Does there exist a software ?
I have a big file having the following structure :
\begin{exo}
...
\end{exo}
\begin{exo}
...
\end{exo}
My aim is to create different files containing just one exercice. How can I do this ? Does there exist a software ?
Emacs users can perform this function.
(defun save-environments (env)
"Collects all the ENV environments (default to EXO) to save them each in a separate file. Replaces each with an \input"
(interactive
(list (read-string "Environment: " "exo")))
(with-current-buffer (buffer-name)
(let ((env-number 0)
(file-se (file-name-sans-extension (buffer-name))))
(goto-char (point-min))
(while
(search-forward (format"\\begin{%s}" env) nil t)
(setq env-number (1+ env-number))
(LaTeX-mark-environment)
(kill-region (point) (mark))
(with-temp-file (format "%s-%s-%d.tex" file-se env env-number)
(goto-char (point-min))
(insert (format "%% %s-%s-%d.tex\n" file-se env env-number)
(format "%% From %s.tex \n\n" file-se))
(yank))
(insert (format "\\input{%s-%s-%d}\n" file-se env env-number))))))
It can be used for any environment, default is exo.
You could use standard latex functionality such as the import libraries and manually split up exercises into individual files. And then use either import with relatives paths via subimport, use just use the full path.
How to use the import package?
I think the main issue would be getting all the commands into separate files.
However if you wish to automatic this process, you may need to use a scripting language like python and do something similar to web scrapping using a tool like TexSoup
That is not really an answer but this can help you.
I have used the following pieces of code to manage a lot of questions written in different files.
\documentclass[10pt]{beamer}
\usepackage{pgffor}
\newcommand\nbquest{16}
\newcommand\dirofquest{01-no-parabola}
\begin{document}
\foreach \n in {1,...,\nbquest}{
\begin{frame}
\frametitle{Question FLASH no. \n}
\Large\centering
\input{\dirofquest/question-\n.tex}
\end{frame}
}
\end{document}
{exo}in imitation of{filecontents}. But what about the file naming? – Donald Arseneau Jun 14 '20 at 21:21.texfiles from the original one an this answer explains how to usetcolorboxto extract contents from one file to other ones which can be later on included or just leaved for independet processing. The second solution could be applied redefining yourexoenviroments. – Ignasi Nov 12 '20 at 09:49