Text Formatting ⇒ Automatic Linking
-
- Posts: 8
- Joined: Tue Oct 18, 2011 3:37 pm
Automatic Linking
i am looking for a way to automatically set a link on a word or phrase.
example: "my awesome book"
everytime i use this text latex should create a link around this phrase that leads to a section where i present my book.
right now i use hyperref which works but is also a little bit tyring to type it all the time again and again. plus i want to add other words or phrases which makes it inconvenient to go on like this.
is there a way to get it done automatically without "tagging" every single time the phrase?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Automatic Linking
create a macro for it in your preamble, let's say \mybook, which contains the phrase and the hyperlink. In the text use just \mybook. So you save typing, and you have the definition at one place. You could later easily change the definition, such as emphasized formatting or different linking, which has effect on all occurrences in the document.ForenDaddy wrote:right now i use hyperref which works but is also a little bit tyring to type it all the time again and again.
Optionally, if you need such macro it several times and if it's more than just a hyperlink (maybe formatting), create a basic macro, such as \mylink{text}{link}, which contains hyperlinking and formatting commands, and \mybook and \myarticle etc. use that. So one macro is responsible for the functionality of all your internal links.
Stefan
-
- Posts: 8
- Joined: Tue Oct 18, 2011 3:37 pm
Re: Automatic Linking
i don't want to rewrite every word.
i want to search latex for a specific phrase and set the formatting i want.
your way is the other way round. and right now it is quite the same as how i do it. a bit shorter and more powerful but still i have to replace everything.
i am still hoping for the hero on the white horse

- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Automatic Linking
Stefan