How to Automatically Underline Links?

I can include this in my yaml to automatically color links: colorlinks: true.
I want links to also automatically be underlined though.
I can manually underline them every time I write them, but that is inconvenient.
I want to do it automatically just like the links are colored automatically.

Which format is your output ?

Depending on it you need to use the proper tool to style your document as you want.

For HTML it quite usual and easy. For PDF with LaTeX, underlined link is not common but I think you can still do it.

My output is bookdown::pdf_document2. My LaTeX engine is xelatex.

consider adding this to your YAML front matter; it will invoke the LaTeX package hyperref, which is a commonly used tool for the hyperlink question

    - \usepackage{hyperref}
    - \hypersetup{colorlinks=false, pdfborderstyle={/S/U/W 1} }

Also consider, and I realise this an approach requiring bigger initial time investment, using a custom LaTeX template for formatting pdf files.

It will allow to standardize this (and alike) formatting choices across a number of pdf documents.

Unfortunately your solution doesn't work, it doesn't change anything.
I am using a LaTeX template, it's eisvogel.

hm... the Eisvogel template has the [hyperref] related section heavily customized - it sort of mixes the links stuff with pdf metadata stuff like author and what not, don't ask me why - and making it underline links is kind of risky with regards to unintended changes elsewhere...

try this fork of the Eisvogel - GitHub - jlacko/pandoc-latex-template: A pandoc LaTeX template to convert markdown files to PDF or LaTeX. - it may (and may not) work in your use case; the changes I made to the eisvogel.tex to make the hyperlinks behave should be obvious in the changelog

Unfortunately, that still didn't work. All it did is change the color of the links, but it didn't underline them.

That is strange... when I compile this report into pdf - with the eisvogel.tex from the forked repo I linked above - on my computer I get both links underlined.

title: "sample document"
date: '2022-03-10'
    latex_engine: xelatex
    template: eisvogel.tex

## R Markdown

This is an [R Markdown document]( Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

It seems that the issue you are facing may be more of "how to customize Eisvogel template to underline links" rather than "how to underline links in a generic markdown document".

I can help with the latter, but my knowledge of the Eisvogel template is limited - and at a quick glance it seems like a rather sophisticated template.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.