Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
a "hook" for \include?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ivan Shmakov  
View profile  
 More options Sep 4 2012, 2:14 pm
Newsgroups: comp.text.tex
From: Ivan Shmakov <oneing...@gmail.com>
Date: Wed, 05 Sep 2012 01:14:13 +0700
Local: Tues, Sep 4 2012 2:14 pm
Subject: a "hook" for \include?
        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.)

        TIA.

--
FSF associate member #7257      http://sfd.am-1.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Enrico Gregorio  
View profile  
 More options Sep 4 2012, 3:46 pm
Newsgroups: comp.text.tex
From: Enrico Gregorio <Facile.da.trov...@in.rete.it>
Date: Tue, 04 Sep 2012 21:46:01 +0200
Local: Tues, Sep 4 2012 3:46 pm
Subject: Re: a "hook" for \include?

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

\let\latexinclude\include
\def\include#1{\macro{#1}\latexinclude{#1}}

You may write also \macro{#1.tex} if you need the complete
file name (.tex is implicitly added for \include).

Ciao
Enrico


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Shmakov  
View profile  
 More options Sep 5 2012, 12:56 am
Newsgroups: comp.text.tex
From: Ivan Shmakov <oneing...@gmail.com>
Date: Wed, 05 Sep 2012 11:56:48 +0700
Local: Wed, Sep 5 2012 12:56 am
Subject: Re: a "hook" for \include?

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

 > \let\latexinclude\include
 > \def\include#1{\macro{#1}\latexinclude{#1}}

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

--
FSF associate member #7257      http://sfd.am-1.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alain Ketterlin  
View profile  
 More options Sep 5 2012, 2:22 am
Newsgroups: comp.text.tex
From: Alain Ketterlin <al...@dpt-info.u-strasbg.fr>
Date: Wed, 05 Sep 2012 08:22:16 +0200
Local: Wed, Sep 5 2012 2:22 am
Subject: Re: a "hook" for \include?

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.

-- Alain.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Heiko Oberdiek  
View profile  
 More options Sep 5 2012, 2:24 am
Newsgroups: comp.text.tex
From: Heiko Oberdiek <heiko.oberd...@googlemail.com>
Date: Wed, 05 Sep 2012 08:24:34 +0200
Local: Wed, Sep 5 2012 2:24 am
Subject: Re: a "hook" for \include?

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

\documentclass{article}
\makeatletter
\newcommand*{\orig@include}{}
\let\orig@include\include
\renewcommand*{\include}[1]{%
  \filename@parse{#1}%
  \orig@include{\filename@base}%
}

\makeatother

\begin{document}
\include{abc/inc}
\end{document}

--
Heiko Oberdiek


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Shmakov  
View profile  
 More options Sep 5 2012, 8:07 am
Newsgroups: comp.text.tex
From: Ivan Shmakov <oneing...@gmail.com>
Date: Wed, 05 Sep 2012 19:07:45 +0700
Local: Wed, Sep 5 2012 8:07 am
Subject: Re: a "hook" for \include?

>>>>> 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.

--
FSF associate member #7257      http://sfd.am-1.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »