So here is the situation : I wanted latex to read some commands when I include another file, and for that I defined a new \include command like this :
\newcommand{\foo}[1]{}
\newcommand{\includeas}[2][]{%
\foo{#1}
\include{#2}}
It works beyond all hopes! But now I'd like to still be able to use RefTeX's toc browser with my new \includeas command.
And here is the problem : (from RefTeX's manual)
User Option: reftex-include-file-commands
List of LaTeX commands which input another file. The file name is expected after the command, either in braces or separated by whitespace.
As you can see, having an optional argument in square brackets after the macro is a problem for RefTeX.
Is there any way I can bypass it?
At the moment I have a quick fix by turning the optional #1 argument to mandatory #2, but it relies on the fact I actually provide the argument all the time, which won't always be the case.
MWE:
File main.tex
\documentclass{minimal}
\begin{document}
\includeas[blabla]{foo}
% The test is to press C-C = , not to try to compile!
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
File foo.tex :
\chapter{Name}
\label{cha:name}