While it worked for some *predefined* refs, such as secret and even
subsecref, for automatically generated custom refs, the brackets
method for dealing with whitespaces doesn't work:

\label{sec:A B}
\secref{{A B}} -- works!

\label{sss:A B}
\sssref{{A B}} -- doesn't work:
LaTeX Warning: Reference `sss:{A B}' on page 1 undefined on input

I notice that LyX adds these lines to the tex file:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.

\AtBeginDocument{\providecommand\secref[1]{\ref{sec:#1}}}
\AtBeginDocument{\providecommand\sssref[1]{\ref{sss:#1}}}

I think secref has been already pre-defined by refstyle, but sssref
wasn't, hence the above definition is used and leads to the error.


On Tue, Sep 10, 2024 at 4:14 AM Igor <rych...@gmail.com> wrote:
>
> (Sorry, bringing this back under the right Subject Line)
>
> Thank you Daniel. Interesting. I'm glad we may still use brackets to
> preserve whitespaces when referencing through refstyle's commands,
> hope it won't create new problems, but at least label names are
> allowed to have whitespaces after all :)
> > \label{sec:A B}
> > \secref{{A B}} -- works!
>
>
> On Tue, Sep 10, 2024 at 2:39 AM Daniel Els <dnj...@gmail.com> wrote:
> >
> > Igor
> >
> > The main command in refstyle that cycles through a list of references (and 
> > a single reference) is:
> >
> >     \def\RS@ref#1[#2]#3{%
> >         \begingroup
> >             \RS@setkeys{RS@#1}{#2}%
> >             \@safe@activestrue%
> >             \edef\RS@tmpa{\zap@space#3 \@empty}%
> >             \@safe@activesfalse%
> >             \edef\RS@tmpa{\noexpand\RS@@ref{#1} 
> > \RS@tmpa,\relax\noexpand\@eolst}%
> >             \RS@tmpa%
> >         \endgroup}
> >
> > It removes spaces and was intended for the following scenario, and that is 
> > how many people write a list of references with spaces in between
> >
> >       \secref(aaa, bbb, ccc) -> \ref{sec:aaa}, \ref{sec:bbb}, \ref{sec:ccc}
> >
> > If the \zap@space part is removed then we have the wrong reference:
> >
> >       \secref(aaa, bbb, ccc) -> \ref{sec:aaa}, \ref{sec: bbb}, \ref{sec: 
> > ccc}
> >
> > The refstyle package cannot distinguish between a space in a list and a 
> > space in a reference. If I change that it will break a lot of old 
> > documents. The second point is that in standard latex, spaces in labels is 
> > a newish thing. It was not always there. Also note even if you put 10 
> > spaces in a row in a label, latex only passes one through to the definition 
> > - see the .aux file. I think it is better to use an underscore _ or include 
> > your label in brackets {aaa}.
> >
> > Danie Els
> >
> >
> >
> >
> >
> > On Mon, 9 Sept 2024 at 11:21, Igor <rych...@gmail.com> wrote:
> >>
> >> ==========
> >> Cc: Danie Els
> >> Hi Dannie,
> >> Seeing that you've updated the refstyle packages quite recently, on
> >> 2024/02/01, could you comment on the issue below? Full discussion
> >> starts from 
> >> https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg222793.html.
> >> Basically, due to a refstyle bug (?) of eating up the whitespaces from
> >> label names aka " refstyle does not support spaces in references", the
> >> LyX developers have to either escape ALL label names  or as suggested
> >> in the patch below, to enclose the label's name within additional {}
> >> just for refstyle's formatted references uses...
> >>
> >> I was wondering if you could rather fix it inside refstyle.sty?!
> >> Thanks,
> >> Igor
> >> ==========
> >>
> >>
> >>
> >> > > Seems like a refstyle's bug.
> >> > > \label{sec:A B}
> >> > > ...
> >> > > \secref{A B} -- can't find the label sec:AB -- refstyle has eaten up
> >> > > my whitespace!
> >> > >
> >> > > \secref{{A B}} -- works!
> >> >
> >> > Maybe, but as long as refstyle is not fixed (and I believe it is not
> >> > maintained any longer), escaping whitespace seems better than such
> >> > extra-grouping.
> >> >
> >> > > > \secref{{A B}} -- works!
> >> > >
> >> > > Actually, considering all eventualities, this might be the best
> >> > > solution, as the problem only concerns refstyle's formatted ref
> >> > > commands. All other solutions that I could think of add unnecessary
> >> > > complication.
> >>
> >> > > Does tex2lyx need some adaptation to avoid {{{{labels}}}} on
> >> > > roundtrips?
> >> >
> >> > Yes, you're right.
> >>
> >> Jürgen, thank you for the patch and the others for the discussion. Let
> >> me answer this question of yours:
> >> > Would it work for you if we limited the space escaping to the case only
> >> > where refstyle is used? I.e., could you uncheck "Use refstyle"?
> >>
> >> -- refstyle gets loaded automatically when I choose Formatted
> >> reference through LyX GUI. Ironically I redefine most of the
> >> refstyle's formatted commands underneath :) I'm going to test to see
> >> how I can implement this with "Use refstyle" unchecked in the future
> >> documents.
> >>
> >> Thanks,
> >> Igor
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to