BibTeX automatically restricts the generated .bbl file to have at most 80 characters in each line. This can have unintended consequences. For instance, I am using the apsrev4-1 bibliography style for APS journals, and this style automatically converts DOI (identifiers for scientific papers) from the .bib file into URLs by turning them into the following:
\href {\doibase xxxx.xxxxx} where \doibase is simply a command that inserts http://dx.doi.org/ and xxxx.xxxxx is the DOI of the given paper. This space does not cause problems in most cases, and the URL gets formatted as http://dx.doi.org/xxxx.xxxxx in the bibliography. However, it can happen that BibTeX decides to break the line between \doibase and the DOI, in which case a space is added and the URL is formatted as http://dx.doi.org/ xxxx.xxxxx which is incorrect and causes problems in some PDF viewers.
I would like to fix this by forcing BibTeX to break the line before each \href. I have been trying to modify the .bst file for this but I have been unsuccessful, the newline$s do not appear in the appropriate place. How can I force linebreaks before all bibliography links?
MWE
In order to reproduce this behavior, I will use the bibliography style apsrev4-1.bst provided by the package RevTeX, but it also needs to be modified to display article titles, as per this answer. The file is very long, so I have copied it here for convenience: paste.ee/p/tj5zj.
If you save this file as apsrev-mod.bst, the minimal working example is then as follows:
\documentclass{article}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@article{entry,
title = {Long title so that it just happens that the line gets broken appropriately},
author = {Author, A and Author, B},
year = {2021},
publisher = {Publisher},
doi = {xxxx.xxxxx},
journal = {Journal}
}
\end{filecontents}
\begin{document}
\cite{entry}
\bibliographystyle{apsrev-mod}
\bibliography{bibliography}
\end{document}
\begin{thebibliography}{5}and\end{thebibliography}in your main tex file ? (be sure to remove lines\bibliographystyle{apsrev-mod},\bibliography{bibliography}, and\begin{filecontents}.....\end{filecontents}). – Cyriac Antony Mar 19 '21 at 07:36