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

Images are not shown in Word (docx) #488

Closed
miltondp opened this issue Mar 3, 2023 · 13 comments
Closed

Images are not shown in Word (docx) #488

miltondp opened this issue Mar 3, 2023 · 13 comments

Comments

@miltondp
Copy link
Contributor

miltondp commented Mar 3, 2023

If I generate a Word file (docx) for the manuscript (BUILD_DOCX=true) using the latest version of manubot and roostock, none of the images are shown (Twitter, Mastodon, figures for the manuscript, etc). This used to work fine before.

image

@miltondp
Copy link
Contributor Author

miltondp commented Mar 3, 2023

If it helps, I'm attaching the Word document for the manuscript I'm working on.

@agitter
Copy link
Member

agitter commented Mar 3, 2023

Is this only affecting svg images? There are known issues with svg images in docx outputs with some prior discussion in #40 and greenelab/covid19-review#848 (comment)

@miltondp
Copy link
Contributor Author

miltondp commented Mar 4, 2023

Ah, that's super helpful, @agitter. By reading those, I just realized that I need to have the command rsvg-convert in my system. I don't think I saw that in the documentation, only in issues and discussions in other repos. I wonder if we should add librsvg (which provides this command) to build/environment.yml in manubot/rootstock.

@agitter
Copy link
Member

agitter commented Mar 4, 2023

I agree it could be a good idea to add librsvg to the environment now. What do you think @dhimmel? Exporting to docx with svg images isn't the most common workflow, but it is common enough. We must have had users report issues with this at least 5 times. Who knows how many times it has cause problems that went unreported.

I believe we didn't include librsvg in the environment originally because it was not available for Windows. However, the latest version is through conda-forge.

Let's move this issue and discussion to the rootstock repo.

@agitter agitter transferred this issue from manubot/manubot Mar 4, 2023
@dhimmel
Copy link
Member

dhimmel commented Mar 6, 2023

I agree it could be a good idea to add librsvg to the environment now

Yes I agree!

@miltondp
Copy link
Contributor Author

miltondp commented Mar 6, 2023

Great, I'll open a PR to include this dependency.

I'm curious when you say exporting to docx with SVG images is uncommon. I have a couple questions regarding this:

  1. Is there another, more compatible way (across output formats) to include vectorized images in a manuscript?
  2. The PDF output, which we usually use for submission, often has pages with long gaps because some images do not fit nicely (link in here). The only way I see to fix this before submission is editing a docx file and then exporting to PDF. A better way to handle these cases would be to have the option to export to LaTeX. What do you do here?

@dhimmel
Copy link
Member

dhimmel commented Mar 7, 2023

Is there another, more compatible way (across output formats) to include vectorized images in a manuscript?

No I think SVG is best for vector images with Manubot.

The PDF output, which we usually use for submission, often has pages with long gaps because some images do not fit nicely

I tend to think it's better to just live the gaps in the PDF from HTML than to try to create a PDF from Word or LaTeX, given how problematic both of those methods can be. Not against users going the Word or LaTeX route, just that I try to avoid it.

@dhimmel
Copy link
Member

dhimmel commented Mar 7, 2023

@agitter
Copy link
Member

agitter commented Mar 7, 2023

Regarding my statement that exporting to docx with SVG images being uncommon, I meant that I would have expected more issues and error reports if more users were using that workflow because it has been mostly broken. I agree SVG is the best image format.

In the COVID-19 review we were able to reliably export to LaTeX, but it required a fair amount of customization toward the LaTeX template. That makes me hesitant to recommend it for general Manubot users

@miltondp
Copy link
Contributor Author

I tend to think it's better to just live the gaps in the PDF from HTML than to try to create a PDF from Word or LaTeX, given how problematic both of those methods can be. Not against users going the Word or LaTeX route, just that I try to avoid it.

Yes, I tend to think the same. But as you collaborate with others, you find people that prefer to work with Word and/or people that want a well-presented manuscript (without the gaps). I'm trying to find a way to satisfy those, otherwise, we have to use something else (not Manubot) which I want to avoid.

In the COVID-19 review we were able to reliably export to LaTeX, but it required a fair amount of customization toward the LaTeX template. That makes me hesitant to recommend it for general Manubot users

This is related to what I said before. I would be really interested in this option, since it can generate a PDF without gaps. Is there any documentation on this? I found the BUILD_LATEX variable, but I see that the output .tex file need some required statements such as \begin{document}, so not sure how it is supposed to be used.

@agitter
Copy link
Member

agitter commented Mar 10, 2023

Is there any documentation on this?

There's no documentation because there is not yet a single recommended way to do it. The best we have is issue #249 with practices that have worked for those who have tried it. I summarized my experience there and linked out to a different issue with even more detail.

@miltondp
Copy link
Contributor Author

There's no documentation because there is not yet a single recommended way to do it. The best we have is issue #249 with practices that have worked for those who have tried it. I summarized my experience there and linked out to a different issue with even more detail.

Oh, I only needed to add standalone: true to build/pandoc/defaults/latex.yaml to make it work! Yeah, there are many issues with images, etc, but all are solvable. And the final PDF seems to look great. I think we should consider adding that line by default.

@agitter
Copy link
Member

agitter commented Mar 11, 2023

I would be okay adding standalone: true to build/pandoc/defaults/latex.yaml by default. I would typically use a template when working with LaTeX, and setting a template implies standalone mode.

danich1 pushed a commit to danich1/word_lapse_manuscript that referenced this issue Apr 5, 2023
merges manubot/rootstock#489
closes manubot/rootstock#488

* environment: add librsvg
* add note about using SVG files from URL and exporting to docx
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

3 participants