wjschne / apaquarto

A quarto extension for creating APA7 documents in .docx, .html, and .pdf formats
https://wjschne.github.io/apaquarto/
Creative Commons Zero v1.0 Universal
170 stars 15 forks source link

Problem rendering .docx file from visual mode #6

Closed mic-wypych closed 1 year ago

mic-wypych commented 1 year ago

Hi,

awsome resource!

I have a problem with rendering .docx files from visual mode. Once I switch to visual mode .docx file is rendered but when I try to open it word throws an error that it could not open the file. I can render pdf files without problems.

The way I'm getting the problem:

  1. I use quarto use template wjschne/apaquarto to create a new project and name it e.g. test_apa
  2. I open the project and the test_apa.qmd file. I do not change a single thing in the file. When I render from the source editor everything is fine and the .docx file opens nicely.
  3. I switch to visual mode and render again. This time the file gets rendered but when I try to open it I get an error from word.
  4. I switch back to source editor. I render again but the error is still there.

Took me a day to find a possible reason. It seems to be a problem with how Appendix title is written. On line 291-292 of the template file there should be: {{< pagebreak >}} # Appendix And switching to visual mode and back to source mode changes it to {{< pagebreak >}} \# Appendix

This results in an error when you try to open a .docx file rendered from visual mode. Adding an additional line between the pagebreak and appendix title solves the issue. I have no idea why rendering to pdf is not affected by this.

I hope this will save some people time if they run into a similar problem

Additional notes (maybe relevant):

  1. I currently work on windows 10
  2. I use quarto 1.3.340 and R 4.3
wjschne commented 1 year ago

Thanks! I rarely use the visual mode, so I would not have noticed for a long time. I fixed the error as you suggested.

mic-wypych commented 1 year ago

Glad I could help! The visual mode is mainly useful for Zotero for me as I'm having trouble inserting citations in source editor.