Chapter numbers not incrementing

65 views
Skip to first unread message

Ian Fantom

unread,
May 17, 2023, 11:10:04 AM5/17/23
to latexus...@googlegroups.com
Hi!

I'm doing my first Latex edit, and find the chapter numbers are not
incrementing.

\chapter {\thechapter: Chapter name}

This is for document class set by: \documentclass[a4paper]{book}

Do I have to initialise \thechapter somewhere? I tried

I've tried:

    This is page~\thepage  ~in chapter~\thechapter.

This gives:

    This is page 31 in chapter 2.

It's on chapter 2 because I tried:

    \setcounter{chapter}{1}

    \stepcounter{chapter}

but it stays at 2.

Regards,

Ian Fantom



Ian Fantom

unread,
May 17, 2023, 11:10:05 AM5/17/23
to latexus...@googlegroups.com
Hi!

This is the message I sent earlier but seems to have got lost in the system.

Thanks,

Ian Fantom

Ian Fantom

unread,
May 17, 2023, 11:10:36 AM5/17/23
to latexus...@googlegroups.com
I recently joined the group. Did this email get distributed? I didn't
receive a copy.

Best wishes

Ian Fantom

On 17/05/2023 11:19, Ian Fantom wrote:

Peter Flynn

unread,
May 17, 2023, 11:15:54 AM5/17/23
to latexus...@googlegroups.com, Ian Fantom
On 17/05/2023 11:19, Ian Fantom wrote:
> Hi!
>
> I'm doing my first Latex edit, and find the chapter numbers are not
> incrementing.

Then something has been unset. Chapter numbers always increment
automatically.

> \chapter {\thechapter: Chapter name}

No, you never need to do this. Just \chapter{Chapter name}

> This is for document class set by: \documentclass[a4paper]{book}

There must be some package you are using that suppresses chapter
numbers. They are always ON by default.

Try this file:

============================== test.tex ============================
\documentclass[a4paper]{book}
\begin{document}
\title{My Book}
\author{Ian Fantom}
\maketitle
\chapter{Introduction}
Stuff
\chapter{Next stage}
More stuff
\end{document}
====================================================================

Let us know what you get.

Peter

Ian Fantom

unread,
May 17, 2023, 11:25:13 AM5/17/23
to Peter Flynn, latexus...@googlegroups.com
Thanks. That works!

I converted my material from LibreOffice Writer (under Ubuntu) to Latex
using Pandoc. That seems to do a good job on the detail but not on the
headings. So I'm editing the .tex file using TexStudio. I'm not yet
familiar with Latex, so am going step by step - my reason for converting
is for the indexing system.

So I'm not quite sure just what the coding includes without close
inspection!

I found the same problem with \part, too, but page numbers seem to work OK.

Regards,

Ian

Ian Fantom

unread,
May 17, 2023, 12:27:46 PM5/17/23
to Peter Flynn, latexus...@googlegroups.com
Some magic has just happened, and I'd love to have some idea of why it's
now working!

After trying your example I removed it and went back to the book. But
the pdf had disappeared and wouldn't come back when I rebuilt. Clicking
on View | Show ... didn't work either.

In the meantime a spurious '\the' appeared in four places randomly in
the text, creating error messages when I rebuilt. I deleted those, and
lo and behold all the chapter numbers appeared as in your example.

Then I found Tools | View, and the pdf reapeared. The 'Chapter 1' etc
appeared, and the prefix '1: Chapter title' appeared where I'd tried
\thechapter.

If it's easy for someone to figure that one out I'd be interested!

Thanks,

Ian

Peter Flynn

unread,
May 17, 2023, 5:49:31 PM5/17/23
to latexus...@googlegroups.com, Ian Fantom
On 17/05/2023 17:19, Ian Fantom wrote:
> Some magic has just happened, and I'd love to have some idea of why it's
> now working!

a) I'm the list owner and I saw your post (eventually)

b) I checked the settings, and apparently the list was set so that new
members get their first few posts flagged for manual release, which I
suspect is why they didn't go through immediately. I have unset that, so
new members can post straight away in future. Thanks for being the trigger.

Peter

Peter Flynn

unread,
May 17, 2023, 5:52:55 PM5/17/23
to latexus...@googlegroups.com
On 17/05/2023 17:19, Ian Fantom wrote:
[...]
> In the meantime a spurious '\the' appeared in four places randomly in
> the text, creating error messages when I rebuilt. I deleted those, and
> lo and behold all the chapter numbers appeared as in your example.

