How to cite different authors with the same last name with Bibtex - r-markdown

I am using rmarkdown with bibtex citation package, but don't know how to handle the citation of different authors with the same last name. I found the post https://tex.stackexchange.com/questions/287970/how-to-cite-two-different-authors-with-the-same-surname-in-bibtex, but this does not work with rmarkdown. Any help would be appreciated.
---
title: "Paper"
thanks:
author: |
| \normalfont myself
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
pdf_document:
number_sections: true
citation_package: natbib
fig_caption: true
fig_height: 4.5
fig_width: 8
link-citations: yes
toc: false
bibliography: /Users/jj/Documents/ch3/references02.bib
biblio-style: apalike
in_header: preamble.tex
keep_tex: yes
fontsize: 12pt
linestretch: 1.2
subparagraph: true
number_sections: true
geometry: margin=1in
header-includes:
- \usepackage{amsmath}
- \usepackage{amsthm}
- \usepackage{bbm}
- \numberwithin{equation}{section}
- \usepackage{makecell}
- \usepackage{indentfirst}
- \usepackage{geometry}
- \usepackage{graphicx}
- \usepackage{tikz}
- \usepackage{verbatim}
- \usepackage{chronosys}
- \usepackage{stackengine}
- \usepackage{booktabs, colortbl, xcolor}
- \usepackage{babel}
- \usetikzlibrary{arrows.meta,calc}
- \usepackage[font=small]{caption}
- \usepackage{adjustbox}
- \usepackage{tabularx}
- \usepackage{pgfplots}
- \pgfplotsset{compat=1.7}
- \usepackage[makeroom]{cancel}
- \usetikzlibrary{arrows,decorations.markings}
- \usetikzlibrary{intersections}
- \usepackage[nottoc]{tocbibind}
- \newtheorem{prop}{Proposition}
- \newtheorem{definition}{Definition}
- \newtheorem{algorithem}{Algorithm}
- \usepackage[T1]{fontenc}
- \usepackage{tabularx,ragged2e,booktabs,caption}
- \newenvironment{rcases}
{\left.\begin{aligned}}
{\end{aligned}\right\rbrace}
- \renewcommand{\refname}{References}
- \UseRawInputEncoding
- \usepackage[utf8]{inputenc}
- \usepackage{hyperref}
- \hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=blue,
citecolor = blue,
urlcolor=blue,
}
- \usepackage{subcaption}
- \usepackage[font=small,labelfont=bf]{caption}
- \usepackage{float}
- \usepackage{flafter}
- \floatstyle{plaintop}
- \restylefloat{table}
- \setlength{\parindent}{2.5em}
- \setlength{\parskip}{0em}
- \usepackage{adjustbox}
- \usepackage[style=english]{csquotes}
- \usepackage[nameinlink,capitalize,noabbrev]{cleveref}
- \creflabelformat{equation}{#2\textup{(\textcolor{red}{#1})}#3}
- \creflabelformat{figure}{#2\textcolor{red}{#1}#3}
- \creflabelformat{table}{#2\textcolor{red}{#1}#3}
- \creflabelformat{section}{#2\textcolor{red}{#1}#3}
- \usepackage[toc,page]{appendix}
- \usepackage{rotating}
- \usepackage{accents}
- \newcommand*{\dt}[1]{%
- \accentset{\mbox{\large\bfseries .}}{#1}}
- \DeclareMathOperator{\Tr}{Tr}
- \usepackage{cleveref}
---
references02.bib file is the following:
#incollection{chang2003,
author="Chang, Ha-Joon",
editor="Ha-Joon Chang",
title="Trade and Industrial Policy Issues",
bookTitle="Rethinking Development Economics",
year="2003",
publisher="Anthem Press",
pages="257-276"
}
#book{sjchang2003,
place={Cambridge},
title={Financial Crisis and Transformation of Korean Business Groups: The Rise and Fall of Chaebols},
DOI={10.1017/CBO9780511510861},
publisher={Cambridge University Press},
author={Chang, Sea-Jin},
year={2003}
}
The text would be:
\cite{chang2003} and \cite{sjchang2003} said different things, blah blah...

Related

Journal Name not italicized in rmarkdown pdf

I have recently updated my RStudio. The new RStudio version is 2022.12.0.
Then I have knitted an old manuscript of mine in pdf, but now in bibliography, the journal name is not italicized. Here are my YAML (a little edited for privacy). Before the update, there was no such issue.
I use Zotero to create my bib file. Also if I export reference from zotero to word file, then there is no issue as well regarding Journal name italics.
---
title: |
| \vspace{2cm} THE MANUSCRIPT TITLE
subtitle:
author:
date:
abstract: |
\justify ABABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
|
`r kableExtra::text_spec ("Keywords:", bold = TRUE)` A; B; C.
|
`r kableExtra::text_spec ("JEL Classifications:", bold = TRUE)` C, Y.
<p> </p>
<p> </p>
|
output:
bookdown::pdf_document2:
fig_caption: yes
keep_tex: yes
header-includes:
- \pagenumbering{gobble}
- \usepackage[document]{ragged2e}
- \usepackage{sectsty} \sectionfont{\centering \emph}
- \usepackage{lscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
- \usepackage{xcolor}
link-citations: yes
linkcolor: blue
geometry: "left=2.75cm,right=2.75cm,top=2.5cm,bottom=2.5cm"
fontsize: 12pt
citecolor: blue
urlcolor: blue
toc: false
bibliography: reference_case.bib
---

Some help to write a doctoral thesis with R Markdown

I'm trying to figure out how I could write my doctoral thesis using R Markdown. Usually, I write articles with Latex. But, I'd like to be able to compile my file both for Word and pdf. Could you please help me understand how I could achieve that? I need to number the \frontmatter in roman numbers and the \mainmatter in arabic numbers.
This is my MWE:
---
title: "A title"
documentclass: book
classoption:
- hidelinks
- twoside
- openright
papersize: a4paper
output:
pdf_document:
includes:
in_header: Mypreamble.tex
latex_engine: xelatex
citation_package: biblatex
toc: yes
toc_depth: 4
number_sections: yes
html_document:
toc: yes
toc_depth: '4'
df_print: paged
word_document:
toc: yes
toc_depth: 4
date: "8 juillet 2022"
bibliography: Lectures.bib
fontsize: 12pt
geometry: left=4cm,right=4cm,top=4cm,bottom=4cm
linestretch: 1.2
toc-title: Plan
links-as-notes: yes
link-citations: yes
header-includes:
- \usepackage{fontspec}
- \setmainfont[Mapping=tex-text]{Arial}
- \usepackage [french]{babel}
- \usepackage[backend=biber,style=apa]{biblatex}
---
Introduction
I did my PhD thesis entirely in R Markdown, outputting to Microsoft Word.
I have a Github repository here if it helps: https://github.com/dannyjnwong/PhD_Thesis
I have also previously blogged about the process here:
https://dannyjnwong.github.io/Writing-a-multi-chapter-document-with-R-Markdown/

codeclimate validate-config Error

Am new to code climate and am facing this error when i run my github project on codeclimate.
codeclimate validate-config
ERROR: Unable to parse: (<unknown>): found unexpected end of stream while scanning a quoted scalar at line 23 column 5
Below is my .codeclimate.yml file :
---
machine:
environment:
CODECLIMATE_REPO_TOKEN: ab24b326dac817e772c5246823b67af66e2358e51134c33e20aaf7fb228088b0
engines:
duplication:
enabled: false
config:
languages:
- python
fixme:
enabled: true
pep8:
enabled: true
radon:
enabled: true
ratings:
paths:
- "**.py"
exclude_paths:
- "docs/*"
- "examples/*
-*api/songs/models*
-*/site-packages/*
-*markupsafe/*
-*psycopg2/*
-*six.py*
-*sqlalchemy/*
-*werkzeug/*
-*stringprep.py*
-*uuid.py*
-*ctypes/*
-*decimal.py*
-*encodings/*
-*hmac.py*
-*asyncio/*
-*concurrent/*
-*multiprocessing/*
-*mimetypes.py*
-*numbers.py*
-*pydoc.py*
-*http/*
-*app/api/user/__init__.py*
-*app/api/request/__init__.py*
-*app/api/__init__.py*
-*app/__init__.py*
-*app/config.py*
-*app/model/*
-*test/*
-*html/*
-*_bootlocale.py*
-*typing.py*
The line line 23 which is in the error message is as below in the file above:
- "examples/*
What should i do to correct this?
The problem with that line is it's missing the closing quotation mark. However, all of the exclude_paths patterns will need to be enclosed in quotes; i.e. the config should look like this:
---
machine:
environment:
CODECLIMATE_REPO_TOKEN: ab24b326dac817e772c5246823b67af66e2358e51134c33e20aaf7fb228088b0
engines:
duplication:
enabled: false
config:
languages:
- python
fixme:
enabled: true
pep8:
enabled: true
radon:
enabled: true
ratings:
paths:
- "**.py"
exclude_paths:
- "docs/*"
- "examples/*"
- "*api/songs/models*"
- "*/site-packages/*"
- "*markupsafe/*"
- "*psycopg2/*"
- "*six.py*"
- "*sqlalchemy/*"
- "*werkzeug/*"
- "*stringprep.py*"
- "*uuid.py*"
- "*ctypes/*"
- "*decimal.py*"
- "*encodings/*"
- "*hmac.py*"
- "*asyncio/*"
- "*concurrent/*"
- "*multiprocessing/*"
- "*mimetypes.py*"
- "*numbers.py*"
- "*pydoc.py*"
- "*http/*"
- "*app/api/user/__init__.py*"
- "*app/api/request/__init__.py*"
- "*app/api/__init__.py*"
- "*app/__init__.py*"
- "*app/config.py*"
- "*app/model/*"
- "*test/*"
- "*html/*"
- "*_bootlocale.py*"
- "*typing.py*"
Note: You'll still see some deprecation warnings because you're using the old .codeclimate.yml format. There is information about converting from the old format to version 2 in the CodeClimate docs:
https://docs.codeclimate.com/docs/advanced-configuration#section-analysis-configuration-versions

Writing greek letters in rmarkdown to docx (newcommand for docx)

I am trying to write none-italic "uL" (microliters) in R markdown with the letter "mu".
It is no problem creating a newcommand for PDF that replaces "\microliters" with "uL".
newcommand{\microliters}{\textmu L}
This (of course?) does not work when knitting to docx. As a workaround, I can live with \microliters being replaced by a "uL" with a regular "u" - in stead of "mu".
But how can I create a docx "newcommand", that does that?
I'm not sure about "newcommand", but this works when converting from rmarkdown to docx:
µl
or
μ
I finally got a solution - not sure if any of the packages are mandatory, so I have included them all:
---
title: "Concentrationmeasurements"
author: "Christian Aa. Olesen"
date: "April 29, 2018"
output:
word_document: default
pdf_document:
latex_engine: pdflatex
header-includes:
- \usepackage{float}
- \floatplacement{figure}{H}
- \usepackage{setspace}
- \doublespacing
- \usepackage{lipsum}
- \usepackage{multirow}
- \usepackage[table,xcdraw]{xcolor}
- \usepackage{lineno}
- \linenumbers
- \usepackage{rotating}
- \usepackage{tikz}
- \usepackage{enumitem}
- \usepackage{blindtext}
- \usepackage{textcomp}
- \usepackage{refstyle}
- \usepackage{graphicx}
- \usepackage[font=small,labelfont=bf]{caption}
- \usepackage{tabularx}
- \usepackage[page]{appendix}
- \usepackage{amsmath}
- \usepackage{amsfonts}
- \usepackage{amssymb}
- \usepackage{hyperref}
- \usepackage{textcomp}
- \usepackage{graphicx}
- \usepackage{amsmath}
- \usepackage{xspace}
- \newcommand{\rtmark}{\textsuperscript{\textregistered}\xspace}
- \usepackage{multirow}
- \usepackage{float}
---
```{r,echo=FALSE, results='asis'}
doc.type <- knitr::opts_knit$get('rmarkdown.pandoc.to')
if (doc.type == "docx") cat(paste("\\newcommand{\\microliters}{\\mathrm{\\mu l}}")) else cat(paste("\\newcommand{\\microliters}{\\textrm{\\textmu l}}","\n"))
```

How to add an index to a PDF rendered from an Rmarkdown document using Rstudio on Windows?

The example document below is intended to include an index after the appendix. In a Sweave document, Rstudio would run a shell escape command to create the index .idx file, but I've not been able to find a way to do this for an Rmarkdown document. Is there a simple header command I'm missing?
---
title: "Untitled"
output:
pdf_document:
toc: yes
header-includes:
- \usepackage{makeidx}
- \makeindex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# R Markdown
This is an \index{R Markdown} R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
# Appendix - A
End of the document
\printindex
I've tried this from both the Knit button and using:
rmarkdown::render(rmd.file, output_format = "pdf_document", clean = FALSE)
I'm looking for a solution that can run as part of an automated process.
UPDATE:
I was able to get the index to work by changing the output type to bookdown::pdf_document2. The additional latex packages were required for a combination of indexing, cross referencing, and formatting.
---
title: "Untitled"
output:
bookdown::pdf_document2:
toc: no
geometry: margin=0.8in
header-includes:
- \usepackage{attachfile2}
- \usepackage{booktabs}
- \usepackage{caption}
- \usepackage{float}
- \usepackage[utf8]{inputenc}
- \usepackage{makeidx}
- \makeindex
- \usepackage{multirow}
- \usepackage{setspace}
- \usepackage{relsize}
- \usepackage[table]{xcolor}
- \setcounter{tocdepth}{5}
- \setcounter{secnumdepth}{0}
- \hypersetup{unicode=true,pdfusetitle,bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,breaklinks=false,backref=false,colorlinks=true,linkcolor=blue}
---
While this would work when manually pushing the create PDF button, the call to rmarkdown::render() still does not process the indexing.