label whitespaces no more
Igor
rychphd at gmail.com
Mon Sep 9 16:14:16 UTC 2024
(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 <dnjels at gmail.com> wrote:
>
> Igor
>
> The main command in refstyle that cycles through a list of references (and a single reference) is:
>
> \def\RS at ref#1[#2]#3{%
> \begingroup
> \RS at setkeys{RS@#1}{#2}%
> \@safe at activestrue%
> \edef\RS at tmpa{\zap at space#3 \@empty}%
> \@safe at activesfalse%
> \edef\RS at tmpa{\noexpand\RS@@ref{#1} \RS at tmpa,\relax\noexpand\@eolst}%
> \RS at 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 at 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 <rychphd at 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
More information about the lyx-devel
mailing list