ismayc / thesisdown

An updated R Markdown thesis template using the bookdown package
Other
809 stars 357 forks source link

Hyperlinks in citations #151

Open JVAQUEROM opened 3 years ago

JVAQUEROM commented 3 years ago

Describe the bug I do not get hyperlinks in citations to point out to the references sections (to the particular entry, of course).

To Reproduce Use any citation, and it does not happen. My experience with LaTeX is more in the way of using \cite, \citep, etc. But I am not familiar with this CSL-way.

Expected behavior All citations with a link that points to the corresponding entry in references chapter.

ismayc commented 3 years ago

I can't seem to get this to work either. I was hoping that adding in pagebackref=true to the call to \usepackage{hyperref} and then moving \usepackage[pagebackref=true]{hyperref} to be the last line before \begin{document} in template.tex would do it, but it looks like this might be more of a Pandoc/bookdown issue as I'm not getting bookdown::pdf_book to produce links to citations either.

JVAQUEROM commented 3 years ago

I guess there is no simple way to use normal natbib package with \citet / \citep commands, right?

ismayc commented 3 years ago

I'm not exactly sure, unfortunately.

JVAQUEROM commented 3 years ago

Ok, I'm getting close to getting biblatex to work.

One has to put this in the preamble of the template.tex

\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}
\addbibresource{$bibliography$}

Also, in the index.Rmd, the YAML must be

output: thesisdown::thesis_pdf: citation_package: biblatex

and in the 99-References.Rmd, last line must be:

\printbibliography

The you can knit the index.Rmd. This will fail BUT you have the .tex. Compile to PDF (this will fail). Then in a terminal (I'm on linux) run biber thesis and then you can compile to PDF again, and all goes well.

I am, however, not sure how to tell pandoc to do this, to do it automatically in the knit call

ismayc commented 3 years ago

Thanks for the update! I wonder if RStudio Community may be able to assist? Referencing {bookdown} with template: template.tex instead of {thesisdown} may get you more traction too. I have to imagine there is someone out there that has gotten this to work?

JVAQUEROM commented 3 years ago

I made some tests with {bookdown}'s pdf_book but still having some trouble with natbib. I may try biblatex, but I do not really have much time for tests, I must finish my thesis...

the-jul commented 3 years ago

Hello everyone, I experienced the same issue as described above (in-text citations are not linked to the reference chapter). However, I am was using the command [@author], where @author refers to the bibtex code. Is there anything that can be done include the hyperlink for this citation type? Thanks for you help!

shdam commented 2 months ago

Hey, Perhaps I should have posted it here, but I managed to get biblatex and hyperlinks working in a way where you can swap between using either citeproc (without hyperlinks) or biblatex (with hyperlinks). Here's the comment with the details: https://github.com/ismayc/thesisdown/issues/207#issuecomment-2320675775

Unfortunately, I didn't manage to tell pandoc to run biber, but instead made a script to knit the document.

Hope this is helpful to anyone :)