Manage counters

Richard Kimberly Heck rikiheck at lyx.org
Mon Oct 12 22:24:24 UTC 2020


On 10/12/20 4:58 AM, Daniel wrote:
> I have just played a bit with Edit > Manage Counter Values. It's a
> nice feature to have available. However, it was not what I expected at
> first. It seems to be "just" a counter inset which sets the counter at
> the place where it is inserted (which becomes clear when looking at
> the code). I think it would be better placed in the Insert menu under
> "Counter Manager" or so.  

It was originally there. Various people thought it should go on the Edit
menu, so it got moved.


> The inset is nothing that directly "Edit"s the current layout but
> "Insert"s something in addition to it. The UserGuide actually states
> that this is an "inset" and that it is located in the "Insert" menu
> (which seems the right place IMO). 

I've fixed the docs.


> Maybe the limitation and functioning could be explained a bit more in
> that section and an example for it's standard usage be provided?

It says what five things it does. An example would be a bit more
complicated.


> 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.


> Also, it would be nice to set the counter of a numbered element more
> directly in another sense: setting it to a certain value via the
> context menu of a numbered element sets it to that value (not that
> value plus one as is currently the case with the "Counter Manager"
> because the value is increased by one when it is used e.g. in \section).
>
> Am I right to assume that the inset is *not* suppose to deliver this
> feature?

I thought about that, but suppose you set it and then tried to display
it or otherwise use it? You'd get a surprising result. So, yes, it's a
bit counter-intuitive. I've added a note about that to the docs, as
well. (Here, as in some other cases, you need a bit of LaTeX knowledge
to make the most of LyX.)

The idea of using the context menu, etc, is a good one, but it would
involve more work.

> 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.

Riki




More information about the lyx-devel mailing list