Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figures and Tables in your Crossref examplae #48

Open
gitopandi opened this issue Jun 7, 2022 · 10 comments
Open

Figures and Tables in your Crossref examplae #48

gitopandi opened this issue Jun 7, 2022 · 10 comments
Assignees

Comments

@gitopandi
Copy link

gitopandi commented Jun 7, 2022

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 iandol self-assigned this Jun 9, 2022
@iandol
Copy link
Owner

iandol commented Jun 10, 2022

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: Support for DOCX native numbering? lierdakil/pandoc-crossref#299 - another crossref plugin has a similar request and a bit more progress: Feature Request:Docx native capabilities tomduck/pandoc-fignos#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
Copy link
Author

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
Copy link
Owner

iandol commented Sep 7, 2022

@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
Copy link

iusgit commented Oct 4, 2022

@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
Copy link

iusgit commented Oct 4, 2022

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

@iandol
Copy link
Owner

iandol commented Oct 4, 2022

@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
Copy link

iusgit commented Oct 4, 2022

Correct, tables work as you say.

@gitopandi
Copy link
Author

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

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

@iandol
Copy link
Owner

iandol commented Jul 23, 2024

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>
```

```{=openxml}
<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](placeholder.png)

# B

Blah

![Image B](placeholder.png)

@acxz
Copy link

acxz commented Jul 24, 2024

@iandol can you fix your example with the changes mentioned here: quarto-dev/quarto-cli#2464 (reply in thread) ?

It is also important to link to the pandoc issue regarding lof and lot in docx: jgm/pandoc#8245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants