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

查看:109
本文介绍了乳胶和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源代码(可能会进行某些格式设置和大小写更改),例如书名,作者和& c.

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提供的命令(例如n?german提供的ä"a).

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.

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

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