我有代码。在此代码中,\printbibliography 中的 url 中断不起作用。\url 中的 url 中断起作用。代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
\begin{filecontents*}{references.bib}
@misc
{
mybibkey,
url = {http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}
}
\end{filecontents*}
\addbibresource{references.bib}
\usepackage{hyperref}
\makeatletter
\g@addto@macro\UrlBreaks
{%
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
\do\u\do\v\do\w\do\x\do\y\do\z\do\&\do\1\do\2\do\3%
\do\4\do\5\do\6\do\7\do\8\do\9\do\0\do\/\do\.%
}
\g@addto@macro\UrlSpecials
{%
\do\/{\mbox{\UrlFont/}\hskip 0pt plus 2pt}%
}
\makeatother
%\usepackage{breakurl}
\begin{document}
See~\cite{mybibkey}.
\printbibliography
\noindent\url{http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}
\end{document}
输出:
如果我取消注释 \usepackage{breakurl},我会收到 writeLaTeX 的警告:
/usr/share/texlive/texmf-dist/tex/latex/breakurl/breakurl.sty:
Package breakurl Warning: You are using breakurl while processing via pdflatex.
如何解决?关于此问题,有很多 Google 条目和 Stack Exchange 条目,但都不起作用。
答案1
感谢 Ulrike Fischer,我现在可以发布我所寻找的答案。前面三行\begin{document}
是关键行。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
\begin{filecontents*}{references.bib}
@misc
{
mybibkey,
url = {http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}
}
\end{filecontents*}
\addbibresource{references.bib}
\usepackage{hyperref}
\makeatletter
\g@addto@macro\UrlBreaks
{%
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
\do\u\do\v\do\w\do\x\do\y\do\z\do\&\do\1\do\2\do\3%
\do\4\do\5\do\6\do\7\do\8\do\9\do\0\do\/\do\.%
}
\g@addto@macro\UrlSpecials
{%
\do\/{\mbox{\UrlFont/}\hskip 0pt plus 10pt}%
}
\makeatother
\setcounter{biburlucpenalty}{1} %break URL after uppercase character
\setcounter{biburlnumpenalty}{1} %break URL after number
\setcounter{biburllcpenalty}{1} %break URL after lowercase character
\begin{document}
See~\cite{mybibkey}.
\printbibliography
\noindent\url{http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}
\end{document}
输出: