José Abílio de Oliveira Matos wrote:
>
> Jean-Marc Lasgouttes wrote:
> >
> > >>>>> "José" == José Abílio de Oliveira Matos <[EMAIL PROTECTED]> writes:
> >
> > José> Is it possible/desirable to have an extra field within the
> > José> \ref inset? The goal is to have a unique interface for
> > José> cross-references, between the latex, linuxdoc, and docbook
> > José> layouts. The extra field could be ignored by the latex
> > José> "front-end", but it would be used by the linuxdoc and docbook.
> >
> > All the InsetLatexCommand handle the syntax \foo[optarg]{arg}. This
> > might not be what you want in this case. I do not know how we could
> > come up with a common inset.
I have played a little with \ref and now, after the enlightment that
reading the source always offers ;-) I know the answer.
There are only three places where the, latex related, source needs to be
changed:
* The form that reads the reference, needs an extra field to read the
extra parameter for SGML based outputs.
* The function InsetCommand::Latex must ignore the optional argument.
* The funtion that draws the inset, it must show the optional argument.
I have introduced by hand, in the lyx, an optional argument, and those
were the places where lyx had problems, with the present code.
Is it ok to make these changes?
> That's enough for now. I need the second argument because for some
> backends, html being the most notable, it is necessary to name the link, so
> that you can follow it.
>
> Example:
> *(linuxdoc)
> See section <ref id="sec-intro" name="Introduction"> for an
> introduction.
>
> *(docbook)
> See section <link linkend="sec-intro">Introduction</link>....
>
> *(latex)
> See section \ref{sec-intro} for an introduction.
>
> So as you see I need an extra argument, "Introduction" in this case, that
> coul be ignored by the latex "frontend". The advantage of the single
> approach is the interoperability between the different layouts (and less
> work for me :-)
>
> Is this clear, it this example? Is there any major problem preventing the
> extra argument in \ref?
This argument is also in favour of the WISIWYM, since the meaning for
reference is the same across all the documents, and all the formats: latex,
linuxdoc or docbook...
> > José> Is there any inset with optional atributes? This is only
> > José> relevant for the \url and \htmlurl insets, since \htmlurl is a
> > José> special case of \url, and this distinction is only relevant for
> > José> the linuxdoc "front-end". I would like to have only one inset,
> > José> to avoid extra-work to change between linuxdoc and docbook...
> >
> > See above. What is the exact kind of syntax you need? We could maybe
> > use the \cite inset for that, since they have related semantics.
>
> No, I need the cite inset for docbook, and also for linuxdoc...
>
> Is it possible to have something like:
>
> \url[LyX Home Page,html]{http://lyx.org}, or
> \url[LyX Home Page][html]{http://lyx.org}.
>
> That is, to have two optional arguments? (or maybe more, but now I only
> need two)
I think that here the best example to follow is the \ref vs \pageref
duality, so the solution is clear and well supported. I will have two new
insect defined in the same place.
To this new insets I can create a Latex method, and avoid all the errors
passing from linuxdoc or docbook to latex. This is back-port of Asger's idea
of insets for 1.1 if I have correctly understood...
José
--
José Abílio de Oliveira Matos
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm rated PG-34!!