## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Classic View Use Monospaced Font Show Text Part by Default Show All Mail Headers Topic: [<< First] [< Prev] [Next >] [Last >>]

 Experiences with templates and internal syntax Morten Høgholm <[log in to unmask]> Mon, 26 Apr 2004 12:03:20 +0200 text/plain (77 lines) Hi all, Recently I've been playing with templates and the new internal syntax. One thing I did think about with the internal syntax was the ability to turn it off again at will. One reason was that I needed to load amsmath and be able to pass options to it, so I couldn't say \ProvidesPackage{test} \RequirePackage{ldcsetup} \RequirePackage{amsmath} \InternalSyntaxOn \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}} \ProcessOptions\relax \endinput as this wouldn't pass the options, but instead had to do it with \ProvidesPackage{test} \RequirePackage{ldcsetup} \InternalSyntaxOn \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}} \ProcessOptions\relax \RequirePackage{amsmath} \endinput Unfortunately this results in an infinite loop created by \GenericInfo  from amstext (\iffirstchoice@ is equal to \iftrue by default and this goes horribly wrong). In order to work around this I decided to do things a little differently: %%%%%%%%%%% \def\InternalSyntaxError{\errmessage{Invalid use of command}} \let\InternalSyntaxOff\InternalSyntaxError \def\InternalSyntaxOn{    \ifx\InternalSyntaxOff\InternalSyntaxError      \edef\InternalSyntaxOff{%        \catcode\noexpand\~=\the\catcode\~\relax        \catcode\noexpand\ =\the\catcode\ \relax        \catcode\noexpand\^^I=\the\catcode\^^I\relax        \catcode\noexpand\@=\the\catcode\@\relax        \catcode\noexpand\:=\the\catcode\:\relax        \catcode\noexpand\_=\the\catcode\_\relax        \endlinechar=\the\endlinechar\relax        \let\noexpand\InternalSyntaxOff\noexpand\InternalSyntaxError      }%      \catcode\~=10\relax      \catcode\ =9\relax      \catcode\^^I=9\relax      \makeatletter      \catcode\_=11\relax      \catcode\:=11\relax      \endlinechar= %      \relax    \else      \InternalSyntaxError    \fi } %%%%%%%%%%%%%%%%%% This way I got a pair of commands I could use to turn the internal syntax on and off, sort of like for \makeatletter and \makeatother, only this new set is able to restore the original meaning of catcodes and provides error checking, so that you don't put two \InternalSyntaxOn after each other and similar stupidities. I think the off-switch      \ifx\InternalSyntaxOff\InternalSyntaxError      \else        \InternalSyntaxOff      \fi could easily be integrated into \@onefilewithoptions and somewhere in \document just so that package authors and hackers don't have to remember to switch it off themselves. Any comments on this (pros and cons)? -- Morten Høgholm