Re: LyX display of align counters

2022-02-19 Thread Scott Kostyshak via lyx-users
On Sat, Feb 19, 2022 at 05:20:03AM +0100, Daniel via lyx-users wrote:
> 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.

Indeed there would be ambiguity.

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

Ah true that is a good idea. I suppose the first step is for me to
figure out what I really want :). Thanks for your comments above. I'll
think more and test a couple of things.

Scott


signature.asc
Description: PGP signature
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users


Re: LyX display of align counters

2022-02-18 Thread Daniel via lyx-users

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


Re: LyX display of align counters

2022-02-18 Thread Scott Kostyshak via lyx-users
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.

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.

Thank you!
Scott


signature.asc
Description: PGP signature
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users


Re: LyX display of align counters

2022-02-18 Thread Daniel via lyx-users

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

?

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.


Best,
Daniel


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


Re: LyX display of align counters

2022-02-18 Thread Scott Kostyshak via lyx-users
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
From 0c03fad85cd099e467db015f98af4b2cf9dd9141 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak 
Date: Thu, 27 Jan 2022 17:11:48 -0500
Subject: [PATCH] beamer.layout: display frame number in LyX display

TODO:
(LyXMessage-ID:)
For some reason, if one keeps the TocLevel to 4, the label "Frame ..."
disappears. But, I guess, as long as you don't use Subsubsection in your
presentation, it should be no problem?

TODO:
(LyXMessage-ID:)
But instead of an empty LabelString, LyX seems to treat it the same as if it
hadn't been defined and adds just the number in front. Maybe this is a bug?

Motivation: Doug would find it useful, racoon suggested upstream
also:

LyXMessage-ID:

Thanks to racoon for the help. I think I would have given up on my
initial try without your help.

TODO (optional): in fragile frame layout, any way to just append "(fragile)",
to avoid having to duplicate "\theframe" ? Also for plain frame.
---
 lib/layouts/beamer.layout | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout
index d824522c8b..eab352bbdf 100644
--- a/lib/layouts/beamer.layout
+++ b/lib/layouts/beamer.layout
@@ -58,6 +58,9 @@ AddToPreamble
   }
 EndPreamble
 
+Counter frame
+End
+
 
 #
 # STANDARD STYLE
@@ -478,14 +481,16 @@ End
 # FRAMES
 #
 
+
 Style Frame
   Category Frames
   Margin   First_Dynamic
   LeftMargin   xx
   LatexTypeEnvironment
   LatexNameframe
-  LabelString  "Frame"
-  TocLevel 4
+  LabelString  "Frame \theframe"
+  LabelCounter frame
+  TocLevel 3
   KeepEmpty1
   NextNoIndent 1
   AlignLeft
@@ -543,7 +548,7 @@ End
 
 Style PlainFrame
   CopyStyle Frame
-  LabelString   "Frame (plain)"
+  LabelString   "Frame \theframe (plain)"
   Argument 3
 MenuString  "Frame Options"
 LabelString "Options"
@@ -554,7 +559,7 @@ End
 
 Style FragileFrame
   CopyStyle Frame
-  LabelString   "Frame (fragile)"
+  LabelString   "Frame \theframe (fragile)"
   Argument 3
 MenuString  "Frame Options"
 LabelString "Options"
@@ -995,7 +1000,8 @@ Style Title
   BottomSep1
   ParSep   1
   AlignCenter
-  LabelTypeNo_Label
+  LabelTypeStatic
+  LabelString  " "
   Argument 1
 LabelString   "Short Title|S"
 Tooltip   "Short title which appears in the sidebar/header"
@@ -1010,6 +1016,7 @@ Style Title
   DocBookTag   title
   DocBookTagType   paragraph
   DocBookInInfomaybe
+  LabelCounter frame
 End
 
 Style Title_(Plain_Frame)
-- 
2.32.0



example.23.lyx
Description: application/lyx


signature.asc
Description: PGP signature
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users


Re: LyX display of align counters

2022-02-18 Thread Daniel via lyx-users

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.


Daniel

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