LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

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

 Subject: Re: First experience with xr under L3PL From: Frank Mittelbach <[log in to unmask]> Reply To: Mailing list for the LaTeX3 project <[log in to unmask]> Date: Thu, 2 Jul 1998 21:40:51 +0200 Content-Type: text/plain Parts/Attachments: text/plain (204 lines)
Richard writes:
> Well . . . some people got out of the wrong side of bed yesterday.
> (Stress from watching the World Cup? :-)

do you mean me? :-)

guess not, neither world cup, nor out of bed this was before going to
bed.

and even if you feel it was harsh it has at least seemed to serve some
purpose

> While you Europeans were sleeping, I have been doing an experiment
> with my minimalist proposal'.

see?

> I picked a random' package from tools to see what it looks like under
> L3PL.  I happened to pick xr.

fine, however you could take the exercise further and actually apply
some of the functionality of L3PL. i've appended my version below

> Here are some notes on xr2.dtx gained from the experience:
>
> %<notpackage>\RequirePackage{l3io}
>
> This line is effectively commented out'.
> I tried \usepackage{xr2} (with the \RequirePackage) first.  As a
> result I had to put \CodeStart...\CodeStop around the body' of the
> package.  (The altered version of \RequirePackage doesn't take effect
> quickly enough.) So I changed my test document to say
> \usepackage{l3io,xr2} instead and commented out the \RequirePackage.

actually it works if there is a blank line after the \RequirePackage

we know that we had a problem with this bit of code but i thought we
got that fixed, seems not so needs looking after

> Oh, and don't do this (as I did):
> \usepackage{l3io,graphicx,url,xr2}
>
> Funny things' happen to graphicx and url (i.e. spaces get gobbled up)
> if you do that . . . you must put l3io and xr2 last.

sorry yes, that a known problem with putting things together on top of each other.

> \let:NwN\ior_close:N\tex_closein:D
> \let:NwN\if_eof:w\tex_ifeof:D
>
> See my previous two messages . . . .

well yes. my fault really, i imported the io module from some other
file structure and only tested it with the l3precomp stuff which

> \def_new:Npn\tools/xr/loop:n#1{\ior_open:Nn\@inputcheck{#1}\scan_stop:
>
> A gotcha:  you now need the braces around #1.

and no \scan_stop: :-)

> The \\ in both these lines was \[log in to unmask]  I wanted to change that to
> \tools/xr/dummy or something like that, but this doesn't work because
> \tools/xr/test:nnnn gets invoked when reading the .aux file, and at
> that stage / has catcode 12 again.  (Using a _ wouldn't work either,
> of course.)

???? works i'd say in my implementation

> Second, I think you will get used to / in the macro names.
> I can parse' names such as \tools/xr/exp_list: without much
> trouble.  If I have any parsing problems at all it is with lines such
> as:
>   \if_meaning:NN\tools/xr/list\@empty\else:
> Somehow the NN stands out too much.

what helps a lot is to use sufficient white space, see my file

> Third, this example isn't as interesting as it might be; I have only
> used function names' (no parameter names').  And it's too small: the
> (only) apparent payoff of L3PL in xr was the two uses of \ior_eof:NTF.

actually i don't think it is too short. when i converted it the result
was much shorter (and clearer i'd say, but see for yourself)

> Clearly I have to try converting some of tools's larger packages.

yes please, but try to apply some more of what the fragments of L3PL

> . . . enjoy!

same to you

frank

i didn't bother to keep it as .dtx file since that would have meant to
rewrite the docu :-)

----------------- test

\begin{filecontents}{l3xr}
\RequirePackage{l3io}
\RequirePackage{l3seq}

% that of course should be in l3io

\let:NwN\ior_close:N\tex_closein:D
\let:NwN\if_eof:w\tex_ifeof:D

% well, that has already an interface in 2e

\newcommand\externaldocument[2][]
{
{
\makeatletter
\def:Npn \l_xr_prefix_tlp {#1}
\seq_push:Nn \l_xr_subfiles_seq {#2.aux}
\xr_loop:
}
}

\seq_new:N \l_xr_subfiles_seq

\def_new:Npn \xr_loop:
{
\seq_pop:NN  \l_xr_subfiles_seq \l_xr_file_tlp
\ior_open:Nn \@inputcheck {\l_xr_file_tlp}
\ior_eof:NTF \@inputcheck
{
\PackageWarning{l3xr}{^^JNo~ file~ \l_xr_file_tlp^^JLABELS~ NOT~ IMPORTED.^^J}
}
{
\PackageInfo{l3xr}{IMPORTING~ LABELS~ FROM~ \l_xr_file_tlp}
}
\seq_empty:NF \l_xr_subfiles_seq
{ \xr_loop: }
}

{
\ior_to:NN \@inputcheck \l_xr_line_tlp
%    \end{macrocode}
% The |...| make sure that |\xr_test:w| always has sufficient
% arguments (three at least).
%    \begin{macrocode}
\exp_after:NN
\xr_test:w
\l_xr_line_tlp . . . \xr_test:w
}

\def_long_new:Npn\xr_test:w #1 #2 #3 #4 \xr_test:w
{
\if_meaning:NN #1 \newlabel
\newlabel{ \l_xr_prefix_tlp #2 }{#3}
\else:
\if_meaning:NN #1 \@input
\seq_push:Nn \l_xr_subfiles_seq {#2}
\fi:
\fi:
\ior_eof:NF \@inputcheck
}
\end{filecontents}

\begin{filecontents}{aaa.aux}
\newlabel{foo}{{1foo}{2}}
\end{filecontents}
\begin{filecontents}{aaa2.aux}
\newlabel{foo}{{1foo2}{2}}
\@input{aaa3.aux}
\end{filecontents}
\begin{filecontents}{aaa3.aux}
\newlabel{bar}{{3bar}{2}}
\end{filecontents}

\documentclass{article}

\usepackage{l3xr}

\externaldocument[A-]{aaa}

\externaldocument{aaa2}

\begin{document}

some label \label{label} and \ref{foo} and \ref{A-foo} and \ref{bar}.

\end{document}