- 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:
- 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 withlatin1
orcp1250/cp1252
, while some older Macs useapplemac
. - Load the
inputenc
package with the corresponding option, like so:\usepackage[utf8]{inputenc}
- 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.
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:
recode
: See http://latex-community.org/tools/recodeiconv
: See http://latex-community.org/tools/iconv
There's also a clever way of automatically selecting the needed encoding by using the selinput
package as follows:
- Load the
selinput
package:\usepackage{selinput}
- Specify some meanings of characters via this command; for example, as follows:
\SelectInputMappings{ adieresis={?}, eacute={é}, germandbls={?}}
- 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.
- Mastering OpenLayers 3
- C語(yǔ)言程序設(shè)計(jì)(第3版)
- Oracle從新手到高手
- 64位匯編語(yǔ)言的編程藝術(shù)
- 人人都懂設(shè)計(jì)模式:從生活中領(lǐng)悟設(shè)計(jì)模式(Python實(shí)現(xiàn))
- Spring Boot Cookbook
- Instant Lucene.NET
- AutoCAD 2009實(shí)訓(xùn)指導(dǎo)
- Android傳感器開發(fā)與智能設(shè)備案例實(shí)戰(zhàn)
- Scala編程實(shí)戰(zhàn)
- WCF技術(shù)剖析(卷1)
- 實(shí)戰(zhàn)Python網(wǎng)絡(luò)爬蟲
- Oracle Database XE 11gR2 Jump Start Guide
- Learning TypeScript
- 面向?qū)ο蠓治雠c設(shè)計(jì)(第3版)