
bibファイルに上付き/下付き文字の化学式が含まれている場合、BibLaTeX
cite-styleをapa
一緒に使用すると問題が発生することがわかりました。MWEはmhchem
\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
Mathmode に切り替わることであるようですが、\ce
それを防ぐ必要があります:
\protect
のように単純な を使用すると{\protect\ce{\delta^{18}O}}
、その問題は解決しますが、"O" が小文字になるため、別の問題も発生します。
{\protect\ce{\delta^{18}\MakeUppercase{O}}}
最終的に正しい結果を得るには、かなり複雑なバージョンが必要になります。
実際の bib ファイルには多数のエントリが含まれているため、当然ながら、すべてを手動で変更することは望ましくありません。不思議なことに、-style では問題なく動作しますが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}