Change chapter number as displayed in LyX

Richard Kimberly Heck rikiheck at lyx.org
Fri Mar 27 16:19:24 UTC 2020


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/20200327/9fd9ecf3/attachment.html>


More information about the lyx-users mailing list