Latex和bibtex文件的不同编码

发布于 2024-08-08 17:26:19 字数 1727 浏览 5 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

余生再见 2024-08-15 17:26:19

首先,根据 LyX wiki BibTeX 不能使用 UTF-8:

BibTeX 不支持 UTF-8(即 Unicode)编码的文件,这是目前大多数操作系统上的默认文件编码。原因是当前的 BibTeX(v.0.99c)于 1988 年发布,因此早于 unicode 的出现。除非早已宣布的 BibTeX v. 1.0 或许多计划的潜在成功应用程序之一已准备就绪,否则必须对 bib 文件使用 latin1 (ISO-8859-1) 或其他 8 位编码(这不会影响 LaTeX编码,仍然可以是utf8)。

通常,BibTeX 文件中的任何内容都会逐字复制到 LaTeX 源代码(可能会进行一些格式设置和大小写更改等),例如书名、作者等。

因此,您的 BibTeX 文件编码必须与您的 LaTeX 文件使用的编码相匹配,否则事情会变得很有趣。你也不能在 BibTeX 中使用 babel 提供的命令(例如 n?german 提供的 "a for ä),除非你的文档包含正确的包

。方法是通过始终使用适当的命令指定特殊字符来使 BibTeX 文件不知道任何编码或包问题。

这基本上意味着您必须使用 ä 而不是。 {\" a} 如果您想绝对确定它是否有效。似乎是相当标准的做法。

BibTeX 手册BibTeXing Oren Patashnik 也详细介绍了这一点:

BibTeX 现在可以处理重音符号
人物。例如,如果您有一个
包含两个字段的条目

author = "Kurt G{\"o}del",
年 = 1931 年,

如果你使用的是 alpha
参考书目风格,然后 BibTeX 将
为此构造标签 [Göd31]
条目,这就是您想要的。到
要使此功能正常工作,您必须
将整个重音字符放入
大括号;在这种情况下,{\"o}
{\"{o}} 就可以了。此外,这些
大括号本身不得包含在内
在大括号中(除了那些
可能会界定整个字段或
整个条目);并且必须有一个
反斜杠作为第一个字符
在大括号内。因此两者都不是
{G{\"{o}}del}{G\"{o}del} 都不会
为这个例子工作。此功能
处理所有重音字符
以及除非反斜杠外来的所有内容
符号见表 3.1 和 3.2
LaTeX 书。此功能的行为
类似地,对于“口音”,你可能会
定义;我们很快就会看到一个例子。
用于计算字母数
在标签中,BibTeX 考虑了一切
包含在大括号内作为
单个字母。

First of all, according to the LyX wiki BibTeX can't use UTF-8:

BibTeX does not support files encoded in UTF-8 (i.e., Unicode), which is nowadays the default file encoding on most OSes. The reason is that current BibTeX (v. 0.99c) was released in 1988 and thus predates the advent of unicode. Unless the long-announced BibTeX v. 1.0 or one of the many planned potential successing applications are ready, latin1 (ISO-8859-1) or another 8-bit encoding has to be used for the bib file (this does not affect the LaTeX encoding, which still can be utf8).

Usually, whatever is inside a BibTeX file gets copied verbatim to the LaTeX source code (with some formatting maybe and case changings, &c.), such as book titles, authors, &c.

So your BibTeX file encoding has to match the one used by your LaTeX file, otherwise things get funny. You also can't use babel-provided commands in BibTeX (such as "a for ä, provided by n?german) unless your document includes the right packages.

The canonical way is to make BibTeX files agnostic of any encoding or package issues by always specifying special characters with their appropriate commands.

This basically means that instead of writing ä you would have to use {\" a} if you want to be absolutely sure that it works. Seems to be fairly standard practice.

The BibTeX manual BibTeXing by Oren Patashnik also details this:

BibTeX now handles accented
characters. For example if you have an
entry with the two fields

author = "Kurt G{\"o}del",
year = 1931,

and if you're using the alpha
bibliography style, then BibTeX will
construct the label [Göd31] for this
entry, which is what you'd want. To
get this feature to work you must
place the entire accented character in
braces; in this case either {\"o} or
{\"{o}} will do. Furthermore these
braces must not themselves be enclosed
in braces (other than the ones that
might delimit the entire field or the
entire entry); and there must be a
backslash as the very first character
inside the braces. Thus neither
{G{\"{o}}del} nor {G\"{o}del} will
work for this example. This feature
handles all the accented characters
and all but the nonbackslashed foreign
symbols found in Tables 3.1 and 3.2 of
the LaTeX book. This feature behaves
similarly for "accents" you might
define; we'll see an example shortly.
For the purposes of counting letters
in labels, BibTeX considers everything
contained inside the braces as a
single letter.

相权↑美人 2024-08-15 17:26:19

您可以即时更改输入编码:

\inputencoding{latin2}
\bibliography{mybib}
\inputencoding{utf8}

\inputencoding 命令由 inputenc 包提供。

You can change the input encoding on the fly:

\inputencoding{latin2}
\bibliography{mybib}
\inputencoding{utf8}

The \inputencoding command is provided by the inputenc package.

寂寞笑我太脆弱 2024-08-15 17:26:19

即使在最新版本中,BibTeX 在处理非 ASCII 字符时也存在巨大问题。如果您更喜欢现代系统,我想推荐 biblatexbiber。两者仍处于测试阶段,但即使在生产环境中它们也能很好地工作。通过这种组合,大多数与 LaTeX 参考书目相关的问题都将消失。作为旁注,biblatex 文档 还包含有关传统 BibTeX 编码问题的部分(第 2.4.3 节)。

BibTeX has huge problems with non-ASCII characters, even in the newest version. If you prefer a modern system, I'd like to recommend the combination of biblatex and biber. Both are still in beta stage, but they work quite well even in production environments. With this combination, most problems related to LaTeX bibliographies will vanish. As a side note, the biblatex documentation also contains a section about encoding issues with traditional BibTeX (§ 2.4.3).

行雁书 2024-08-15 17:26:19

Bibtex 对任何非标准字符编码都有随机支持——本质上有时它可以工作,大多数时候它不能,并且官方不支持它(更多详细信息)。

就我个人而言,在 .bib 中,我坚持基本的 ASCII 和 LaTeX 魔法,如 \"o。对于 .tex,如果我不用英语编写,我会使用 \usepackage[utf8]{inputenc} 将 .tex 保留为 UTF-8 。

Bibtex has random support for any non-standard character encodings -- essentially sometimes it works, most of the time it doesn't and officially it is not supported (More details ).

Personally, in .bib, I stick to the basic ASCII and LaTeX magic like \"o. For .tex, if I don't write in English, I keep .tex in UTF-8 with \usepackage[utf8]{inputenc} .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文