Csl style is not recognized when output in Word

Hi everyone! I'm trying to output a Word document using APA bibliography style. When I compile my document in order to output a PDF, there is no problem at all: citations are listed correctly in the references section. It's the same with HTML output. On the other hand, when I compile my document using Word output, my references are not listed correctly. How could I fix that issue?

This is a reference bib I use:

@Book{Assoun1981,
author = {Assoun, Paul-Laurent}, 
title = {Introduction à l'épistémologie freudienne}, 
publisher = {Éditions Payot}, 
address = {Paris}, 
year = {1981}, }

And this is my MWE:

---
title: "A title"
output:
  word_document:
    toc: yes
    toc_depth: 4
  pdf_document:
    latex_engine: xelatex
    toc: yes
    toc_depth: 4
    number_sections: yes
  html_document:
    toc: yes
    toc_depth: '4'
    df_print: paged
date: "8 juillet 2022"
csl: apa7-fr-couture.csl
bibliography: lectures.bib
fontsize: 12pt
geometry: left=4cm,right=4cm,top=4cm,bottom=4cm
linestretch: 1.5
toc-title: Plan
links-as-notes: yes
link-citations: yes
header-includes:
- \usepackage{fontspec}
- \setmainfont[Numbers=OldStyle,Mapping=tex-text]{Janson Text LT Std}
- \usepackage{fancyhdr}
- \pagestyle{headings}
- \fancyfoot[LE,RO]{\thepage}
- \usepackage [french]{babel}
- \usepackage[numberedbib,nosectionbib]{apacite}
---

# Introduction

[@Assoun1981]

# References

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Please can you format your R Markdown content correctly so that we are able to help you ?

FAQ: How to Format R Markdown Source

I've just modified it.

This is what I get for HTML

and what I get for WORD

It seems the same to me. what is the difference you see ?

I am using Latest Pandoc version also.

Can you share you rmarkdown version and Pandoc version ?

or the whole sessioninfo::session_info() ?

Thank you

(as You did not provide the CSL I used this one http://profmcouture.ca/apa/apa7-fr-couture.csl)

Thanks for your help. I'm sorry: I didn't add that APA style requires an indented bibliography section and that is precisely the issue: using pdf output, my references are indented correctly, not when I try to get a Word output, as you can see on the two following pictures: the first alignment is the good one. My version of Pandoc is the latest. The same for RMarkdown.

a

I don't think the bib file content your provided allows to see this indented difference by the way.

I would suggest using a very small example file with no R to render only with latest Pandoc itself.
I suspect this could be an issue Pandoc citeproc which does not correctly apply the CSL file styling (supposing that the information is correctly encoded in the CSL file).

You may be able to overcome this limitation though by providing a custom template, but I think this is an issue in Pandoc.

Command to run would be I think

pandoc --to docx --from markdown --citeproc -o test.docx  test.md

For HTML

pandoc --to html --from markdown --citeproc -o test.html --self-contained -s test.md

(check pandoc --help to see about the flags)

With simple content for test.md something like

---
title: test
csl: <your csl file or url>
bibliography: <bib file>
---
# Header 1

See < add reference here>

# References

I let you build this simple one as you have the necessary content to create it. Then if you see the issue in this case too, it means it is a Pandoc issue.

My computer skill is very limited. What do I need to do? Launch the terminal and enter...

pandoc --to docx --from markdown --citeproc -o test.docx  test.md

after I created a test example?

yes that is the idea. Otherwise, you can provide me with a github repo for example will all the necessary content that reproduce the issue (including correct CSL and bib file).

Then I can check and open an issue on Pandoc's side if that is necessary.

This is what I get after launching the Terminal :

pandoc: test.md: openBinaryFile: does not exist (No such file or directory)

I noticed that my file in my Finder was named test.Rmd and not test.md. But, even when I change the name of the file, I get the same message from the terminal.

I meant to create a test.md file with simple content (not a Rmd as it does not need code), so that we can check Pandoc behavior

It works with HTML and docx, but with word, the APA format does not appear.
Whatever, this is what I get launching the Terminal, the same message:

pandoc: test.md: openBinaryFile: does not exist (No such file or directory)

Sorry I am not following your last message. What works ?

  • HTML works and APA ok ?
  • DOCX works as render a document, but APA is not ok ?

All this using Pandoc only, no rmarkdown ?

Just trying to sum up the conclusion of the tests

It's exactly what you describe:

  • HTML works and APA ok
  • DOCX works as render a document, but APA is not ok
    All this using Pandoc only, no rmarkdown

But, when I "compile" my doc using my Biblatex citation package, APA is correctly rendered. Is the probleme due to csl?

This would confirm an issue in Pandoc directly.

What do you mean ? How do you use biblatex with Docx ?

I meant : when I use Biblatex and output a pdf, not in order to use Word.

How about Pandoc issue? What would I need to to to fix it?

Oh yes in that case, it won't use CSL if you are using biblatex citation method and a bib style file or a CTAN package.

I would report in Pandoc repo with a reproducible example with Pandoc only like we did above