我有一个大文件,其结构如下:
\begin{exo}
...
\end{exo}
\begin{exo}
...
\end{exo}
我的目标是创建仅包含一个练习的不同文件。我该怎么做?有软件吗?
答案1
Emacs 用户可以执行此功能。
(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))))))
它可以用于任何环境,默认是exo。
答案2
答案3
这实际上不是一个答案,但它可以帮助你。
我使用了下面几段代码来管理写在不同文件中的大量问题。
\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}