包含帶有 \input 的 .bib 檔案不起作用

包含帶有 \input 的 .bib 檔案不起作用

在以下簡單文件中,參考書目不起作用:

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage{inputenc}

\inputencoding{utf8}
\begin{filecontents}{\jobname.bib}
\input{references_utf8}
\end{filecontents}
\inputencoding{latin1}

\begin{document}
\noindent
\cite[voir][chap. 12]{2009solar}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}

我想這樣做是因為我的主要文件採用 latin-1 格式,而 .bib 檔案採用 utf-8 格式。\inputencoding在這個問題中推薦了使用的想法:如何即時將 UTF-8 轉換為 latin-1?

檔案references_utf8.bib看起來像這樣:

@book{2009solar,
address = {New Delhi},
author = {Solanki, Chetan Singh},
booktitle = {Solar Photovoltaics: Fundamentals, Technologies and Applications},
chapter = {12},
edition = {1},
isbn = {9788120337602},
pages = {478},
publisher = {Prentice-Hall of India},
title = {{Solar Photovoltaics: Fundamentals, Technologies and Applications}},
url = {http://books.google.ca/books?id=hdvYA9KsI2YC},
year = {2009}
}

但必須採用utf-8編碼。

我怎樣才能使這個設定起作用?

答案1

bibtex無法處理utf8字元。和bibtex8 一些utf8 字元是可能的,例如變音符號。但是,您可以變更輸入編碼:

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage[latin1]{inputenc}

\begin{document}
\noindent
\cite[voir][chap. 12]{2009solar}

\begingroup
\iputencoding{utf8}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\endgroup
\end{document}

相關內容