[LH5052] Auto-generated table of contents has duplicate title

Kindle Previewer. Verified it looks like this on Kindle as well.

We’ll still need to know if the Compile was to mobi, ePub, or ePub 3 at least. If it isn’t a known bug, someone has to help you in a Zoom session (Literature & Latte doesn’t do that) or you need to send the project.

I spent a couple of hours investigating this. The project I’m working with was ported from Scrivener 1 to Scrivener 3, and apparently this conversion process is buggy or does not port all settings: I created a new “Novel with parts” project in Scrivener 3, verified it exports correctly in epub3, and then compared it to what the converted project looked like. Here’s some stuff that’s missing from my converted project:

  • Section layout labels are completely different
  • Section layout is missing table of contents layout definition
  • No styles are defined, although the Scrivener 1 project made extensive use of them
  • HTML elements page has no selections for any styles, probably because there are no styles

I also went through the reference manual, and it doesn’t describe what the settings on the HTML elements tab of the compile settings page do for automatically generated pages (like the table of contents). I’d like to get more details about that in the manual.

I’ve decided not to bother with this and instead re-create the entire novel in Scrivener 3.

  • Section layout labels are completely different
    Section types and layouts didn’t have names, so do you mean the folder+, file+, and container+ icons? In v3, section types and layouts DO have names. I think it’s much less confusing that way.

  • Section layout is missing table of contents layout definition
    You can make a section type and layout for the automatic ToC, but the automatic one is less flexible. You can change it, I suspect, by editing CSS.

  • No styles are defined, although the Scrivener 1 project made extensive use of them
    Scrivener 1 didn’t have ANY styles. You mean format presets, which are much more limiting. Find a paragraph of each type and define a style based on it. Then you’ll have your presets back, but they’ll work a bit like Word styles (only better).

  • HTML elements page has no selections for any styles, probably because there are no styles
    There are a couple of built-in styles, but you can add others to taste.

https://www.notion.so/deepspacecorps/Compile-Overview-b0cde310b0664ab988bde88636bcd40f

https://www.dropbox.com/s/q121bwb839a15xc/Scrivener%202%20to%203%20conversion.mp4?dl=0

1 Like

The Compile functions are completely different between Scrivener 1 and Scrivener 3, and settings do not automatically translate between the two. An upgrade guide for Scrivener 1 users can be found here:
literatureandlatte.com/scri … -guide-win

Katherine

1 Like

I guess I’ll do that with mine as well. Any tips on how to manually recreate the project? Split windows maybe? I’ve never used that function. Don’t know if I can click and drag text blocks from the binder, or if I need to drill down to Select All text in the editor and copy/paste section by section.

Specifically referring to the “double” contents, that looks to me like a “page header”, being added by the book reader itself. Does that text not change from one page to the next as you go through major sections?

It’s often a good idea to verify that kind of stuff by looking at the actual source itself, to make sure what you’re looking at isn’t something the reader is adding or changing. Compiling to ePub and opening in Sigil is usually the best way of doing this, but if you want to see exactly what is going into the Mobi output, then go into the general options tab of the compile overview screen, and tick the checkbox to “Save source files…”. You can look at these files directly in an HTML editor and verify whether “Contents” is in fact really printed into the output twice.

(As an aside: Amazon recommends using ePub with Kindle Previewer now, not Mobi.)

I’ve added this section back into the manual. It was fixed for ebook output it looks like, and should all be good to go at this point. The only setting relevant to the contents page is the Page title style. If you’re using the built-in Ebook format you shouldn’t have to do anything here. But if you were creating your own from scratch, you would want to create a style in the Styles pane, that establishes the look for the heading, and then wire it up in this pane. This setting also impacts the “Notes” section, if you make use of endnotes in your ebook.

As to the general efficacy of the compile settings upgrade process: basically if Scrivener 1 supported the feature it should map over if you use the legacy format it creates for you. The upgrade guide that Katherine referred to above goes over how to audit that to your specifications.

