iandol / scrivomatic

A writing workflow using Scrivener's style system + Pandoc for output…
https://iandol.github.io/scrivomatic/
GNU General Public License v3.0
297 stars 30 forks source link

Figures and Tables in your Crossref examplae #48

Open gitopandi opened 2 years ago

gitopandi commented 2 years ago

Hi,

I used you crossref examplae, because I'm switching from pure Markdown with Typora as my editor back to Scrivener. Your setup works fine, but I have issue with figures and tables:

  1. In the markddown file the second figure with the [#fig:...] syntax isn't shown in Typora, because of the path to the figure is in square brackets. See attached screenshots.
  2. Both figures are shown in the Word .docx file but the captions are not recognized in Word, not for the figures and not for the tables. And no lists for figures and tables are generated automatically. If I try to insert a list of figures Word do not find any captions. See also the screenshot attached.
  3. In Word I get the message in the third screenshot if I open it. Are the issues maybe related to the message?

Any help is appreciated and thanks very much for your work during the last years

Andreas CleanShot 2022-06-07 at 08 07 07@2x

CleanShot 2022-06-07 at 08 03 46@2x

CleanShot 2022-06-07 at 08 09 35@2x

iandol commented 2 years ago

Hi Andreas,

I have made some small tweaks to the Crossref project, and updated the repo with a newer zip file. but I don't think this will change your observed behaviour.

  1. Scrivener generates image syntax using the reference link syntax. This uses ![caption][ref link] to define the figure. This is valid pandoc markdown (and is also part of the original markdown spec, and commonmark too), so I'm somewhat confused why Typora doesn't support this? I've never used it (I use VSCode to edit markdown if I need to), so I don't know what flavour of markdown it supports…
  2. pandoc-crossref doesn't generate native figure numbers, I made an issue on this but the developer does not want to add output-specific code: https://github.com/lierdakil/pandoc-crossref/issues/299 - another crossref plugin has a similar request and a bit more progress: https://github.com/tomduck/pandoc-fignos/issues/34 — one thing to look out for is that Quarto https://quarto.org has built a new cross referencing filter for pandoc which may or may not generate native figure numbering on Word… Note if you use LaTeX then lists of figures etc. works fine.
  3. No, this warning is simply related to the fact the docx template file uses a field to put the current title in the footer. Word fields can be abused so Word asks you explicitly.
gitopandi commented 2 years ago

Hi Ian,

After a while I'm back to writing. Thanks al lot for you answers and infos. I solved the issue with the figures and understood what my wrong thought was.

If I have more time I will have a look to quarto. In the mean time i use a PDF to Word converter. With a few manual corrections, the word doc is O.K.

iandol commented 2 years ago

@gitopandi — By the way, I just checked Quarto does not [yet] support native Figure labels for DOCX. BUT I noticed at least in the most recent Word you can build the list-of-figures (LOF) based on styles and each figure caption has the style "Image Caption" so you can the LOF.

I am very surprised a PDF > DOCX converter produces better output than Pandoc?

iusgit commented 2 years ago

@iandol Could you provide the openxml lines to create the LOF based on style? Is the magic in here: <w:instrText xml:space=\"preserve\"> TOC \h \z \u </w:instrText>?

iusgit commented 2 years ago

OK, found it: TOC \h \z \t "Image Caption" \c would provide everything of style "Image Caption". Thanks for mentioning this possibility!

iandol commented 2 years ago

@iusgit -- great, for tables I would assume it would be TOC \h \z \t "Table Caption" \c. I'd made a test docx but it seems you got there first.

I assume that a Lua filter could insert this into the DOCX to allow lof to work with DOCX while we wait for Quarto, pandoc-crossref and others to update to utilise native numbering...

iusgit commented 2 years ago

Correct, tables work as you say.

gitopandi commented 1 year ago

I am very surprised a PDF > DOCX converter produces better output than Pandoc?

It was as you think. Pandoc was the best option 😄

iandol commented 4 months ago

An example of injecting a TOC and LOF manually into a docx:

---
title: hello
author: Jane Doe
---

```{=openxml}
<w:sdt>
<w:sdtPr><w:docPartObj><w:docPartGallery w:val="Table of Contents" /><w:docPartUnique /></w:docPartObj></w:sdtPr>
<w:sdtContent>
<w:p><w:pPr><w:pStyle w:val="TOCHeading" /></w:pPr><w:r><w:t xml:space="preserve">Table of Contents</w:t></w:r></w:p>
<w:p><w:r><w:fldChar w:fldCharType="begin" w:dirty="true" />
<w:instrText xml:space="preserve">TOC \o "1-3" \h \z \u</w:instrText>
<w:fldChar w:fldCharType="separate" /><w:fldChar w:fldCharType="end" /></w:r></w:p>
</w:sdtContent>
</w:sdt>
<w:sdt>
<w:sdtPr><w:docPartObj><w:docPartGallery w:val="Table of Figures" /><w:docPartUnique /></w:docPartObj></w:sdtPr>
<w:sdtContent>
<w:p><w:pPr><w:pStyle w:val="TOCHeading" /></w:pPr><w:r><w:t xml:space="preserve">Table of Figures</w:t></w:r></w:p>
<w:p><w:r><w:fldChar w:fldCharType="begin" w:dirty="true" />
<w:instrText xml:space="preserve">TOC \h \z \t "Image Caption" \c</w:instrText>
<w:fldChar w:fldCharType="separate" /><w:fldChar w:fldCharType="end" /></w:r></w:p>
</w:sdtContent>
</w:sdt>

A

Blah

Image A

B

Blah

Image B

acxz commented 4 months ago

@iandol can you fix your example with the changes mentioned here: https://github.com/quarto-dev/quarto-cli/discussions/2464#discussioncomment-10131723 ?

It is also important to link to the pandoc issue regarding lof and lot in docx: https://github.com/jgm/pandoc/issues/8245