# Preprocess LaTeX file, a latex -E equivalent [duplicate]

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)?

-

## migrated from stackoverflow.comDec 4 '11 at 2:17

This question came from our site for professional and enthusiast programmers.

## marked as duplicate by Werner, Joseph Wright♦Dec 4 '11 at 8:14

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 3 '11 at 20:53
@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 4 '11 at 5: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 4 '11 at 7:40