Manage counters

racoon xracoonx at gmx.de
Tue Oct 13 16:00:06 UTC 2020


On 2020-10-13 17:49, Richard Kimberly Heck wrote:
> On 10/13/20 1:43 AM, Daniel wrote:
>> On 2020-10-13 00:24, Richard Kimberly Heck wrote:
>>> On 10/12/20 4:58 AM, Daniel wrote:
>>>> I think it's nice to have the inset available but its use is limited
>>>> for me. In particular, it seems not a feature to "directly" change the
>>>> counter of numbered elements. Here is what I mean: Say, I want to
>>>> change the counter of a Numbered list (enumerate). In the attached
>>>> document I try to reset a Numbered list counter with the inset but it
>>>> doesn't work. This is because `\setcounter` comes either too early
>>>> (outside of the enumerate environment) or too late (after `\item`). I
>>>> think to work, `\setcounter` should be added '''at the beginning or
>>>> the line''' where the counter inset is added as in the attached tex
>>>> document.
>>>
>>> Scott pointed out the same issue. To make it work, you have to Insert>
>>> List Preamble (an optional argument), and then you also have to modify
>>> the layout for that argument to remove PassThru. (This is on the list a
>>> couple weeks back.) Otherwise, you can't insert insets but only bare
>>> text. It's not ideal but it's also not clear what else to do. Generally
>>> removing PassThru seems wrong, since that's what one will ordinarily
>>> want, I think.
>>
>> Somehow I could not get it to work by removing PassThru. But I suspect
>> that the following two problems will remain:
>>
>> 1. The counter *in the Workarea* is not properly modified since the
>> counter inset still comes after the list started.
>
> That's likely true, but can probably be fixed somehow. I'll have to
> investigate.
>
>
>> 2. Changing the first element in a list works different from changing
>> other elements in a list. Which is quite counter-intuitive.
>
> I agree. It's not ideal how it works with lists. I didn't really have
> lists in mind when designing this. (Scott's own use case is better
> handled with enumitem's resume function, e.g.)
>
>
>>> The idea of using the context menu, etc, is a good one, but it would
>>> involve more work.
>>
>> I guess you mean "more work" as in more work than for the counter inset.
>> My hopes are not high that I will be able to do it. I'll still try it at
>> some point little bit. I hope I can learn a lot from the counter inset
>> code.
>
> I think this would have to be done by making the counter value a
> paragraph parameter, like line spacing. That's where we store this kind
> of thing. The option would be available in the dialog only when the
> paragraph has an associated counter.

Thanks a lot for the hints. And please always let me know if you would
be yourself interested in implementing it. I am not particularly fond of
implementing any particular feature myself. I know any of the developers
would do a better job. I am only taking some on because the developers
seem busy with other things.

>>>> I am also thinking of being able to set not only the value but the
>>>> format, e.g. "(\roman{enumi})", of the counter, ideally via a nice UI
>>>> with a couple of preset values.
>>>
>>> Here, I think it might be worth just having a module that made other
>>> formats available. I have one for local use.
>>
>> It strikes me as a pretty basic feature that should be available
>> module-less some day.
>
> Possibly. But the difficulty is that this kind of case can be made for
> many features. If all of them are available by default, then the result
> is chaos. Modules were specifically designed to allow people to turn
> things on and off as they need them or don't.

I agree that making all features default might be chaotic and like the
concept of modules. However, this is a default feature of the common
word processors, so one might be able to make a special case for it that
way. However, someone else would have to make that case.

Daniel


More information about the lyx-devel mailing list