I have no idea where the bogus \the commands came from. At a wild random
guess, you deleted that string from somewhere, and somehow it got pasted
elsewhere. I have seen this happen with laptop touchpads, where the
middle click on the bottom edge performs a paste operation, like a
3-button mouse.

> Then I found Tools | View, and the pdf reapeared. The 'Chapter 1' etc
> appeared, and the prefix '1: Chapter title' appeared where I'd tried
> \thechapter. If it's easy for someone to figure that one out I'd be
> interested!

You don't say what editor or IDE you're using, so we have no idea what
Tools | View means in the context of your menus.

Peter

Peter Flynn

unread,
May 17, 2023, 5:57:59 PM5/17/23
to latexus...@googlegroups.com
On 17/05/2023 17:19, Ian Fantom wrote:
>> Thanks. That works!

OK, back on track.

>> I converted my material from LibreOffice Writer (under Ubuntu) to
>> Latex using Pandoc.

Pandoc is excellent, but for converting into LaTeX try the LibreOffice
(actually I think OpenOffice) LaTeX Export Plugin
(https://extensions.libreoffice.org/en/extensions/show/writer2latex-1)

>> That seems to do a good job on the detail but not
>> on the headings.

The best conversion I have seen from the wordprocessor world to the
LaTeX world is the one built into AbiWord. AbiWord opens Libre Office
documents, of course, but I have never tested it as a route into LaTeX
for anything except its own documents.

>> So I'm editing the .tex file using TexStudio.

Aha. Now we see it. I believe it is very good.

>> I'm not yet familiar with Latex, so am going step by step - my
>> reason for converting is for the indexing system.
>>
>> So I'm not quite sure just what the coding includes without close
>> inspection!

Have a look at Formatting Information, which is an introductory online
book (http://latex.silmaril.ie/) [claimer: I wrote it]

Peter

Ian Fantom

unread,
May 17, 2023, 6:16:40 PM5/17/23
to latexus...@googlegroups.com, Peter Flynn
Ah! Thanks. I'll have a look at that.

Ian

Ian Fantom

unread,
May 18, 2023, 10:29:06 AM5/18/23
to latexus...@googlegroups.com

I'm starting to understand the chapter numbering problem. No \frontmatter or \mainmatter had been declared. When I declared \frontmatter the chapter headers reverted to how they were originally, and not incrementing. So I've just declared \mainmatter and we now have the correct presentation of the chapter headings for all chapters declared subsequently. It seems if there's no declaration the \chapters part assumes \frontmatter, but the page numbering defaults to Arabic numbers as for \mainmatter. I haven't yet found how to declare CIP data, prefaces, forwords, acknowledgements, dedications etc in \frontmatter.

I'll look up your book shortly.

Thanks for the help.

Ian

--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to latexusersgro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/latexusersgroup/B9CD17D3-0B64-4064-9FEA-F74C47823293%40fantom.org.uk.

Peter Flynn

unread,
May 18, 2023, 6:00:41 PM5/18/23
to latexus...@googlegroups.com
On 18/05/2023 15:11, Ian Fantom wrote:
> I'm starting to understand the chapter numbering problem. No
> \frontmatter or \mainmatter had been declared.

If you omit both (most people do) then you get numbered chapters.

> When I declared \frontmatter the chapter headers reverted to how they
> were originally, and not incrementing.
Correct. Publishers don't put chapters in the front matter: that's for
prefaces and intros and other preliminaries.

> So I've just declared \mainmatter and we now have the correct
> presentation of the chapter headings for all chapters declared
> subsequently.
If you have no \frontmatter, then just omit \mainmatter as well.

> I haven't yet found how to declare CIP data,

There is nothing built into LaTeX for a CIP block, and I don't know of
any package implementing it. In a publication setting, the CIP block is
generated from a database, so it gets inserted automatically into the
LaTeX file ready-formatted with LaTeX commands.

If you have CIP data from the LoC, formatting it is usually
straightforward, with no indentation, no paragraph space, one step
smaller type than the body size, and ragged right setting, using \par to
separate the elements.

> prefaces, forewords, acknowledgements, dedications etc in \frontmatter.

I use \section* for all of them, because I consider that they should all
be styled one level lower than chapters, but that's my own preference
and many people like them formatted as chapters. Generally speaking they
should all be formatted the same with the possible exception of the
dedication, which is often centered vertically *and* horizontally, but
these things are a matter of a publisher's house style — if you're doing
this for yourself, you get to invent whatever style you want.

Peter
Reply all
Reply to author
Forward
0 new messages