Using the wonderful Scrivomatic to compile/export to docx and latex and the exported output does not honor centering format for my figures styled as ‘no style’ but centered using Format->Paragraph->Center with or without ‘Preserve Formatting’ checked. Captions are centered as requested in the exports. I’m new to Scrivener so am probably missing something simple. Any suggestions would be most appreciated. Thank you.
Centering will depend entirely on the LaTeX or DOCX template, this is not something Scrivener’s editor text settings control. The sample scrivomatic output does show centered images for LaTeX PDFs:
I reran my default scrivomatic project and still get centered images for LaTeX, so it isn’t a simple change in LaTeX.
Ah, but DOCX doesn’t center any more (it used to). I see that my current DOCX template was not setting the Captioned Image
style to center. I just changed it:
And pushed the new template to my dotpandoc repo (if you used git you can git pull
this change, otherwise download the file and manually replace it):
With this figures are now centered in my DOCX scrivomatic sample output:
Note: you can edit this file to make your DOCX output exaclty how you want it, it is a really cool feature of Pandoc’s DOCX output…
Thanks. Yes, your custom.docx mod works for me. For latex, I am using your latex-refs and then converting to pdf using pdflatex after export. I suspect I am not yet using Scrivener styles properly as now docx export centers my figure but not its caption while the pdf has the caption centered but not the figure. I’ll figure this out or, worst case, simply edit the tex file. I really appreciate the direction you are going with Scrivomatic.
My use case is that I am a long time tex user with colleagues who prefer Word/docx. If I can communicate with them while needing to learn next to nothing about Word that would be a huge win. I really like that md, like tex, is pure editable text. Beyond that, the abstraction you have implemented coupling Scrivomatic with Pandocomatic is simply beautiful. Thank you again for making this available!
If you create a minimal scrivener project that reproduces your problems I can take a look, that will show up if the problem is a markdown formatting problem — your intermediate markdown output from Scrivener should look like this for figures (new lines before and after are important):

Note for TeX compilation I always use XeLaTeX or LuaLaTeX as, UTF-8 should be a bare minimum this day and age… But it is surprising that TeX output doesn’t center for you as Pandoc directly emits image blocks with \centering
enabled (i.e. even before a template comes into play), you can easily test that at the command line (if you run pandoc without a file it accepts simple input typed into the terminal then type [ctrl][d] and pandoc will run on your text):
> pandoc -t latex

\begin{figure}
\centering
\pandocbounded{\includegraphics[keepaspectratio,alt={Caption}]{xkcd.png}}
\caption{Caption}
\end{figure}
centering is directly emitted, but perhaps your latex template doesn’t specify \pandocbounded
and perhaps this interferes with layout (my custom.latex has this at line 100, taken from the default pandoc template)?
Here is a snippet from the md file. assort.png is stored in the binder.
implications of some of our results in the context of the Electoral College.
![**Figure 1** Assortativity Map][assort]
In **Fig. 1** $elect20G$ is laid out geographically with vertices located
Image label is in parens not square brackets in the md file.
WRT to pdflatex, I recall taking a ‘Missing \begin{document} using xelatex so I reflexively switched to pdflatex. I’ll revisit that once I better understand how Scrivener styling works.
The square+square brackets should be valid as long as you see a link reference at the end that corresponds to the image, like [assort]: assort.png
– this should generate valid latex, what does your latex show for this fragment?
In the small example I sent you, the tex is fine.
Figure and caption below should be centered.
\begin{figure}
\centering
\includegraphics[width=2.46875in,height=0.84375in,alt={Figure 1 Assortativity Map}]{assort.png}
\caption{\textbf{Figure 1} Assortativity Map}
\end{figure}
Is \textbf{Fig. 1} and caption centered?
\end{document}
The tex looks good and the pdflatex conversion works as expected with both figure and caption centered in the pdf.
The docx, however, has centered figure but left justified caption.
–Stu
I modified the Image Caption style in my copy of your custom.dox to center the text line and now both image and caption are centered. The latex continues to center both image and caption properly. I didn’t seem able to override the docx image caption format from within Scrivener though this probably reflects my newness with Scrivener and unfamiliarity with Word. Having to edit docx this way seems to go against the spirit of styles. Any way, if ever I see you in real life, I owe you several good espressos. Thanks! --Stu
Styles in Scrivener do TWO different things:
- In the editor they control the RTF visualisation, and this can directly impact some compiler output (like RTF targets and others). But NOT markdown, so your RTF editor centering will not make it out via Pandoc…
- For markdown/text compiler workflows, styles are semantic labels that you can use to inject structural meaning. The visual effect in the editor is not transferred, only the “meaning”.
For example, lets take the Small Caps inline style. You apply it in the editor and you see small caps there. You compile it and you see small caps in the LaTeX output. BUUUUUT it is not the “look” that makes it across, the RTF small caps themselves are totally lost. Imagine here that | is the selection in the Scrivener editor and the caps are a visualisation of small caps:
Some text with |SMALL CAPS| segment.
Scrivener’s compiler takes this text, throws away the RTF completely and injects the correct plain text markdown that semantically labels the text:
Some text with [small caps]{.smallcaps} segment.
This is semantically labelled normal plain text. Pandoc then translates [...]{.smallcaps}
into whatever the target output uses to visualise this. For DOCX Pandoc uses named styles, and so you edit the custom.docx
template. This is IMO totally in the spirit of styles - semantic “buckets” that text lives in that can be [re]visualised. Look A → [abstract semantic intermediate] → Look B…
And in some cases, visual outputs that are not present in RTF can still be used. Here for example you’ll see some styles applied in Scrivener:
The first box is angled text, and it isn’t angled in Scrivener. However we can use Pandoc → Typst (a wonderful PDF layout engine, better IMO than LaTeX), and we get:
It is not the visual look that is transferred, but the semantic meanings that can then drive layout in the target. You could do something like this for centered text blocks, but really it is easier to adjust the template / reference document in the case of figures and captions…