Trouble Formatting Caption Under Photo

ch
chuckmiller
Posts: 112
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Fri Mar 09, 2018 9:35 pm Post

I'm having a problem getting the caption formatting to stick under a photo in my ebook. I have the text styled with a caption style and have even used preserve text and it refuses to appear centered. I've been able to get it to appear indented and italicized, but can't get it to appear center justified. I have adjustments in the css as follows...

.caption { margin: 3rem 3rem 3rem 3rem; text-indent: 0rem; text-align: center !important; font-style: italic; line-height: 1.2em; font-size: 0.83rem; }

and everything works except for the centering. As seen below...
bio.jpeg
bio.jpeg (543.64 KiB) Viewed 676 times

Any help resolving this would be greatly appreciated.

User avatar
AmberV
Posts: 24306
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Wed Mar 21, 2018 8:50 pm Post

Have you examined the HTML output in an ePub editor? I ask because by default if you use the “Caption” style in the editor, and you’re working from our built-in Ebook format as a starting point, then the default behaviour is to wire the “Caption” style to formal captioning in the HTML Elements format pane. The implication is that the output will use modern HTML5 elements for displaying a figure with a caption:

Code: Select all

<figure>
<img src="images/PastedGraphic.png" alt="This is the text of the caption." id="pastedgraphic" style="height:585px;width:468px;" />
<figcaption>This is the text of the caption.</figcaption>
</figure>


As you can see, there is no element classed as “caption”, and so your selector would do nothing in this scenario. It is using the new <figcaption> element, and if you go over to the CSS format pane and search for figcaption in the “Default CSS” split, you’ll find settings base on however you styled things in the Styles pane.

Thus ultimately it may be as simple as setting centre-alignment in the Styles pane on the “Caption” style. But if you want to do a full override with your own CSS, you can of course use the figcaption selector to do so.

Granted you might be seeing something entirely different depending on your methods—that’s why I suggest looking at the actual output though. Trying to solve this by looking at what the reader prints is tough.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

ch
chuckmiller
Posts: 112
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Mon Mar 26, 2018 11:23 am Post

Thanks for the help with figcaption. That did the trick.