How to add an hyperlink to a section header?
I would like for example to hyperlink my "Publications" section header to my Google Scholar profile. But regular rmarkdown or LaTeX syntax doesn't seem to work. I am using the awesomecv template.
---
surname: Curie
pronouns: she/her
output:
vitae::awesomecv:
page_total: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(vitae)
```
# [Publications](https://scholar.google.com/)
Test 1
# \href{https://scholar.google.com/}{Publications}
Test 2
Test 1 doesn't create an hyperlink, while test 2 results in the following error:
! Argument of \href@split has an extra }.
<inserted text>
\par
l.108 ...://scholar.google.com/}{Publications}}{}}
\label{section}
Error: LaTeX failed to compile Untitled.tex.
See https://yihui.org/tinytex/r/#debugging for debugging tips. See Untitled.log for more info.
Execution halted
Is there any supported way to do this already?
This is not supported, sorry.
The first approach with markdown is closer to producing the correct results, however the processing of headers in the upstream template (https://github.com/posquit0/Awesome-CV) malforms the link.
The generated tex is:
\section{\href{https://scholar.google.com/}{Publications}}\label{publications}
If you look into it and fix the issue, I'd be happy to accept a PR.
I'd be happy to look into submitting a PR for this, but I might need a pointer or two since I am not too familiar with how vitae works and its integration with the Awesome-CV template. You provided the generated tex: is this how it currently looks like (leading to the problem) or how it should look like? And how can I test in a more minimal context the generation of this tex with say a minimal example (so I can play with it until I get it right)?
If I remember correctly, the Awesome-CV LaTeX classes/templates defines macros for \section.
In this macro, it is accepting \href{https://scholar.google.com/}{Publications} in the first position, but whatever it does to it produces the error with an extra } you describe above.
One possible reason would be if it is trying to escape LaTeX code in headers, but this is just a guess and would need investigating/debugging.
But that's where I'd start.
- create a minimal Rmd (as you've done in your great bug report)
- use
keep_tex: trueto get the generated tex file (this is how I got the code in my reply above) - tinker with the
\section{}macros in the tex file to see what works and what doesn't. Looking at the Awesome-CV class and modifying what it does in\section{}might help too. - Find/fix the
\section{}macro so that it works with\href{}inputs
Great, thanks. Is it also worth opening an issue in the Awesome template repo, or are you also maintainer for that one?
You could open an issue there - I don't maintain it but maybe an issue there will get better help from more latex users. Any fixes or changes in the template can then be brought across to this package.
On Sat, Sep 14, 2024, 12:59 AM Rémi Thériault @.***> wrote:
Great, thanks. Is it also worth opening an issue in the Awesome template repo, or are you also maintainer for that one?
— Reply to this email directly, view it on GitHub https://github.com/mitchelloharawild/vitae/issues/264#issuecomment-2349160146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD3BJF7LC6BHPGKPATB3CI3ZWL4T5AVCNFSM6AAAAABK6HGTWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBZGE3DAMJUGY . You are receiving this because you commented.Message ID: @.***>
One idea for example is how the section titles have the colored first few letters. That might be splitting up the href command into several parts, therefore malforming the latex syntax.
On Sat, Sep 14, 2024, 1:01 AM Mitchell O'Hara-Wild < @.***> wrote:
You could open an issue there - I don't maintain it but maybe an issue there will get better help from more latex users. Any fixes or changes in the template can then be brought across to this package.
On Sat, Sep 14, 2024, 12:59 AM Rémi Thériault @.***> wrote:
Great, thanks. Is it also worth opening an issue in the Awesome template repo, or are you also maintainer for that one?
— Reply to this email directly, view it on GitHub https://github.com/mitchelloharawild/vitae/issues/264#issuecomment-2349160146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD3BJF7LC6BHPGKPATB3CI3ZWL4T5AVCNFSM6AAAAABK6HGTWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBZGE3DAMJUGY . You are receiving this because you commented.Message ID: @.***>
When using the markdown strategy, I actually get the following tex:
\section{\texorpdfstring{\href{https://scholar.google.com/}{Publications}}{Publications}}\label{publications}
How should it look like exactly to work "properly"? should it have that many times the word Publications (x3)?