官术网_书友最值得收藏!

  • LaTeX Cookbook
  • Stefan Kottwitz
  • 465字
  • 2021-07-09 21:25:00

Inputting accented characters

By default, LaTeX works with simple ASCII characters. For accented characters, such as in the German word "sch?n", you need to type sch\"on into your editor. The babel command with the ngerman option simplifies the syntax to sch"on. But there is an easier way.

How to do it...

We will activate extended input character support as follows:

  1. Check your editor's configuration and find out its input encoding setting. utf8 (UTF-8 means Unicode) is standard for Linux, Mac OS X, and some Windows editors. However, some Windows editors still work with latin1 or cp1250/cp1252, while some older Macs use applemac.
  2. Load the inputenc package with the corresponding option, like so:
    \usepackage[utf8]{inputenc}
  3. Now you can directly type characters such as a, ü, ?, é, and è in to your document.

Tip

If you need help with editor settings, you can post a question in the forum at http://latex-community.org/forum/. This web site provides support forums for various LaTeX editors.

How it works...

The inputenc package enables direct entering of accented characters and symbols from code tables other than ASCII, and of Unicode. Modern editors and operating systems support UTF-8, so utf8 should be preferably set in the editor.

Note

There's an utf8x encoding, but beware: this is not an extension, but a different approach, useful for some Asian languages.

Be careful: the inputenc encoding option, the editor setting, and the actual file encoding of the operating system all need to match.

There's more...

If you would like to change the existing encoding, such as for files produced on a different system, you could open such a file in your editor with the actual encoding and save it with the new encoding. You may also use a conversion program such as one of these:

There's also a clever way of automatically selecting the needed encoding by using the selinput package as follows:

  1. Load the selinput package:
    \usepackage{selinput}
  2. Specify some meanings of characters via this command; for example, as follows:
    \SelectInputMappings{
      adieresis={?},
      eacute={é},
      germandbls={?}}
  3. In your document text, you can now type ?, é, or ?, and they will be printed correctly.

Here, we provide samples of required characters with their meanings, and the selinput package determines the matching encoding. A few chosen glyphs may already suffice. If you would like to specify more, you can find their names in the selinput manual. It can be opened by typing the texdoc selinput command in Command Prompt, or accessed online at http://texdoc.net/pkg/selinput.

In addition to not needing to deal with encodings, you can also easily change the editor or operating system. You can exchange your files with friends who may use a different encoding without changing any setting.

主站蜘蛛池模板: 金昌市| 宝丰县| 宁晋县| 盘山县| 布拖县| 南京市| 罗城| 进贤县| 大埔区| 巩义市| 疏勒县| 东阿县| 武定县| 蒙城县| 永顺县| 桃园市| 二连浩特市| 固始县| 宣威市| 奉节县| 永顺县| 商城县| 长垣县| 青阳县| 长海县| 如皋市| 苏州市| 邢台市| 麦盖提县| 高邮市| 宝应县| 青铜峡市| 陇南市| 剑川县| 那坡县| 鱼台县| 淮安市| 隆子县| 宣恩县| 辽阳县| 黄陵县|