On 2022-02-18 22:15, Scott Kostyshak via lyx-users wrote:
On Fri, Feb 18, 2022 at 09:53:32PM +0100, Daniel via lyx-users wrote:
On 2022-02-18 17:03, Scott Kostyshak via lyx-users wrote:
On Fri, Feb 18, 2022 at 02:52:35PM +0100, Daniel via lyx-users wrote:
On 17/02/2022 14:06, Scott Kostyshak via lyx-users wrote:
I like to renumber my align numbers within frame. e.g., Instead of "equation
3", I essentially use them as "3rd line of equation on this frame" which makes
it easy for students to ask questions and refer to the line number.

I do this with the following LaTeX code in the preamble:

\AtBeginEnvironment{align}{\setcounter{equation}{0}}

I'm greedy and would like to adapt the LyX layout to show the same.

Specifying "Within" frame seems to almost do what I want:

Counter equation
        Within               frame
End

However, if I'm on Frame 10, it will show 10.1, 10.2, etc..., where I would
prefer just 1, 2, ...

If the above can't be tweaked to work, perhaps a different approach to using
"Within" would be to have the Frame layout reset the equation counter to 0?

Scott

Maybe you could provide a minimal example of the frame setup you have? I
guess you are working with some "frame" counter definition.

Ah indeed there is some interaction with another local patch I have
applied. I don't think the patch is necessary to reproduce the issue in
this thread (without it, it seems LyX marks them as #.1, #.2, #.3, #.4;
but for completeness I attach it (it is against current master).

I also attach an example .lyx file. I saved it as 2.3.x format just for
simplicity, but I am testing on current master. Note that the LyX file
has a preamble (that resets the counter to 0 in LaTeX) as well as a
local layout (that specifies the Within).

I also attach a screenshot, which has Frame number patch applied.
Instead of the equation labels "1.1, 1.2, 2.1, 2.2", I would prefer
"1, 2, 1, 2" in the LyX display.

Thanks,
Scott

Like so:

Counter equation
   Within      frame
   LabelString \arabic{equation}
End

?

Perfect! Thanks.

By the way, why do you use

\AtBeginEnvironment{align}{\setcounter{equation}{0}}

rather than

\AtBeginEnvironment{frame}{\setcounter{equation}{0}}

?

If you use the latter, you can use different equation environments without
getting ambiguous numbers within a frame.

That's a good idea. I might change to that. The reason why I initially
chose "align" was so that if I do two (small) aligns on one frame, both
would restart to (1). But that's a very rare situation anyway.

Okay, so you want them to restart at (1) on the same frame. So, if you had two equation environments on one frame you couldn't say "3rd line of equation on this frame" but would have to say "3rd line of the first equation on this frame" or so.

I guess I might want to do both of the above LaTeX commands, in theory.
Almost all the time though, it's just one align on one frame so it won't
make a big difference.

If you have the latter command, the former seems superfluous because you cannot have an equation that goes over more than one frame, or?

The former (your) LaTeX command mimics what enumerated lists do. Just notice that the layout code I provided restarts within frame and hence mimics the latter LaTeX command above not the former. I am not sure that it is currently possible to mimic enumerated list counters in LyX. For example,

Counter equation
  Within      equation
  LabelString \arabic{equation}
End

just leads to a crash. (Maybe for obvious reasons?) Maybe what would be needed is a reset of a counter depending on an environment rather than another counter?

Best,
Daniel


--
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to