1

I am writing a manuscript using RMarkdown and one issue with in-text citations I haven't been able to figure out is when I have a prefix (or suffix) along with the citation. See the following text for example:

(around 0.07% of the global population, Worldometer 2022)

This can be produced using the following code:

[around 0.07% of the global population, @worldometer2022]

However, in such instances, the prefix should ideally be separated from the rest of the citation by a semi-colon and not a comma. Doing so in the code completely messes up the knitted text:

[around 0.07% of the global population; @worldometer2022]

[around 0.07% of the global population; Worldometer (2022)]

From a different SO post, I realised that this is because Pandoc reads that semi-colon as something else and it therefore needs to be "escaped" using a backslash. However, when I try that, the backlash seems to automatically disappear or be removed each time I save/knit, and I get the same messy text.

Can anyone help me with this? Why is the "escaping" not working? Is there a more efficient way of having semi-colons in the prefix? It's quite an essential feature, as commas are not appropriate everywhere.

Here's my YAML:

---
title: "Test"
author: "A"
bibliography: mybib.bib
csl: ibis.csl # but semi-colon problem occurs even with default csl
link-citations: yes
output: 
  bookdown::word_document2:
    number_sections: true
    global_numbering: true
    fig_caption: yes
    reference_docx: rmd_word_template.docx
---

where mybib.bib is:

@misc{worldometer2022,
  title = {{{COVID Live}} - {{Coronavirus Statistics}} - {{Worldometer}}},
  author = {{Worldometer}},
  year = {2022},
  month = jan,
  abstract = {Live statistics and coronavirus news tracking the number of confirmed cases, recovered patients, tests, and death toll due to the COVID-19 coronavirus from Wuhan, China. Coronavirus counter with new cases, deaths, and number of tests per 1 Million population. Historical data and info. Daily charts, graphs, news and updates},
  howpublished = {https://www.worldometers.info/coronavirus/},
}
zx8754
  • 52,746
  • 12
  • 114
  • 209
  • Without testing, have you considered escaping the semi-colon as in `[around 0.07% of the global population\; @worldometer2022]`? (or `\\;` ...) – r2evans Mar 06 '23 at 14:59
  • 1
    Sorry if I wasn't clear in the post. I tried escaping using `\;` but this backlash automatically gets removed when I save/knit the file. Later I tried `\\;` to make sure, but this just results in the same messy output I have shown in the post, but with one added backslash before the semi-colon. – Karthik Thrikkadeeri Mar 06 '23 at 15:06
  • I haven't tried it, but could you reformulate your text as ("around 0.07% of the global population; @worldometer2022") ? i.e. use regular parentheses/round brackets and then use the un-bracketed "@worldometer2022" to get the citation? – Ben Bolker Mar 06 '23 at 15:45
  • @BenBolker I tried your suggestion of (around 0.07% of the global population; @worldometer2022) and the output is the same as what I'd shown in the post, just with parentheses instead of brackets. And adding quotation marks inside the parantheses also does nothing but add quotation marks in the knitted output. – Karthik Thrikkadeeri Mar 06 '23 at 16:30

1 Answers1

0

I found the following (not so elegant) work around:

[around 0.07% of the global population$;$ @worldometer2022]
johannes
  • 14,043
  • 5
  • 40
  • 51