BTW, is there an easy way to invoke an arbitrary TeX macro just
before a file is read within \include? The macro is to be
called with either the filename, or just the \include argument
(i. e., without the .tex suffix.)
Ivan Shmakov <oneing...@gmail.com> wrote:
> BTW, is there an easy way to invoke an arbitrary TeX macro just
> before a file is read within \include? The macro is to be
> called with either the filename, or just the \include argument
> (i. e., without the .tex suffix.)
>>>>> Enrico Gregorio <Facile.da.trov...@in.rete.it> writes:
>>>>> Ivan Shmakov <oneing...@gmail.com> wrote:
>> BTW, is there an easy way to invoke an arbitrary TeX macro just
>> before a file is read within \include? The macro is to be called
>> with either the filename, or just the \include argument (i. e.,
>> without the .tex suffix.)
There's a catch: this way, \macro will be invoked before
\clearpage (which is in turn invoked by \include before doing
\input) and thus may be unfit for my purposes. (I hope to check
it shortly.)
> You may write also \macro{#1.tex} if you need the complete file name
> (.tex is implicitly added for \include).
Actually, I'd need to strip leading directories of the filename
instead. I guess I can, e. g.:
\def \@basename #1/#2\@endbasename {%
#2}
But I'm curious, is there be a predefined LaTeX macro to do
that? (I believe there is, but it's probably undocumented.)
Ivan Shmakov <oneing...@gmail.com> writes:
>>>>>> Enrico Gregorio <Facile.da.trov...@in.rete.it> writes:
>>>>>> Ivan Shmakov <oneing...@gmail.com> wrote:
> >> BTW, is there an easy way to invoke an arbitrary TeX macro just
> >> before a file is read within \include? The macro is to be called
> >> with either the filename, or just the \include argument (i. e.,
> >> without the .tex suffix.)
> There's a catch: this way, \macro will be invoked before
> \clearpage (which is in turn invoked by \include before doing
> \input) and thus may be unfit for my purposes. (I hope to check
> it shortly.)
> > You may write also \macro{#1.tex} if you need the complete file name
> > (.tex is implicitly added for \include).
> Actually, I'd need to strip leading directories of the filename
> instead. I guess I can, e. g.:
> \def \@basename #1/#2\@endbasename {%
> #2}
> But I'm curious, is there be a predefined LaTeX macro to do
> that? (I believe there is, but it's probably undocumented.)
The filehook package provides hooks that let you run arbitrary code
before/after many file inclusion mechanisms. The currfile package is a
wrapper around filehook (afaiu) that keeps file paths around.
Ivan Shmakov <oneing...@gmail.com> wrote:
> >>>>> Enrico Gregorio <Facile.da.trov...@in.rete.it> writes:
> >>>>> Ivan Shmakov <oneing...@gmail.com> wrote:
> > \let\latexinclude\include
> > \def\include#1{\macro{#1}\latexinclude{#1}}
> Actually, I'd need to strip leading directories of the filename
> instead. I guess I can, e. g.:
> \def \@basename #1/#2\@endbasename {%
> #2}
> But I'm curious, is there be a predefined LaTeX macro to do
> that? (I believe there is, but it's probably undocumented.)
>>>>> Alain Ketterlin <al...@dpt-info.u-strasbg.fr> writes:
>>>>> Ivan Shmakov <oneing...@gmail.com> writes:
[...]
>> Actually, I'd need to strip leading directories of the filename
>> instead. I guess I can, e. g.:
>> \def \@basename #1/#2\@endbasename {%
>> #2}
>> But I'm curious, is there be a predefined LaTeX macro to do that?
>> (I believe there is, but it's probably undocumented.)
> The filehook package provides hooks that let you run arbitrary code
> before/after many file inclusion mechanisms. The currfile package is
> a wrapper around filehook (afaiu) that keeps file paths around.
That's it, thanks!
What's even better is that currfile also splits the filename
into its leading directories, prefix and suffix parts.