Cannot understand figures and captions

Da
David Matuszek
Posts: 12
Joined: Sat Jul 21, 2018 4:28 pm
Platform: Mac
Location: Malvern, PA
Contact:

Mon Jul 22, 2019 3:22 am Post

I put the following in Scrivener:

Code: Select all

<$img:pic1.png>
Figure <$n:figure:ref>: First label.

and I get a boxed, centered image with a caption inside the box. I could do without the box, but oh well.

I put the following in Scrivener:

Code: Select all

<$img:pic1.png>
Figure <$n:figure:GroundBreakingEquation>: A groundbreaking equation.

(this is from viewtopic.php?t=12163) and I get a boxed, centered image with the caption outside the box and left-justified.

If I put something like <$n:figure:ref>, this uses different numbering than <$n:figure>, Unlike the code I copied from the link above, every attempt to reference a figure gives me figure 1, never any other number. The copied code works, except for the captions not being in the right place.

This is on a Mac, Scrivener 3.1.3, and mostly I look at the epub results with Calibre, but other epub viewers give the same results.

If I have to use MultiMarkdown or some other complicated tool, can someone suggest an easy way to get started?

It's really conventional for images to be centered, unboxed, with a caption directly below. I think it's incredible that Scrivener can't do this--it does everything else I need, and then some.

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

Mon Aug 05, 2019 6:33 pm Post

I’m not sure how you are getting boxes around your image—that isn’t something any of our default settings do at any rate. It’s certainly something that you could do with your own CSS, or if your viewer is doing that somehow, that may also be where it is coming from.

I find it a lot easier to track down this kind of stuff using Calibre’s editor, where you can see the actual HTML, and the CSS that is used to style things. A step up from that is enabling the Save source files in a folder with exported Kindle or ePub file setting, in the compile’s General Options tab on the right side. That will put all of the source files into a folder, where you can use Firefox (or similar) to better track down where styling is coming from, using its development tools.

As for the alignment of the caption, that’s really up to you. It’s typically going to be best to use a style for your captions, so that kind of decision can be made globally. The default “Caption” style is by default centre-aligned. It also has the added benefit of being handled intelligently by the compiler, when using with ePub and Kindle files, in that it will create a semantically correct figure environment with the image and caption declared within it, rather than just using styled paragraphs (a big advantage here is that we can apply CSS that attempts to keep the image and caption on the same screen). Here is the difference between applying direct formatting and using the Caption style:

Code: Select all

<div class="ps1"><img src="images/test.png" alt="" id="test" style="height:82px;width:174px;" /></div>
<p class="ps1">Figure 1: An image with a test caption.</p>


And here is the CSS that is automatically generated (with default settings) for the .ps1 class:

Code: Select all

.ps1 { margin-left: 0rem; text-indent: 0rem; text-align: center; }


Versus semantic captions:

Code: Select all

<figure>
<img src="images/test.png" alt="Figure 1: An image with a test caption." id="test" style="height:82px;width:174px;" />
<figcaption>Figure 1: An image with a test caption.</figcaption>
</figure>


So in short, you either have to format this yourself, or you have to let Scrivener somehow know that “Figure 12: Blah blah blah” is a caption. It has no idea just because you typed it in one line after the image, that this is what you mean.

If I put something like <n:figure:ref>, this uses different numbering than <n:figure>…


That is correct, they are technically different numbering streams. I’m not sure why precisely, but it has always been that way. You have to give each number a reference point, even if you don’t intend to ever use it.

And as for referencing, you should be using the “<$n#figure:reference>” format for those. These specifically will not increment the counter, even if they occur in the text before the counter is created.

If I have to use MultiMarkdown or some other complicated tool, can someone suggest an easy way to get started?


I haven’t looked at MMD’s ePub generator in a good while, but I think it will still be better to consider Pandoc first (and we offer direct integration of that, once a Pandoc installation is detected).

It’s going to leave a lot more up to you however, with regards to designing the book with CSS. It’s default output is quite vanilla on purpose, to make it easier to apply your own designs—but by that token it is aimed more at those that have a good background in HTML/CSS design. Scrivener greatly benefits from that as well, but its defaults are tuned more toward “inflexible but easy to use” output (like the aforementioned serial-number generated .ps1 class, which is next to useless if you’re working with your own stylesheet—you’d want to turn off the feature that generates that).
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles