Hi, I'm going to try to ask this question without a minimal example for
the moment, but if needed I'll make one.
I have a class file based on memoir that I'm working on, which has some
conditional code based on whether a particular package is loaded:
\@ifpackageloaded{foo}{%
some code
}
{\relax}
}
This works fine in my class. I thought I would replace <some code> in
the class file with \input{file-containing-code} so that the fix is more
modular. (It will not be needed when a new version the foo package is
available).
But when I do this, I get a bunch of undefined control sequences, as if
none of the memoir commands had been loaded.
Am I missing something here? Is there any reason why using \input as
opposed to having the code directly in the class file should work
differently?
Thanks
Alan
|
|
0
|
|
|
|
Reply
|
Alan
|
4/17/2010 7:19:03 PM |
|
In article <amunn-0B5168.15190317042010@news.eternal-september.org>,
Alan Munn <amunn@msu.edu> wrote:
> Hi, I'm going to try to ask this question without a minimal example for
> the moment, but if needed I'll make one.
>
> I have a class file based on memoir that I'm working on, which has some
> conditional code based on whether a particular package is loaded:
>
> \@ifpackageloaded{foo}{%
> some code
> }
> {\relax}
> }
And, no, this extra } is not in my file. :-)
>
> This works fine in my class. I thought I would replace <some code> in
> the class file with \input{file-containing-code} so that the fix is more
> modular. (It will not be needed when a new version the foo package is
> available).
>
> But when I do this, I get a bunch of undefined control sequences, as if
> none of the memoir commands had been loaded.
>
> Am I missing something here? Is there any reason why using \input as
> opposed to having the code directly in the class file should work
> differently?
>
> Thanks
>
> Alan
|
|
0
|
|
|
|
Reply
|
Alan
|
4/17/2010 7:22:16 PM
|
|
Le 17/04/2010 21:19, Alan Munn a �crit :
> Hi, I'm going to try to ask this question without a minimal example for
> the moment, but if needed I'll make one.
Yes it could help. Or say the order of the operations :
\ProvideClass{myclass}
\LoadClass(memoir}
\@ifpackageloaded{foo}
{\InputIfFileExists{...}}% or \usepackage ?
\relax
>
> I have a class file based on memoir that I'm working on, which has some
> conditional code based on whether a particular package is loaded:
>
> \@ifpackageloaded{foo}{%
> some code
> }
> {\relax}
> }
>
> This works fine in my class. I thought I would replace<some code> in
> the class file with \input{file-containing-code} so that the fix is more
> modular. (It will not be needed when a new version the foo package is
> available).
>
> But when I do this, I get a bunch of undefined control sequences, as if
> none of the memoir commands had been loaded.
>
> Am I missing something here? Is there any reason why using \input as
> opposed to having the code directly in the class file should work
> differently?
>
> Thanks
>
> Alan
|
|
0
|
|
|
|
Reply
|
GL
|
4/17/2010 7:23:21 PM
|
|
In article <4bca0ab2$0$18408$426a74cc@news.free.fr>,
GL <gouailles@gmail.com> wrote:
> Le 17/04/2010 21:19, Alan Munn a �crit :
> > Hi, I'm going to try to ask this question without a minimal example for
> > the moment, but if needed I'll make one.
>
> Yes it could help. Or say the order of the operations:
Thanks. I looked back at the code, and realise that the
\@ifpackageloaded command was within the scope of \AtBeginDocument.
Moving it outside of that scope fixed the problem.
Alan
|
|
0
|
|
|
|
Reply
|
Alan
|
4/17/2010 7:33:39 PM
|
|
Alan Munn <amunn@msu.edu> wrote:
> In article <4bca0ab2$0$18408$426a74cc@news.free.fr>,
> GL <gouailles@gmail.com> wrote:
>
> > Le 17/04/2010 21:19, Alan Munn a �crit :
> > > Hi, I'm going to try to ask this question without a minimal example for
> > > the moment, but if needed I'll make one.
> >
> > Yes it could help. Or say the order of the operations:
>
> Thanks. I looked back at the code, and realise that the
> \@ifpackageloaded command was within the scope of \AtBeginDocument.
> Moving it outside of that scope fixed the problem.
Inside \AtBeginDocument you have probably the wrong catcode
for `@'.
\AtBeginDocument{%
\@ifpackageloaded{foo}{%
\@ifpackagelater{foo}{2010/01/01}{% version of fixed foo
\makeatletter
\InputIfFileExists{fix-foo}{}{}%
\makeatother
}{}%
}{}%
}%
Or a little more defensive (retaining the catcode of @):
Instead of \makeatletter...\makeatother:
\begingroup
\edef\x{\endgroup
\noexpand\makeatletter
\noexpand\InputIfFileExists{fix-foo}{}{}%
\catcode64=\the\catcode64\relax % 64 = @
}%
\x
--
Heiko Oberdiek
|
|
0
|
|
|
|
Reply
|
Heiko
|
4/18/2010 12:24:14 AM
|
|
In article <hqdj57$dhp$1@news.eternal-september.org>,
Heiko Oberdiek <heiko.oberdiek@googlemail.com> wrote:
> Alan Munn <amunn@msu.edu> wrote:
>
> > In article <4bca0ab2$0$18408$426a74cc@news.free.fr>,
> > GL <gouailles@gmail.com> wrote:
> >
> > > Le 17/04/2010 21:19, Alan Munn a �crit :
> > > > Hi, I'm going to try to ask this question without a minimal example for
> > > > the moment, but if needed I'll make one.
> > >
> > > Yes it could help. Or say the order of the operations:
> >
> > Thanks. I looked back at the code, and realise that the
> > \@ifpackageloaded command was within the scope of \AtBeginDocument.
> > Moving it outside of that scope fixed the problem.
>
> Inside \AtBeginDocument you have probably the wrong catcode
> for `@'.
> \AtBeginDocument{%
> \@ifpackageloaded{foo}{%
> \@ifpackagelater{foo}{2010/01/01}{% version of fixed foo
> \makeatletter
> \InputIfFileExists{fix-foo}{}{}%
> \makeatother
> }{}%
> }{}%
> }%
>
> Or a little more defensive (retaining the catcode of @):
>
> Instead of \makeatletter...\makeatother:
>
> \begingroup
> \edef\x{\endgroup
> \noexpand\makeatletter
> \noexpand\InputIfFileExists{fix-foo}{}{}%
> \catcode64=\the\catcode64\relax % 64 = @
> }%
> \x
Thanks, Heiko. That definitely was the problem, and now I understand
why.
Alan
|
|
0
|
|
|
|
Reply
|
Alan
|
4/18/2010 3:11:24 AM
|
|
|
5 Replies
228 Views
(page loaded in 0.059 seconds)
|