Re: LYX 2.4.2.1 — Problem with \label and \ref mechanism

Richard Kimberly Heck rikiheck at gmail.com
Sun Oct 20 15:42:54 UTC 2024


On 10/20/24 10:24 AM, didiergabory at free.fr wrote:
> I'd like to give you this example of a module that I'm having trouble 
> finalizing... Because I have to admit, I'm having a really hard time 
> understanding the documentation...
>
> I've created a new environment in which I'm placing python code using 
> the listings package...
>
> I'd like to use the cross-reference mechanism... I've created a new 
> counter, used the \refstepcounter command, placed the \label and \ref 
> commands in the document... It works on the pdf output... But the 
> indication (see attached screenshot) in the LYX window is incorrect - 
> the designated counter refers to the section counter... And not to the 
> ‘code’ counter I created... What's wrong with the way I'm doing things?

The problem isn't with your code. InsetLayout does not support counters. 
The LabelType and LabelCounter tags don't exist in InsetLayout (so are 
throwing error, which you'll see if you launch LyX from a terminal). So 
LyX itself knows the counter 'code' exists, because you declared it, but 
it doesn't associate it with the 'Code Python' layout. Hence, it 
defaults to using the section counter to render it.

> I have a second request: Is it possible to display the counter number 
> in the label above the frame of each occurrence in the LyX document ? 
> In other words, ‘Python Code i’ rather than the simple ‘Python Code’ 
> label.
>
> In the body module:
> InsetLayout Flex:Python
> LabelString ‘Python Code \thecode’ Doesn't work...

Again, because InsetLayout doesn't do counters. So there's no way to do 
that in LyX.


It probably should, but that would take some work (on our part).


Riki

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20241020/0acc6c66/attachment.htm>


More information about the lyx-users mailing list