In writing my resume, I have found \hypersetup{baseurl=url} to be quite handy. For example, I could just define my GitHub homepage as the base URL and write \url{helloworld} to have it automatically point to the project page while showing only the project name on paper. On the other hand, I could also define the DOI homepage as the base URL and write ##.####/xxxxxx and have a valid DOI link. The problem is I can't do both in one document.

According to the hyperref package documentation:

A base URL is established, which is prepended to other specified URLs, to make it easier to write portable documents.

From the description, it seems I just have to use this user macro, but it didn't work.

How do I achieve what I want without resorting to hacks like this? Am I just misunderstanding something and using the macro wrongly?


The base URL is a global property of the PDF file and is written in the document's catalog object. Therefore, it cannot be changed locally.

There are packages like doi or doipubmed that provide a \doi macro.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.