0

Possible Duplicate:
Replace \input{fileX} by the content of fileX automatically

I'm developping a framework for managing LaTeX project's dependencies but I can't figure out if there is a simple way of getting a preprocessed LaTeX file.

For instance, if my main.tex looks like :

\documentclass{article}
...
\newcommand{\specialpath}[0]{../foo/}
\input{\specialpath extracommands}
...
\begin{document}
    \input{introduction}
    ...
\end{document}

I want to have:

\documentclass{article}
...
% Content of ../foo/extracommands.tex
\usepackage{minted}
\newcommand{\whatever}
% end
...
\begin{document}
    % Content of introduction.tex
    \section{Introduction}
    \lipsum[1-4] % Or even the developpement of the command
    % end
    ...
\end{document}

In other words, is there an equivalent of the gcc flag -E for LaTeX (or an utility capable of doing that)?

Maxime
  • 101
  • This is going to be difficult on a LaTeX-only level, since \include{} will most likely translate directly into a TeX primitive like \input. It might be easier to get the raw TeX out, but I'm not even sure if and how that could be done. – Kerrek SB Dec 03 '11 at 20:53
  • Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Werner Dec 04 '11 at 02:26
  • I think @Werner is right. Also, if it seems useful, I can easily code a pure (La)TeX program to do that (i.e., no need for a C or perl compiler). – Bruno Le Floch Dec 04 '11 at 04:11
  • @BrunoLeFloch: Of course, only TeX can parse TeX. I haven't tested, but I am sure that all those scripts will fail on \catcode\`@=1 @input{file} – Aditya Dec 04 '11 at 05:52
  • @Maxime: how deep do you want the expansion to go? Once you go real deep, things get very messy. Do you want more than just inlining the \input statements? E.g., what about the \usepackage, or \documentclass? – Bruno Le Floch Dec 04 '11 at 07:40
  • @Aditya: I don't think that we can get all occurrences of the \input primitive to be replaced by the file's contents: the problem is that \input can be hidden within macro expansions => perhaps we want to expand \usepackage... A simpler (but different) possibility is to add the filecontents of all files given by \listfiles (or by a suitable hack into the TeX primitive \input). – Bruno Le Floch Dec 04 '11 at 07:44

1 Answers1

0

I think you want to use \listfiles.

David Carlisle
  • 757,742
lhf
  • 2,212