如何在 UTF8中编译 LaTeX?

我的文档是按照 ISO 标准制作的。它不支持变音字母,例如 ä 和 ö。我需要他们。编译文档时不使用 UTF8,但不使用 UTF8。更准确地说,文档不是用 main.tex 开头的那行代码编译的:

\usepackage[utf8]{inputenc}

如何用 UTF8编译 LaTeX 文档?

163142 次浏览

Save your file in UTF8 format.

Verify the file format using the following (UNIX) command:

file -bi filename.tex

You should see:

text/x-tex; charset=utf-8

Convert the file using iconv if it is not UTF8:

iconv --from-code=ISO-8859-1 --to-code=UTF-8 filename.txt > filename-utf.txt

I'm not sure whether I got your problem but maybe it helps if you store the source using a UTF-8 encoding.

I'm also using \usepackage[utf8]{inputenc} in my LaTeX sources and by storing the files as UTF-8 files everything works just peachy.

Convert your document to utf8. LaTeX just reads your text as it is. If you want to use the utf8 input encoding, your document has to be encoded in utf8. This can usually be set by the editor. There is also the program iconv that is useful for converting files from iso encodings to utf.

In the end, you'll have to use an editor that is capable of supporting utf. (I have no idea about the status of utf support on windows, but any reasonable editor on linux should be fine).

\usepackage[utf8]{inputenc} will not work for a bibliographic entry such as this:

@ARTICLE{Hardy2007,
author = {Ibn Taymiyyah, Aḥmad ibn ʿAbd al{-}Halīm},
title = {Naqḍ al{-}manṭiq},
shorttitle = {Naqḍ al-manṭiq},
editor = {Ḥamzah, Aḥmad},
publisher = {Maktabat a{l-}Sunnah},
address = {Cairo},
year = {1970},
sortname = {IbnTaymiyyaNaqdalmantiq},
keywords = { Logic, Medieval}}

For this entry use \usepackage[utf8x]{inputenc}

You needed to iconv your source.

That said, the TEX-based compiler invoked by latex doesn't really support variable-length encodings; it needs big libraries that tell it that certain bytes go together. Xelatex is Unicode-aware and works much better.

I use LEd Editor with special "Filter" feature. It replaces \"{o} with ö and vice versa in its own editor, while maintaining original \"{o} in tex files. This makes text easily readable when viewed in LEd Editor and there is no need for special packages. It works with bibliography files too.

I have success with using the Chrome addon "Sharelatex". This online editor has great compability with most latex files, but it somewhat lacks configuration possibilities. www.sharelatex.com