It’s not going to create stuff that didn’t exist in v1. As noted there were no styles (and the styles used in the compiler are separate from the project anyway), and you couldn’t create a custom table of contents page either, so there certainly are things you would need to add to an older project, if you want to take advantage of new features.

I’ve always advocated working the other way around: bring the settings you want into the project, rather than trying to take an empty template and getting all of your content over into that (that said, if you really do want to do that, there are far better methods than manually going through with copy and paste!). The user manual has a little guide for doing things either way, in §5.4.2, Converting a Project to a Different Template, pg 56. For what you need, points (2) and (4) will be the main things you want to look into.

That said, the challenge listed above, for example of not having a “Table of Contents” section type, is relatively easy to fix if you just want to add these feature to your existing project.

2 Likes

I’ve noticed all my epubs with auto generated TOC have the double ‘Contents’ header too, but in Google Play Books. I had thought it was reader specific as it seems to have no end of trouble with lots of other things. But your post promoted me to download Sigil and have a look.

It’s definitely produced by the compile itself, from a paragraph tag that I’m guessing shouldn’t be there. Snippet of the start of the contents xhtml file of one of my test compiles (epub produced using standard epub 3 compile settings) copied from Sigil below.

> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html>
> <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
> <head>
>   <meta charset="utf-8"/>
>   <title>Contents</title>
>   <link type="text/css" rel="stylesheet" href="css/stylesheet.css"/>
> </head>
> <body>
> <p>Contents</p>
> <nav epub:type="toc" id="toc">
> <h2 class="bordered-title">Contents</h2>

Great, thanks for checking the source. Thus far I am unable to find the combination of settings it takes to produce the results you have. There are two oddities in fact:

  1. The bare <p> of course, which shouldn’t be there.
  2. In your screenshots there is another entry for the part level break that isn’t linked—technically that shouldn’t be there as well.

This book wouldn’t validate for either of those reasons. So somehow you have a setup that is causing entries to be added to the ToC unlinked, and maybe that is causing the secondary problem as well.

Either way, I’m wondering if you can take a look at this test project and see what’s different about it, from what you’re doing, and maybe post a modified version of it that reproduces the issue.

Sample project (173.9 KB)

Not the OP btw :wink: Just someone who noticed the same problem.

From what I can tell comparing your project compile settings and mine, something in the section layouts of my custom compile settings is adding that extraneous paragraph tag so guessing the OP has a similar problem? Just not sure what. Still trying to get my head around the new compile settings.

Amended project with those compile settings saved attached below.
epub_toc_generation_error01 [2021_05_28_15_42_09].zip (171.8 KB)

1 Like

Oops! Thanks for pointing that out. Well it should help the OP out if they still need it—though I do remain curious how the auto-ToC generator is inserting a plain-text “part” like that.

As for this problem, it does appear to be a bug to me. If the compile Format is not set up for ebooks, like Default, then it will lack a style definition for headings, as we discussed earlier in the HTML Elements pane. If that is left without a setting, then for some odd reason we get this plain paragraph inserted into the output. I can think of no reason for why it would do that.

So to fix it, you’d either want to set up a heading style, or start from the built-in Ebook compile format, which is generally going to be the best option anyway. To fix it:

  1. Double-click the format you are using to edit it, and confirm duplication if necessary.
  2. Go into the Styles pane, and click the + button in the top right area. Add anything here, probably just a “Heading 1”.
  3. In the HTML Elements pane, set the Page title style to this new style.

And now it should work.

Was this issue resolved? I just started finding the same problem in my compiled epub3 file.

EDIT: The “Flat Table of Contents” option doesn’t generate a ToC, and the “HTML ToC” options compiles double page headings.

(The table of contents is also a numbered list, which I assume/hope is an option I can disable somewhere. Not sure why it’s not on the Table of Contents options page though.)

