参考文献出现 `Invalid UTF-8 byte or sequence`
rami3l opened this issue · 6 comments
rami3l commented
如下的由 Zotero 导出的 BibTeX 条目(导出选项为 UTF-8 with BOM)
@article{cebiric_compact_2018,
title = {Compact {Summaries} of {Rich} {Heterogeneous} {Graphs}},
abstract = {Large data graphs with complex and heterogeneous structure, possibly featuring typed data and an ontology encoding the application-domain semantics, are widely used nowadays. The literature provides many solutions for building succinct representations of graphs, called summaries, in particular based on graph quotients through an equivalence relation between graph nodes.},
language = {en},
author = {Čebirić, Šejla and Goasdoué, François and Guzewicz, Pawel and Manolescu, Ioana},
year = {2018},
pages = {44},
}
在参考文献列表中显示为
log 中对应报错信息为
Invalid UTF-8 byte or sequence at line 193 replaced by U+FFFD.
Missing character: There is no � in font Times New Roman/OT:script=latn;language=dflt;mapping=tex-text;!
但替换 Š
为 {\v{S}}
后能正常显示。
note286 commented
rami3l commented
@note286 感谢你的回复。
在我的论文中,正文的 Š
能正常显示。
上面的源码我也能够通过编译(环境为 MiKTeX 23.1 on Windows 10,XeLaTeX 编译,Times New Roman v7.00),显示结果正常。
怀疑为 natbib
相关问题。我将尝试给出最小复现。
rami3l commented
test.tex
\documentclass{article}
\usepackage[english]{babel}
\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}
\begin{document}
This document is citing \cite{cebiric_compact_2018}.
\medskip
\bibliography{ref.bib}
\end{document}
test.log
...
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
Missing character: There is no � in font [lmroman10-regular]:mapping=tex-text;!
...
ref.bib
@article{cebiric_compact_2018,
title = {Compact {Summaries} of {Rich} {Heterogeneous} {Graphs}},
abstract = {Large data graphs with complex and heterogeneous structure, possibly featuring typed data and an ontology encoding the application-domain semantics, are widely used nowadays. The literature provides many solutions for building succinct representations of graphs, called summaries, in particular based on graph quotients through an equivalence relation between graph nodes.},
language = {en},
author = {Čebirić, Šejla and Goasdoué, François and Guzewicz, Pawel and Manolescu, Ioana},
year = {2018},
pages = {44},
}
test.pdf
PS: lmroman10
将不支持的 �
字符显示为空白,而 Times New Roman 显示为方框。若换用 Garamond 等支持字体,则 �
正常显示,和本问题并无直接关系。
note286 commented
参考 bibtex - "Invalid UTF-8 byte sequence" with Springer LNCS bst (splncs04) - TeX - LaTeX Stack Exchange 解决了,可以使用bibtexu
而不是bibtex
。
另外,是\bibliography{ref}
而不是\bibliography{ref.bib}
。
rami3l commented
@note286 感谢你提供的链接,但我这里还是没能解决这个问题。
在改动 \bibliography
后:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}
\begin{document}
This document is citing \cite{cebiric_compact_2018}.
\medskip
\bibliography{ref}
\end{document}
latexmkrc
$bibtex = 'bibtexu %O %S'
会给出 log
Initial Win CP for (console input, console output, system): (CP65001, CP65001, CP65001)
I changed them all to CP65001
Rc files read:
latexmkrc
Latexmk: This is Latexmk, John Collins, 18 Nov. 2022. Version 4.78, version: 4.78.
After making new aux file, require run of *latex.
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': Reasons for rerun
Category 'other':
Rerun of 'xelatex' forced or previously required
------------
Run number 1 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf --max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex"'
------------
This is XeTeX, Version 3.141592653-2.6-0.999994 (MiKTeX 23.1) (preloaded format=xelatex.fmt)
restricted \write18 enabled.
entering extended mode
(c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-02-07> (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.sty (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\xebabel.def)
*************************************
* Local config file bblopts.cfg used
*
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/babel-english\english.ldf)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel/locale/en\babel-english.tex) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/natbib\natbib.sty) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-xetex.def) (test.aux) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\ts1cmr.fd)
Package natbib Warning: Citation `cebiric_compact_2018' on page 1 undefined on input line 8.
No file test.bbl.
Package natbib Warning: There were undefined citations.
[1] (test.aux) )
Output written on test.xdv (1 page, 928 bytes).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
Latexmk: Missing bbl file 'test.bbl' in following:
No file test.bbl.
Latexmk: Getting log file 'test.log'
Latexmk: Examining 'test.fls'
Latexmk: Examining 'test.log'
Latexmk: Log file says output to 'test.xdv'
Latexmk: Found bibliography file(s):
./ref.bib
Latexmk: applying rule 'bibtex test'...
Rule 'bibtex test': Reasons for rerun
Category 'other':
Rerun of 'bibtex test' forced or previously required
------------
Run number 1 of rule 'bibtex test'
------------
------------
Running 'bibtexu "test.aux"'
------------
The top-level auxiliary file: test.aux
The style file: abbrvnat.bst
Database file #1: ref.bib
Warning--you've exceeded 100, the entry-string-size, for entry cebiric_compact_2018
while executing--line 1347 of file abbrvnat.bst
*Please notify the bibstyle designer*
Warning--empty journal in cebiric_compact_2018
(There were 2 warnings)
Latexmk: ====List of undefined refs and citations:
Citation `cebiric_compact_2018' on page 1 undefined on input line 8
Latexmk: If appropriate, the -f option can be used to get latexmk
to try to force complete processing.
Latexmk: Summary of warnings from last run of *latex:
Latex failed to resolve 1 citation(s)
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
bibtex test: Command for 'bibtex test' gave return code 256
将 `bibtexu` 改为 `bibtex` 后编译正常,得到 log
Initial Win CP for (console input, console output, system): (CP65001, CP65001, CP65001)
I changed them all to CP65001
Rc files read:
latexmkrc
Latexmk: This is Latexmk, John Collins, 18 Nov. 2022. Version 4.78, version: 4.78.
After making new aux file, require run of *latex.
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': Reasons for rerun
Category 'other':
Rerun of 'xelatex' forced or previously required
------------
Run number 1 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf --max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex"'
------------
This is XeTeX, Version 3.141592653-2.6-0.999994 (MiKTeX 23.1) (preloaded format=xelatex.fmt)
restricted \write18 enabled.
entering extended mode
(c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-02-07> (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.sty (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\xebabel.def)
*************************************
* Local config file bblopts.cfg used
*
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/babel-english\english.ldf)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel/locale/en\babel-english.tex) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/natbib\natbib.sty) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-xetex.def) (test.aux) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\ts1cmr.fd)
Package natbib Warning: Citation `cebiric_compact_2018' on page 1 undefined on input line 8.
No file test.bbl.
Package natbib Warning: There were undefined citations.
[1] (test.aux) )
Output written on test.xdv (1 page, 928 bytes).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
Latexmk: Missing bbl file 'test.bbl' in following:
No file test.bbl.
Latexmk: Getting log file 'test.log'
Latexmk: Examining 'test.fls'
Latexmk: Examining 'test.log'
Latexmk: Log file says output to 'test.xdv'
Latexmk: Found bibliography file(s):
./ref.bib
Latexmk: applying rule 'bibtex test'...
Rule 'bibtex test': Reasons for rerun
Category 'other':
Rerun of 'bibtex test' forced or previously required
------------
Run number 1 of rule 'bibtex test'
------------
------------
Running 'bibtex "test.aux"'
------------
This is BibTeX, Version 0.99d (MiKTeX 23.1)
The top-level auxiliary file: test.aux
The style file: abbrvnat.bst
Database file #1: ref.bib
Warning--empty journal in cebiric_compact_2018
(There was 1 warning)
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': Reasons for rerun
Changed files or newly in use/created:
test.aux
test.bbl
------------
Run number 2 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf --max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex"'
------------
This is XeTeX, Version 3.141592653-2.6-0.999994 (MiKTeX 23.1) (preloaded format=xelatex.fmt)
restricted \write18 enabled.
entering extended mode
(c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-02-07> (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.sty (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\xebabel.def)
*************************************
* Local config file bblopts.cfg used
*
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/babel-english\english.ldf)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel/locale/en\babel-english.tex) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/natbib\natbib.sty) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-xetex.def) (test.aux) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\ts1cmr.fd)
Package natbib Warning: Citation `cebiric_compact_2018' on page 1 undefined on input line 8.
(test.bbl
Missing character: There is no � in font [lmroman10-regular]:mapping=tex-text;!
)
Package natbib Warning: There were undefined citations.
[1] (test.aux
Package natbib Warning: Citation(s) may have changed.
(natbib) Rerun to get citations correct.
) )
(see the transcript file for additional information)
Output written on test.xdv (1 page, 2484 bytes).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
Latexmk: Getting log file 'test.log'
Latexmk: Examining 'test.fls'
Latexmk: Examining 'test.log'
Latexmk: Found input bbl file 'test.bbl'
Latexmk: References changed.
Latexmk: Log file says output to 'test.xdv'
Latexmk: Found bibliography file(s):
./ref.bib
Latexmk: applying rule 'bibtex test'...
Rule 'bibtex test': Reasons for rerun
Changed files or newly in use/created:
test.aux
------------
Run number 2 of rule 'bibtex test'
------------
------------
Running 'bibtex "test.aux"'
------------
This is BibTeX, Version 0.99d (MiKTeX 23.1)
The top-level auxiliary file: test.aux
The style file: abbrvnat.bst
Database file #1: ref.bib
Warning--empty journal in cebiric_compact_2018
(There was 1 warning)
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': Reasons for rerun
Changed files or newly in use/created:
test.aux
------------
Run number 3 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf --max-print-line=10000 -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex"'
------------
This is XeTeX, Version 3.141592653-2.6-0.999994 (MiKTeX 23.1) (preloaded format=xelatex.fmt)
restricted \write18 enabled.
entering extended mode
(c:/Users/user/Documents/Code/Personal/neonine-thesis/test.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-02-07> (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.sty (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel\xebabel.def)
*************************************
* Local config file bblopts.cfg used
*
(C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.cfg) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/babel-english\english.ldf)) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/generic/babel/locale/en\babel-english.tex) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/natbib\natbib.sty) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-xetex.def) (test.aux) (C:\Users\user\AppData\Local\Programs\MiKTeX\tex/latex/base\ts1cmr.fd) (test.bbl
Missing character: There is no � in font [lmroman10-regular]:mapping=tex-text;!
) [1] (test.aux) )
(see the transcript file for additional information)
Output written on test.xdv (1 page, 2288 bytes).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.
Latexmk: Getting log file 'test.log'
Latexmk: Examining 'test.fls'
Latexmk: Examining 'test.log'
Latexmk: Found input bbl file 'test.bbl'
Latexmk: Log file says output to 'test.xdv'
Latexmk: Found bibliography file(s):
./ref.bib
Latexmk: applying rule 'xdvipdfmx'...
Rule 'xdvipdfmx': Reasons for rerun
Changed files or newly in use/created:
test.xdv
Category 'changed_source_rules':
xelatex
------------
Run number 1 of rule 'xdvipdfmx'
------------
------------
Running 'xdvipdfmx -E -o "test.pdf" "test.xdv"'
------------
test.xdv -> test.pdf
[1]
8457 bytes written
Latexmk: ====List of undefined refs and citations:
Missing character: There is no � in font [lmroman10-regular]:mapping=tex-text;!) [1
Latexmk: Summary of warnings from last run of *latex:
=====Latex reported missing or unavailable character(s).
=====See log file for details.
Latexmk: All targets (test.pdf) are up-to-date
似乎和 bibtexu
的返回值有关。
更新:将 latexmkrc
内容替换为
$bibtex = 'bibtex %O %S > nul'
之后问题解决。不过该语法似乎仅限 Windows。
note286 commented
你直接四步编译即可。
pdflatex -synctex=-1 main
bibtexu main
pdflatex -synctex=-1 main
pdflatex -synctex=-1 main