LaTeX-Package-Repositories / LaTeX-Package-Repositories/doi
DOI breaking and hyphenation
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 10
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Just now I encountered a situation where a DOI, entered with \doi, was cut across lines and a hyphen inserted at the break, turning
10.1016/j.ijheatfluidflow.2008.07.001
into
10.1016/j.ijheatfluid-
flow.2008.07.001
This is because the doi package uses \href from hyperref, which treats its second argument like normal text. Clearly adding a hyphen inside a URL is a bad idea.
The url package works differently, its does not add hyphens and instead defines possible break points. Heiko Oberdiek pointed out that the best of both worlds is obtained with \nolinkurl, to format (if I understood correctly) the second argument of \href using \url.
The attached example (to be typeset with LuaLaTeX for the above hyphenation to occur) compares the outputs of
\doi{<doi>}
\href{https://doi.org/<doi>}{https://doi.org/<doi>}
\url{https://doi.org/<doi>}
\href{https://doi.org/<doi>}{\nolinkurl{https://doi.org/<doi>}}
\href{https://doi.org/<doi>}{\nolinkurl{doi:<doi>}}
The last of these gives the same output as \doi, without the unwanted hyphen. The only difference is doi:, outside the link with \doi and inside it with \href+\nolinkurl (I prefer the latter).
The whole doi package was introduced to deal with DOIs containing non-sensical characters like
10.1175/1520-0469(1983)040<0396:SWALW>2.0.CO;2
At the time, \href couldn't deal with these characters. Now it seems it can, see the second example in the attached file.
Hence the two questions:
- Is the
doipackage still necessary? Could its functionality be implemented simply with\href{https://doi.org/<doi>}{\nolinkurl{doi:<doi>}}? - Assuming it is still necessary, could the clever breakpoint handling brought by the
urlpackage be combined into it?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the doi package behavior shown in doi-hyphen-example.zip and typeset the comparison with LuaLaTeX. Compare \doi with the \href, \url, and \nolinkurl examples using both DOI values from the issue. Done means DOI links retain valid line-breaking behavior without inserting a hyphen, including the DOI containing special characters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- tex
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100