0

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?

mzkrc
  • 219
  • 2
  • 7

1 Answers1

0

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

manro
  • 3,529
  • 2
  • 9
  • 22
  • Thank you so much for your comment. Right now, I could border and put different colors in intext citations and urls with your code and `linkbordercolor` and `urlbordercolor` arguments. However, to change the borders for table of content, when I use `menubordercolor`, it just does not work and give the same border color with `linkbordercolor`. When I deleted the`linkbordercolor`, it also gives always red border color although I change it to other colors. Can you help on this issue? – mzkrc Nov 24 '21 at 04:40
  • @muhammet-ozkaraca i added a solution. If i helped to you, you can accept my answer. Thanks ;) – manro Nov 24 '21 at 09:30
  • Thank you so much for your help! Obviously it did helped and apologize for forgetting to accept your solution. However, regarding differentiating the colors for TOC and citations, actually it is still same. I am not sure why but I guess it might be related to R Markdown maybe. – mzkrc Nov 24 '21 at 09:38
  • @muhammet-ozkaraca No problems, I learn with you together. Look at this link: https://tex.stackexchange.com/questions/525261/better-default-colors-for-hyperref-links Maybe, it could help you. If you find a solution, i'll glad to see it here ;) Good luck. – manro Nov 24 '21 at 09:47
  • 1
    I tried something like this `- \definecolor{linkbordercolour}{rgb}{0,0.2,0.6} - \definecolor{citebordercolour}{rgb}{0,0.6,0.2} - \definecolor{urlbordercolour}{rgb}{0.8,0,0.8} - \definecolor{menubordercolour}{rgb}{0.5,0.5,0.5} - \hypersetup {colorlinks = false, citebordercolor = citebordercolour, linkbordercolor = linkbordercolour, urlbordercolor = urlbordercolour, menubordercolor = menubordercolour, pdfborder={0 0 1 [1 0]}, linktoc = all}`(with and without menubordorcolor argument) But still does not work. My conclusion is I think it is all about R Markdown. – mzkrc Nov 24 '21 at 23:37
  • However, in any case, thank you so much for your comment and suggestions. More or less I did what I wanted to do at the end. – mzkrc Nov 24 '21 at 23:40
  • @muhammet-ozkaraca Try to reinstall your LaTeX distribution in free time. Maybe it will help. – manro Nov 25 '21 at 07:37
  • 1
    If I can, I will try this. Thank you so much for your persistence to my inquiries!!! – mzkrc Nov 27 '21 at 14:03