如何優雅打破長土井場

如何優雅打破長土井場

這是我論文中的程式碼片段。

\RequirePackage{filecontents}

\begin{filecontents}{bib.bib}
@article{baumert62,
  author = {Baumert, Leonard and Golomb, Solomon W. and Hall, Jr, Marshall},
  doi = {10.1090/S0002-9904-1962-10761-7},
  journal = {Bulletin of the American Mathematical Society},
  number = 3,
  pages = {237--238},
  title = {Discovery of an Hadamard Matrix of Order 92},
  volume = 68,
  year = 1962
}

\end{filecontents}

\documentclass{article}

% for back reference in bibliography
\usepackage[ocgcolorlinks,pdfusetitle]{hyperref}

% for biblatex with biber
\usepackage[
  backend=biber,
  style=alphabetic,
  citestyle=alphabetic,
  backref=true]{biblatex}

% for DOI field
\usepackage{doi}

\addbibresource{bib.bib}

\begin{document}
The first missing order of 92 was resolved in 1962 by Baumert, Golomb,
and Hall Jr. \cite{baumert62} who ran computer experiment on Williamson's method.

%%% bibliography
\printbibliography
\end{document}

它產生一個參考書目項目,其DOI字段太長。

在此輸入影像描述

當然,我想每個人都想修復它。我知道我可以使用以下內容,如中所述線。

\setcounter{biburlnumpenalty}{100}  % allow breaks at numbers
\setcounter{biburlucpenalty}{100}   % allow breaks at uppercase letters
\setcounter{biburllcpenalty}{100}   % allow breaks at lowercase letters

我不想允許在數字、小寫字母和大寫字母處換行,而是允許在特殊字元處換行,例如/,.-。當我處理 DOI 欄位時,我認為這些是更適合允許換行的地方,而不是普通的字母數字字元。我怎樣才能做到這一點?

答案1

此選項ocgcolorlinks不允許連結中出現換行符。

hyperref的自述文件

實驗選項“ocgcolorlinks”

這個想法是在查看時使用彩色鏈接,但在列印時不使用顏色。

  • 主要缺點:連結不能跨行斷開。

換句話說,它與選項 幾乎相同colorlinks,但有兩處不同。

  • colorlinks允許在連結中換行,而ocgcolorlinks不允許;
  • colorlinks列印文件時保留顏色,而ocgcolorlinks以黑色列印。

那麼,你可以做些什麼來規避這個問題呢?

使用該colorlinks選項而不是ocgcolorlinks在列印文件時選擇以“黑白”列印。

微量元素:

\RequirePackage{filecontents}

\begin{filecontents}{bib.bib}
@article{baumert62,
  author = {Baumert, Leonard and Golomb, Solomon W. and Hall, Jr, Marshall},
  doi = {10.1090/S0002-9904-1962-10761-7},
  journal = {Bulletin of the American Mathematical Society},
  number = 3,
  pages = {237--238},
  title = {Discovery of an Hadamard Matrix of Order 92},
  volume = 68,
  year = 1962
}

\end{filecontents}

\documentclass{article}

% for back reference in bibliography
\usepackage[colorlinks,pdfusetitle]{hyperref}

% for biblatex with biber
\usepackage[
  backend=biber,
  style=alphabetic,
  citestyle=alphabetic,
  backref=true]{biblatex}

% for DOI field
\usepackage{doi}

\addbibresource{bib.bib}

\begin{document}
The first missing order of 92 was resolved in 1962 by Baumert, Golomb,
and Hall Jr. \cite{baumert62} who ran computer experiment on Williamson's method.

%%% bibliography
\printbibliography
\end{document} 

輸出:

在此輸入影像描述

答案2

只是為了完整性ocgcolorlinks(彩色連結列印為黑色)現在可以使用ocgx2包裹:

\usepackage{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}

微量元素:

\RequirePackage{filecontents}

\begin{filecontents}{bib.bib}
@article{baumert62,
  author = {Baumert, Leonard and Golomb, Solomon W. and Hall, Jr, Marshall},
  doi = {10.1090/S0002-9904-1962-10761-7},
  journal = {Bulletin of the American Mathematical Society},
  number = 3,
  pages = {237--238},
  title = {Discovery of an Hadamard Matrix of Order 92},
  volume = 68,
  year = 1962
}

\end{filecontents}

\documentclass{article}

% for back reference in bibliography
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[pdfusetitle]{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% for biblatex with biber
\usepackage[
  backend=biber,
  style=alphabetic,
  citestyle=alphabetic,
  backref=true]{biblatex}

% for DOI field
\usepackage{doi}

\addbibresource{bib.bib}

\begin{document}
The first missing order of 92 was resolved in 1962 by Baumert, Golomb,
and Hall Jr. \cite{baumert62} who ran computer experiment on Williamson's method.

%%% bibliography
\printbibliography
\end{document}

答案3

您可以使用http://shortdoi.org正如 @matth 所提到的,為 DOI 創建一個簡短的持久別名。這些縮短的 DOI 與規範的 DOI 相比有幾個優點:

  1. 它們足夠短,因此不需要斷線。
  2. 它們很容易從紙上複製。如果您只有一篇文章的紙本副本(僅搜尋標題/作者更容易),那麼長的 DOI 幾乎毫無用處。
  3. 它們更美觀,這意味著出版商和合著者的阻力更少。

我編寫了一個腳本,該腳本將處理現有的 BibTeX 檔案並用縮短的 DOI 替換所有 DOI 名稱: https://github.com/mosco/bibtex-shorten-doi

需要注意的是:不幸的是,短DOI 不被視為正確的DOI,並且不能用於在doi.org 以外的任何網站(例如CrossRef、Sci-Hub 等)上進行手動查找。建議自動轉換您參考書目中的所有 DOI。

相關內容