Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Which command would be most suitable to be hooked in order to preprocess input before it is passed to TeX?

Input file:

\begin{document}
    \input{a}
\end{document}

Seen by TeX (after a file a_pp.tex has been created):

\begin{document}
    \input{a_pp}
\end{document}

What about \include, \bibliography, or even other means of including files?

Note that the preprocessing is to be applied only to files that are interpreted/compiled by TeX directly, not to files that are read and parsed by some macro.

This is to move towards Forward-inverse search using SyncTeX with the precison of a single word.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

The filehook package gives you the options to do something at the beginning or end of each \input and \include.

For instance you could use \AtBeginEveryFile to have some arbitrary code called whenever a file is included.

share|improve this answer
    
This is amazing, thank you! –  krlmlr Jun 14 '12 at 12:19
    
You should thank Martin Scharrer who wrote the package! –  Seamus Jun 14 '12 at 12:21
    
True. It is so much easier to use packages that define a clear interface for a certain aspects, than having to delve into TeX internals. Thanks a lot, @MartinScharrer! –  krlmlr Jun 14 '12 at 12:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.