Cannot get text to be centered when compiling to html

Hello,

I’ve just starting working with Scrivener, and so far everything has been great except for one thing: No matter what I try I cannot compile to HTML and preserve centered text. It always aligns to the left, except for indents.

I’ve tried using paragraph styles. I’ve tried compiling As-Is. I’ve tried tinkering with every setting I can find, both for my existing project and a new default project. Nothing seems to work.

I’m new, and so I’m probably just overlooking something simple. Does anyone have any advice or suggestions?

Thanks!

What are you using to inspect the output file?

It’s very difficult to force particular formatting in ePubs, browsers, and so on, as the reader software can often override whatever the file defines.

Do you see the same behavior if you compile to another format, such as PDF or Word?

1 Like

Kewms, thanks for your reply.

I have used Firefox and Microsoft Edge to look at the file and both show it without being centered.

No, the same behavior does not happen in other output formats. PDF and Word both keep the centering intact. Looking at the HTML code it appears that there’s no centering code at all. However, when I export the file to .html instead of compiling it to .html centering code is maintained. That makes me think that I’m doing something wrong in the compiling process.

A couple of suggestions to try (if you haven’t done so already):

  1. Mark all centred paragraphs with Format → Preserve Formatting.

  2. To make it easuer going forward, create a “center” style with centred alignment and Preserve Formatting set. Without futzing around, my understanding is that when you compile to html, “Override Text and Notes Formatting” is set, so the compiler will treat centred text as a normal <p>…</p> unless it is specifically told to use <p align="center">…</p>.

  3. Hope that the ultimate guru, @AmberV comes along soon. :laughing:

Mark

2 Likes

Thanks Mark, but I followed all of your instructions to the letter, and it still ignores the centered text when compiling to html.

I even tried compiling with multiple different layouts (default, as-is, etc.). I even started a brand new project with just three lines of text (one centered normally, one not centered as a baseline, and one centered using your custom style and preserved formatting). Still no luck.

I appreciate the attempt in any case lol. :grinning:

1 Like

I don’t think you are doing anything wrong, this looks like a bug to me. If we look at an example using the stock “Centered Text” style in conjunction with the Modern compile format, we get something like this:

<p class="ps1"><span class="s1">Re teng thung...</span></p>
<p class="ps2"><span class="s1">This is an example of some text using the stock "Centered Text" style.</span></p>
<p class="ps1"><span class="s1">Groum ma...</span></p>

So that should at least provide a hook for there to be a different CSS setup on this line, given it is using .ps2 instead of .ps1. But if we look at the stylesheet element in the document head, there are no paragraph classes being added to match the ones in the HTML and describe them. Neither .ps1 nor .ps2 exists, and thus the formatting is broken for body text as well, not just the lack of alignment in the special styled line.

Well, at least you know how to fix it now, even if the fix is to manually edit the file and make sure you have the right “psn” indicated.

2 Likes

Thanks AmberV, that is reassuring. I appreciate your thorough example. :slightly_smiling_face:

I’ll take your suggestion and just add the necessary code myself. It really isn’t that big of a hassle for this project. Hopefully it is something that can be patched in the future.

No problem. As a Mac-user, I have no idea of the wrinkles in the Windows compile system… not that I know that much of what goes on behind the scenes on the Mac either, truth be told.

Anyhow, AmberV has spoken :grin: and you know what you need to do for the moment. Let’s hope that bug gets sorted soon.

:slight_smile:

Mark

1 Like

Thanks for the report! I suppose not many people use the HTML output for much, at least not with anything much beyond normal text that is! :laughing:

1 Like