Change chapter number as displayed in LyX

Richard Kimberly Heck rikiheck at lyx.org
Wed Apr 15 23:24:51 UTC 2020


On 3/27/20 12:53 PM, Matt Barnard wrote:
> That seemed to be the case, thanks for confirming.
> Is your patch on github? I have time now due to current events and
> could take a look at finishing it.

I can't remember if I replied to this. It turned out that I hadn't done
much work on the patch, but I've started working on it again, and it
ought to be pretty close. You can see what I've got here:

   
https://git.lyx.org/?p=developers/rgheck/lyx.git;a=log;h=refs/heads/features/Counters

though it definitely needs some cleanup, even if it does actually work
(which it probably doesn't). I'm hoping to work on it more over the next
few days.

Riki


>
> On Fri, Mar 27, 2020, 9:19 AM Richard Kimberly Heck <rikiheck at lyx.org
> <mailto:rikiheck at lyx.org>> wrote:
>
>     On 3/26/20 8:55 PM, Matt Barnard wrote:
>>     Sure, see attached. Adjusting the LyX numbering like this is
>>     something I've found myself wanting to do a number of times.
>
>     Yes, the only to fix this in LyX itself would be with some LaTeX
>     trickery of the sort you describe below. There's not currently any
>     way to manipulate LyX's counters within the text itself. I have a
>     partial patch that will do this kind of thing but haven't had time
>     to finish it.
>
>     Riki
>
>
>>
>>     Example (attached)
>>
>>         \setcounter{part}{9}
>>         Part 10 My document starts on Part 10
>>         1 with one section
>>         \addcontentsline{toc}{part}{*By the way,}*By the way,
>>         This chapter is an aside, but it needs to be at the Part
>>         level in the ToC
>>         \setcounter{part}{9}
>>         Part 11 then we continue with Part 10
>>         2 but LyX says this is Part 11
>>
>>
>>     Note that I resolved this for now using the following:
>>
>>         \newcounter{previouschapter}
>>         \newcounter{previoussection}
>>         \newcounter{uniquechapteranchor}
>>         \newcommand{\pushchapter}{%
>>           \let\previouschaptertitle\parttitle%
>>
>>           \setcounter{previouschapter}{\value{part}}%
>>           \setcounter{previoussection}{\value{section}}%
>>         }
>>         \newcommand{\popchapter}{%
>>           \renewcommand*{\theHpart}{\value{uniquechapteranchor}\the\value{part}} 
>>         % for hyperref
>>
>>           \chapt{\value{previouschapter}}                           
>>                % shorthand for \setcounter{part}{n-1}
>>           \part{\previouschaptertitle~(cont.)}%
>>           \sect{\value{previoussection}}%
>>           \stepcounter{section}%
>>           \stepcounter{uniquechapteranchor}%
>>         }
>>
>>
>>     and then 
>>      
>>
>>         \part{Real  part  } 
>>
>>         \pushchapter
>>         \part*{Interrupting part} 
>>
>>         \popchapter % output a new part, but don't start a new part
>>         in LyX
>>
>>         \section{this is in real  part} 
>>
>>      
>>     LyX continues numbering with the previous part even though I
>>     write a new part in the output
>>
>>     On Thu, Mar 26, 2020 at 4:57 PM Richard Kimberly Heck
>>     <rikiheck at lyx.org <mailto:rikiheck at lyx.org>> wrote:
>>
>>         On 3/26/20 4:16 PM, Matt Barnard wrote:
>>>         Hello,
>>>
>>>         I'm interrupting a numbered chapter with an unnumbered
>>>         chapter, and I would like to continue sections within that
>>>         previous numbered chapter. I've done this on the output side
>>>         with \setcounter{part}, but in LyX the chapter number is
>>>         still incremented.
>>>
>>>         I've fixed this for the first instance using the local layout
>>>
>>>             Counter part
>>>
>>>             InitialValue 12
>>>
>>>             End
>>>
>>>         but I haven't found a way to give LyX a command mid-document
>>>         to adjust numbering.
>>>
>>>         Is this currently supported?
>>>
>>         I'm not sure I entirely understand the issue. Can you post a
>>         very simple example file?
>>
>>         Riki
>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20200415/10bf3fc6/attachment.html>


More information about the lyx-users mailing list