Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add an hyperlink to a section header? #264

Open
rempsyc opened this issue Jul 16, 2024 · 7 comments
Open

How to add an hyperlink to a section header? #264

rempsyc opened this issue Jul 16, 2024 · 7 comments

Comments

@rempsyc
Copy link

rempsyc commented Jul 16, 2024

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?

@mitchelloharawild
Copy link
Owner

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.

@rempsyc
Copy link
Author

rempsyc commented Sep 13, 2024

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)?

@mitchelloharawild
Copy link
Owner

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.

  1. create a minimal Rmd (as you've done in your great bug report)
  2. use keep_tex: true to get the generated tex file (this is how I got the code in my reply above)
  3. 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.
  4. Find/fix the \section{} macro so that it works with \href{} inputs

@rempsyc
Copy link
Author

rempsyc commented Sep 13, 2024

Great, thanks. Is it also worth opening an issue in the Awesome template repo, or are you also maintainer for that one?

@mitchelloharawild
Copy link
Owner

mitchelloharawild commented Sep 13, 2024 via email

@mitchelloharawild
Copy link
Owner

mitchelloharawild commented Sep 13, 2024 via email

@rempsyc
Copy link
Author

rempsyc commented Sep 13, 2024

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants