Is there a work around for DOI links in bibliographies not spanning the whole URL?

Hello,

is there a work around for the Issue showcased here? The doi prefix does not link to the right place. I need to use APA and have the right prefix. This is kinda urgent…

Hi @Marcel, welcome and thank you for your question! I have changed your post’s title to bring it in line with the question guidelines and thus make it easier to understand from the title:

Good titles are questions you would ask your friend about Typst.

If it’s urgent, I would probably recommend modifying the bibliography file. I tested with the following:

#show link: highlight

#bibliography(
  style: "apa",
  full: true,
  bytes(```
@article{glacier-melt,
  author = {Regine Hock},
  title = {Glacier melt: a review of processes and their modelling},
  journal = {Progress in Physical Geography: Earth and Environment},
  volume = {29},
  number = {3},
  pages = {362-391},
  year = {2005},
  doi = {10.1191/0309133305pp453ra},
  URL = {https://doi.org/10.1191/0309133305pp453ra},
}
```.text),
)

(Note that for next time, you can make it easier for us by adding an example bibliography entry to your post. That way we can immediately start working on your problem, and don’t first need to reproduce it.)

This entry already contains a URL field, but it is ignored in favor of the DOI. If you remove the DOI field, the highlight indicates that the full URL is the link instead.

If you’re interested, the DOI vs URL decision is due to the following code in the CSL used by Typst:

  <macro name="access">
    <choose>
      <if variable="DOI" match="any">
        <text variable="DOI" prefix="https://doi.org/"/>
      </if>
      <else-if variable="URL">
        <group delimiter=" ">
          <choose>
            <if variable="issued status" match="none">
              <group delimiter=" ">
                <text term="retrieved" text-case="capitalize-first"/>
                <date variable="accessed" form="text" suffix=","/>
                <text term="from"/>
              </group>
            </if>
          </choose>
          <text variable="URL"/>
        </group>
      </else-if>
    </choose>
  </macro>

I think it’s the <text variable="DOI"> that produces the link implicitly, and the prefix is not included in this (since it isn’t for all styles), so this can’t be easily fixed by providing a custom CSL style…

2 Likes