
當使用BibLaTeX
' cite-styleapa
以及mhchem
bib 檔案包含帶有下標/上標的化學式時,我發現了一個問題。 MWE 是
\documentclass{article}
\usepackage[version=4]{mhchem}
\usepackage[style=apa, backend=biber]{biblatex}
%\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{Bib.bib}
\begin{document}
This is a citation with only simple chemistry: \parencite{Cite1}.
This is a citation with superscript: \parencite{Cite2}.
\printbibliography
\end{document}
Cite1 僅包含一個簡單的化學式,並且工作得非常好:
@Article{Cite1,
author = {Author, A.},
date = {2020},
journaltitle = {A Journal},
title = {A title with just some \ce{Mg/Ca} chemistry},
issue = {2},
pages = {1--4},
volume = {1},
timestamp = {2020-03-27},
}
引用 2 包含上標,並導致 14 個錯誤:
@Article{Cite2,
author = {Author, B.},
date = {2020},
journaltitle = {Another Journal},
title = {A title with some more complicated \ce{\delta^{18}O} chemistry and a longer title},
issue = {1},
pages = {2--6},
volume = {8},
timestamp = {2020-03-27},
}
問題似乎是,BibLaTeX
切換到數學模式,儘管\ce
應該防止這種情況:
一個簡單的\protect
,如 中{\protect\ce{\delta^{18}O}}
,解決了這個問題,但又產生了另一個問題,因為現在“O”變成了小寫。
我需要相當複雜的版本{\protect\ce{\delta^{18}\MakeUppercase{O}}}
才能最終得到正確的結果:
由於真正的圍脖文件包含許多條目,因此我可以理解地不想手動更改所有條目。奇怪的是,它與 - 風格完美配合authoryear
,問題顯然是apa
- 特定的。我將非常感謝任何關於如何解決這個問題的建議。
答案1
biblatex-apa
應用句子大小寫\MakeSentenceCase*
.該巨集相當複雜,基本上只能處理純文字而不會中斷。
如果您的標題中有複雜的宏,您需要用一對大括號隱藏/保護它們。
支架保護的複雜規則意味著您需要二如果大括號中的內容以巨集開頭並且您想要保留大括號,請使用大括號對。
\documentclass{article}
\usepackage[version=4]{mhchem}
\usepackage[style=apa, backend=biber]{biblatex}
\begin{filecontents}{\jobname.bib}
@Article{Cite1,
author = {Author, A.},
date = {2020},
journaltitle = {A Journal},
title = {A Title with Just Some {{\ce{Mg/Ca}}} Chemistry},
issue = {2},
pages = {1--4},
volume = {1},
}
@Article{Cite2,
author = {Author, B.},
date = {2020},
journaltitle = {Another Journal},
title = {A Title with Some More Complicated {{\ce{\delta^{18}O}}}
Chemistry and a Longer Title},
issue = {1},
pages = {2--6},
volume = {8},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
This is a citation with only simple chemistry: \parencite{Cite1}.
This is a citation with superscript: \parencite{Cite2}.
\printbibliography
\end{document}