MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Editor (https://www.mobileread.com/forums/forumdisplay.php?f=262)
-   -   TOC Formatting Question (https://www.mobileread.com/forums/showthread.php?t=334667)

phossler 11-07-2020 09:26 PM

TOC Formatting Question
 
5 Attachment(s)
Is there any way to have Heading formatting carried over to the Editor TOC?

I have some superscript and subscript formatting in the H1 and the TOC editor does not apply it in in the Editor TOC Editor

I made an inline TOC and it was not there either but I could re-apply it at least



I know that there's 2 TOCs in an epub. ADE seems to use both, the NCX(??) on the left, and the inline one as the TOC (I'm assuming that Calibre assigns TOC as the semantic for the inline TOC file)

Probably not possible to format the NCX(??) TOC, but for the inline file that Calibre generates, it'd be nice if character formatting from the Hx could be carried over. Right now, every time the inline TOC is regenerated, I have to re-apply any special formatting

hobnail 11-07-2020 09:51 PM

The same thing happens with Sigil. From start.xhtml I copied the stuff between the body tags into a new .xhtml file in a new epub3 in Sigil and generated the table of contents and the sub and superscripts are lost.

DNSB 11-07-2020 10:07 PM

Quote:

Originally Posted by hobnail (Post 4055791)
The same thing happens with Sigil. From start.xhtml I copied the stuff between the body tags into a new .xhtml file in a new epub3 in Sigil and generated the table of contents and the sub and superscripts are lost.

ADE rendering an epub2 file and other epub2 renderers will use the ncx file as the source for ToC information. An inline HTML ToC is not necessary and not used by the renderer. The ncx file format is XML not HTML. To quote: "XML stores data in plain text format. This provides a software- and hardware-independent way of storing, transporting, and sharing data." You will notice that you can not link a stylesheet to the ncx file anymore than you can link it to the opf file.

If you are creating an epub3, you can use formatting in the nav document and you can see this if the nav document is in the spine and you are viewing that document. Otherwise, it will be displayed as a plain text document.

kovidgoyal 11-08-2020 12:24 AM

Im afraid not. ToC title are canonically represented as plain text. the inline toc is generated from this canonical representation

phossler 11-08-2020 12:25 PM

@DNSB - thanks for explaining the NCX. I never thought about it being XML so that explains it

@KG - bummer. I prefer to use an inline TOC for a 'complicated' book, and fortunately most times there is no need to tweak the TOC text.

theducks 11-08-2020 12:35 PM

Paul, I understand a bit about using a inline TOC for a 'complicated book' because you can include a lot more (first lines, long chapter titles) than works cleanly with the NCX.

OTOH The NCX TOC works outside the flow of the book. There is no Out and Back when simply viewing. The device keeps the NCX 'on the side'

phossler 11-08-2020 02:00 PM

@theducks -- I agree there are advantages to both.

deback 11-08-2020 06:40 PM

For inline TOCs, after generating them, I copy the STYLE section from a text file over the STYLE section in the inline TOC. The STYLE section in the text file is a template that I created a long time ago after formatting the STYLE section in an inline TOC the way I wanted it to be. This way, a simple copy and paste is needed each time I generate an inline TOC, instead of having to format it each time.

Here is my template that I have saved in a text file:

<style type="text/css">
li {
list-style-type: none;
font-size: 0.85em;
padding-left: 0;
margin-left: 0;
margin-bottom: 0.1em;
}
a {
color: blue;
text-decoration: none;
}
a:hover {
color: red;
}
</style>
</head>

<body id="calibre_generated_inline_toc">

<h3 style="text-align: center;">CONTENTS</h3>

JSWolf 11-08-2020 06:46 PM

If you have an internal ToC you want to be able to easily get to, you an add an entry in the ToC for this. In most cases, there's nothing special about an internal ToC and if that is the case, just drop the internal ToC. It's what I do.

JSWolf 11-08-2020 06:48 PM

Quote:

Originally Posted by deback (Post 4056085)
For inline TOCs, after generating them, I copy the STYLE section from a text file over the STYLE section in the inline TOC. The STYLE section in the text file is a template that I created a long time ago after formatting the STYLE section in an inline TOC the way I wanted it to be. This way, a simple copy and paste is needed each time I generate an inline TOC, instead of having to format it each time.

Here is my template that I have saved in a text file:

<style type="text/css">
li {
list-style-type: none;
font-size: 0.85em;
padding-left: 0;
margin-left: 0;
margin-bottom: 0.1em;
}
a {
color: blue;
text-decoration: none;
}
a:hover {
color: red;
}
</style>
</head>

<body id="calibre_generated_inline_toc">

<h3 style="text-align: center;">CONTENTS</h3>

But do you always need this ToC? Is it somehow different enough to the NCX ToC? In most cases, it's not different enough and the internal ToC can be left out without any problem because it's not going to be used.

thiago.eec 11-08-2020 07:06 PM

Quote:

Originally Posted by deback (Post 4056085)
Here is my template that I have saved in a text file

Have you tried using a snippet?

It is saved right in the editor, and you can invoke it just by typing your predefined trigger (let's say: T), and then pressing CTRL+J.

You can also define placeholders for your template. For instance, I have a snippet for SVG covers. I use placeholders for image url, height and width; you can jump throughout then with CTRL+J, saving you a lot of time. I think it is really useful.

Also, you can pre-select some text and press CTRL+J, before typing your trigger. This way, your selected text will replace one of your placeholders (the one marked with *).

phossler 11-08-2020 11:55 PM

Not sure if this applies

Ref: https://manual.calibre-ebook.com/cus...ates-et-cetera

There is a file with the CSS that gets incorporated into an inline TOC

I copied

C:\Program Files\Calibre2\app\resources\templates\inline_toc_ styles.css

to

C:\Users\userid\AppData\Roaming\calibre\resources\ templates\inline_toc_styles.css

and customized it.


All times are GMT -4. The time now is 06:55 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.