#How to underline links ?
29 messages · Page 1 of 1 (latest)
?render
#show link: underline
https://google.com
As in links to locations in your document?
#link and urls both fall under the #show link: rule, so they both will be affected.
If you only want to underline links within the document, not links to urls you can do
#show link: it => {
if type(it.dest) == "location" {
underline(it)
} else {
it
}
}
OK both solution work actually. Sorry for the confusion and thanks.
Hi, thanks for this! I'd link to make my links both underlined and navy blue; does anyone know how can I achieve this? Right now I have this:
?render
#show link: it => [
#set text(navy)
#underline(it.body)]
https://google.com
But it seems a bit unidiomatic and also note that I can't close the square bracket on a new line because it would add a space after the link, even if there shouldn't be one (e.g. if there were a period after the link).
What do you find unidiomatic unidiomatic about it?
?render
#show link: it => {
set text(navy)
underline(it.body)
}
https://google.com.
Thanks for the quick response!
I'm a super novice with Typst so everything feels a bit unidiomatic haha
For example, why would you set the color but apply underline directly?
Why not set both or apply both?
Also, I don't really get the difference between the square brackets and the curly braces in both our examples. would you mind explaining?
Take a look at the intro pages of the doc. It's a pretty central concept and you'll see it described there in more detail.
In short: you can have content (default, or surrounded like this: [content]) and you can have code blocks (like this: {code}. If you have write [text], you get the word text. If you write {text} you refer to a function called text.
You can call functions from content by prepending # (like This is a #strong(example)). But if you want to call several variables/functions, you'll end up with a lot of # symbols cluttering your way, so you're better off with a code block.
That's a fair question. Ultimately it's because underline is not just a text property but its own thing because it has properties of itself, i.e. you can write set underline(..). However, you could also apply it like set does with show: underline, which basically puts the remainder of the scope into the underline function.
Thanks to you both. @tawny halo I still don't completely get how one would use set underline, would you mind showcasing that by changing the example above?
?render
#show link: it => {
set text(navy)
set underline(stroke: 2pt) // sets properties of underline function
show: underline // wraps everything that follows with the underline function
it.body
}
https://google.com.
Just curious if this works:
(Oops... how do I use the bot? Do I have to put ?render at the very top?)
It has to be a separate message
?render
#show link: it => {
set text(navy)
show: underline.with(stroke: 2pt) // wraps everything that follows with the underline function
it.body
}
https://google.com.
Perfect, thanks 😄