TransWikia.com

Revise hyperlinks in multiple documents using a master hyperlink text file

TeX - LaTeX Asked by Penguin_Knight on May 21, 2021

While moving my teaching materials online, I got into a little technical challenge and would appreciate any inputs or pointers.

Premise: Every week, I’d have a set of teaching notes. Learning would go through them, work along, and then I’d like them to submit their self-evaluation through an online questionnaire. E.g.:

> documentclass{article}
> usepackage{hyperref}
> begin{document}
> 
> Week one contents here.
> 
> Please fill out href{http://www.QuestionnaireWeek01.com}{this questionnaire} to
> tell us what's the most interesting you learned in this module and
> what's the one muddiest point that you'd like clarified.
> 
> end{document}

Challenge: For each course I’ll have 14 of these notes, and 14 different links to the online questionnaires. Revising them at the beginning of every cycle can be cumbersome. I’d like to see if there is a method to keep all the updated hyperlinks in one file, so that all the 14 documents will refer to this one central document. (Kind of like input, but just for that hyperlink.) Here is a code-like example of what I mean:

% This contains all the hyperlinks, which I can easily update at the beginning of every cycle:
a = http://www.QuestionnaireWeek01.com
b = http://www.QuestionnaireWeek02.com
c = http://www.QuestionnaireWeek03.com
d = http://www.QuestionnaireWeek04.com
e = http://www.QuestionnaireWeek05.com, etc.

And the notes will just refer to the static label instead of the link:

> documentclass{article}
> usepackage{hyperref}
> begin{document}
> 
> Week one contents here.
> 
> Please fill out href{that ``a'' in the master link file above}{this questionnaire} to
> tell us what's the most interesting you learned in this module and
> what's the one muddiest point that you'd like clarified.
> 
> end{document}

… like a macro variable. Maybe through newcommand? I’m just a bit lost at how to go about connecting the two documents.

One Answer

Feeling a little silly now as it seems my question contains a possible answer already. I think I can write up the all the hyperlink in one document called "listurl":

% List of website
newcommand{urlgoogle}{https://www.google.com}
newcommand{urlreddit}{https://www.reddit.com}

and then input that into the preamble of all my weekly notes, like:

documentclass{article}
usepackage{hyperref}

input{listurl}

begin{document}

Week one contents here.

See this href{urlgoogle}{Google} site.

See this href{urlreddit}{Reddit} site.

end{document}

This should work? If there are more straightforward or elegant ways, please kindly let me know.

Answered by Penguin_Knight on May 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP