latex 和 bibtex 文件的不同编码 [英] Different encoding of latex and bibtex files

查看:11
本文介绍了latex 和 bibtex 文件的不同编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 .bib 文件的编码与 .tex 文件不同时,LaTeX 会处理这种情况吗?例如,.tex 在 ISO-8859-2 中,.bib 在 UTF-8 中.可以通过 LaTeX 即时转换编码吗?还是只能手动操作?

Does LaTeX handle situation when a .bib file has different encoding than .tex file? For instance, .tex is in ISO-8859-2 and .bib in UTF-8. Can the encoding be converted on the fly by LaTeX? Or the only way is to do is manually?

推荐答案

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

First of all, according to the LyX wiki BibTeX can't use 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 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).

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

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.

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

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.

规范的方法是通过总是使用适当的命令指定特殊字符,使 BibTeX 文件不受任何编码或包问题的影响.

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

这基本上意味着,如果您想绝对确定它是否有效,则必须使用 {" a} 而不是编写 ä.似乎是公平的标准做法.

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.

BibTeX 手册 BibTeXing Oren Patashnik 也详细说明了这一点:

The BibTeX manual BibTeXing by Oren Patashnik also details this:

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

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

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

如果您使用的是 alpha参考书目风格,然后 BibTeX 将为此构造标签 [Göd31]条目,这是您想要的.到让这个功能工作你必须将整个重音字符放在大括号;在这种情况下 {"o}{"{o}} 会做.此外,这些大括号本身不得包含在内在大括号中(除了那些可能会分隔整个字段或整个条目);并且必须有一个反斜杠作为第一个字符大括号里面.因此既不{G{"{o}}del}{G"{o}del} 将为这个例子工作.此功能处理所有重音字符除了非反斜杠外的所有东西表 3.1 和 3.2 中的符号乳胶书.此功能的行为同样对于口音",您可能定义;我们很快就会看到一个例子.为了计算信件在标签中,BibTeX 考虑了一切包含在大括号内作为单个字母.

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.

这篇关于latex 和 bibtex 文件的不同编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