r-markdowncitationshyperref

How to add border in-text citations in R markdown?


I am relatively a new user in R and for the last couple of days, I was looking how to put borders in in-text citations in Rmarkdown. Based on what I have seen in the web, I prepared this YAML front.

title: "Bla Bla Bla"
author:
  - Bla Bla Bla
output:
  pdf_document:
    latex_engine: xelatex
header-includes:
    - \usepackage {hyperref}
    - \usepackage {xcolor}
    - \hypersetup {colorlinks = true, linkcolor = green, urlcolor = blue, linkbordercolor = {1 0.5 0.25}}
bibliography: ["Bla Bla Bla.bib"]
link-citations: yes
fontsize: 12 pt
biblio-style: apsr
date: "`r format(Sys.time(), '%B %d, %Y')`"
linestretch: 1.5
ident: True

With this YAML, I am able to use different colors in in-text citations thanks to hyperref package from LaTeX. When I read its documentation, actually it says that if I use linkbordercolor argument (I also tried "citebordercolor" argument as well but it did not work neither), it should put borders around in-text citations but it does not actually. (I also looked at xcolor documentation as well and the same was written at there as well (look pg. 27 in http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/xcolor/xcolor.pdf)

Thus, can you help me so that I can be able to add borders around citations?


Solution

  • Try this header:

    header-includes:
    - \usepackage{hyperref}
    - \usepackage{xcolor}
    - \hypersetup {frenchlinks=true, colorlinks = false, pdfborder={0 0 1}} 
    

    Output:

    enter image description here


    Addition:

    - \hypersetup {frenchlinks=true, colorlinks = false, pdfborder = {0 0 1},  citebordercolor=violet,  linkbordercolor=green,  urlbordercolor=blue}
    

    enter image description here