Search code examples
rlatexrstudiobookdown

Generate phd html site using bookdown output from latex file


Hum, i trying to understand how R Bookdown generate different html output to migrate easily my phd actually in latex on a html website.

\usepackage[backend=biber,backref=true, natbib=true, isbn=false, doi=true, url=true, style=authoryear,maxcitenames=1, maxbibnames=999, sorting=nyt, refsection=chapter, hyperref]{biblatex}

As you can see, my thesis use biblatex with biber and natbib which permit me to use \autocite and \autocites command. I try multiple configuration to reuse this type of citation directly in markdown (and not [@key] or @key citation), without success.

I start with simple things in index.Rmd :

--- 
title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
bibliography: [these.bib]
biblio-style: apalike
latex_engine: xelatex
citation_package: natbib
link-citations: yes
github-repo: rstudio/bookdown-demo
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."
---

# Introduction

test my citation with \autocite{Pumain1997}.

these.bib contain this simple citation :

@article{Pumain1997,
author = {Pumain, Denise},
doi = {10.3406/spgeo.1997.1063},
issn = {0046-2497},
journal = {Espace g\'{e}ographique},
number = {2},
pages = {119--134},
title = {{Pour une th\'{e}orie \'{e}volutive des villes}},
url = {http://www.persee.fr/web/revues/home/prescript/article/spgeo\_0046-2497\_1997\_num\_26\_2\_1063},
volume = {26},
year = {1997}
}

Solution

  • You need to keep in mind that following rules are applied when rendering the Rmd file

    1. bookdown specific commands will be translated by bookdown into the relevant LaTeX\HTML equivalent
    2. markdown will be converted by pandoc into the relevant LaTeX\HTML equivalent
    3. LaTeX (HTML) will be passed as is when the output format is LaTeX (HTML)
    4. LaTeX (HTML) will be ignored when the output format is HTML (LaTeX)

    Bottom line: use @key and [@key] in case you want to convert the document to both LaTeX and HTML