Yes, as you confirm, the bug itself has not yet been corrected for. However to repeat what was said above: it’s not a bug that should be a problem for any properly configured compile Format. If you are not starting from the stock “Ebook” compile format because you want a clean slate, then please make sure to follow the checklist given above, to set it up properly with a dedicated heading style. While not setting up a proper internal page heading shouldn’t trigger a bug, you would still want to set one of those up anyway, in other words.

The “Flat Table of Contents” option doesn’t generate a ToC

I’m not seeing that problem specifically. It may be better to start a new bug report thread on that, with full instructions on how to reproduce. For me, ticking that box just creates a flat ToC, as expected—in both the visual HTML page and the internal ToC structure of the ebook.

(The table of contents is also a numbered list, which I assume/hope is an option I can disable somewhere. Not sure why it’s not on the Table of Contents options page though.)

Before you go down a path of trying to change that by hand, do note that doing so would produce an invalid ePub file. Of note:

The ol child of the nav element represents the primary level of content navigation.

Oh, thanks. I had actually changed it to a <ul>, but I guess should switch that back. I guess I could use CSS such as {display: none;} instead. But I shouldn’t have to.

I’d really like to know where the “settings” are for this. I’ve been making ebooks in Scrivener for years and have never had a numbered Table of Contents before. And I didn’t choose to have one, so no idea why I have one now. :thinking:

It changed when we updated the specifications to ePub3. I don’t recall if ePub2 had a formal navigation element like we do now that doubled as a visible ToC page, it was just a regular old HTML page that you could format however you wanted. Now, since it is also used to drive the internal navigation of the book itself, it has more rules that need to be followed. In general you shouldn’t have to worry too much about them though since we take care of all of the details for you.

For example, as for needing to style it, you shouldn’t have to as the software will add that CSS for you (you can check in the CSS pane, in the “Default Stylesheet” column). It uses this CSS, for maximum compatibility:

nav#toc ol {
	list-style: none;
	padding: 0em;
	line-height: 1.5em;
	margin-top: 0.5rem;
	margin-bottom: 0.5rem;
}
nav#toc ol li:before {
	content: none;
}

So you would only need to worry about it if you set the mode in that pane to “Use Custom CSS Stylesheet”. At that point you would have full control, and probably would want to copy and paste some of the prefab stuff we generate into the left column.

I’m not sure why it gave me a numbered TOC. However, after changing it to <ul>, then seeing your reply and changing it back to <ol>… the numbers are gone! Hopefully they stay that way.

I’m on Windows and not able to follow the steps to fix. I do not see any styles in the drop-down list on the HTML Elements pane.

FYI: my background with seeing Contents 2x: This file was a v 1 created in 2017. I tried upgrading that older file to v 3, gave up because of too many compile issues, and created a new v 3 file and dragged or imported my files over. This is my last one.

It should be listing any paragraph styles you have available in the Styles pane (where you would also design how the headings themselves should look).

I would also reiterate from above that in most cases you will be better served by starting from the “Ebook” compile Format, and modifying it to taste. Unless you have experience in HTML/CSS and intend to largely design the book yourself from that angle, or are looking to build a lot of detailing up from scratch, using “Default” or even legacy upgraded settings will require diving straight into the deep end, particularly if all of this is new to you.

I am using ebook format (ebook3) with my section types mapped to the layout. I only have 3 types. I did rename my format so I could reuse for 2nd book I want to re-publish. But no styles appear as drop-down choice for My format under the HTML Elements pane (or any of the other drop-downs).

Oh, sorry for the lack of clarity, when I said “Ebook” compile format, I meant from the list of options in the left sidebar. You pick “ePub 3” as the type of file you want to create, at the top of the window, and then from the left you choose how you want it to look. With ebooks there aren’t many choices (like how with RTF you can choose between manuscript, modern and so forth).

You can try it with no risk, since all of your settings for your current Format are saved. Just selected “Ebook” from that left list, and click on Assign Section Layouts to choose from the many different layouts you can select from, to choose how the book will look, and see if that works better for you in general.

That aside, I don’t know what else to suggest other than to double-check your Styles list again in this custom Format.