星期三, 一月 09, 2013

LaTeX/Special Characters



LaTeX logo.svg
In this chapter we will tackles everything related to input encoding, typesetting diacritics and special characters.
In the following document, we will refer to special characters for all symbols other than A-Za-z0-9 and english punctuation marks.
This chapter is tightly linked with the font encoding issue. You should have a look at Fonts on the topic.
Some languages usually need a dedicated input system to ease document writing. This is the case of Arab, Chinese, Japanese, Korean and others. This specific matter will be tackled in Internationalization.
The rules for producing characters with diacritical marks, such as accents, differ somewhat depending whether you are in text mode, math mode, or the tabbing environment.

Contents

  [hide] 

[edit]Input encoding

[edit]A technical matter

Most of the modern computer systems allow you to input letters of national alphabets directly from the keyboard. If you tried to input these special characters in your LaTeX source file and compiled it, you may have noticed that they do not get printed at all.
A LaTeX source document is a plain text file. A computer stores data in a binary format, that is a sequence of bits (0 and 1). To display a plain text file, we need a code which tells which sequence of bits corresponds to which sequence of characters. This association is called input encoding, character encoding, or more informally charset.
For historical reasons, there are many different input encodings. There is an attempt to unify all the encoding with a specification that contains all existent symbols that are known from human history. This specification is Unicode. It only defines code points, which is a number for a symbol, but not the way symbols are reprensented in binary value. For that, unicode encodings are in charge. There is also several unicode encodings available, UTF-8 being one of them.
The ASCII encoding is an encoding which defines 128 characters on 7 bits. Its widespread use has lead the vast majority of encodings to have backward compatibility with ASCII, by defining the first 128 characters the same way. The other characters are added using more bits (8 or more).
This is actually a big issue, since if you do not use the right encoding to display a file, it will show weird characters. What most programs try to do is guess statistically the encoding by analyzing the frequent sequences of bits. Sadly, it is not 100% safe. Some text editors may not bother guessing the encoding and will just use the OS default encoding. You should consider that other people might not be able to display directly your input files on their computer, because the default encoding for text file is different. It does not mean that the user cannot use another encoding, besides the default one, only that it has to be configured. For example, the German umlaut ä on OS/2 is encoded as 132, with Latin1 it is encoded as 228, while in Cyrillic encoding cp1251 this letter does not exist at all. Therefore you should consider encoding with care.
The following table shows the default encodings for some operating systems.
Operating systemDefault Encodings
Western LatinCyrillic
Modern Unices (*BSD, Mac OS X, GNU/Linux)utf-8utf-8
Mac (before OS X)applemacmaccyr
Unix (Old)latin1koi8-ru
Windowsansinew, cp1252cp1251
DOS, OS/2cp850cp866nav
UTF-8 and Latin1 are not compatible. It means that if you try to open a Latin1-encoded file using a UTF-8 decoding, it will display odd symbols only if you used accents in it, since both encoding are ASCII superset they encode the classic letters the same way. There aren't many advantages in using Latin1 over UTF-8, which is technically superior. UTF-8 is also becoming the most widely used encoding (on the Web, in modern Unices, etc.).

[edit]Dealing with LaTeX

TeX uses ASCII by default. But 128 characters is not enough to support non-english languages. TeX has its own way to do that with commands for every diacritical marking (see Escaped codes). But if we want accents and other special characters to appear directly in the source file, we have to tell TeX that we want to use a different encoding.
There are several encodings available to LaTeX:
  • ASCII: the default. Only bare english characters are supported in the source file.
  • ISO-8859-1 (a.k.a. Latin 1): 8-bits encoding. It supports most characters for latin languages, but that's it.
  • UTF-8: a Unicode multi-byte encoding. Supports the complete Unicode specification.
  • Others...
In the following we will assume you want to use UTF-8.
There are some important steps to specify encoding.
  • Make sure your text editor decodes the file in UTF-8.
  • Make sure it save your file in UTF-8. Most text editors do not make the distinction, but some do, such as Notepad++.
  • If you are working in a terminal, make sure it is set to support UTF-8 input and output. Some old Unix terminals may not support UTF-8. PuTTY is not set to use UTF-8 by default, you have to configure it.
  • Tell LaTeX that the source file is UTF-8 encoded.
\usepackage[utf8]{inputenc}
inputenc package tells LaTeX what the text encoding format of your .tex files is.

[edit]Extending the support

The LaTeX support of UTF-8 is fairly specific: it includes only a limited range of unicode input characters. It only defines those symbols that are known to be available with the current font encoding. You might encounter a situation where using UTF-8 might result in error:
! Package inputenc Error: Unicode char \u8:ũ not set up for use with LaTeX.
This is due to the utf8 definition not necessarily having a mapping of all the character glyphs you are able to enter on your keyboard. Such characters are for example
ŷ Ŷ ũ Ũ ẽ Ẽ ĩ Ĩ
In such case, you may try need to use the utf8x option to define more character combinations. utf8x is not officially supported, but can be viable in some cases. However it might break up compatibility with some packages like csquotes.
Another possiblity is to stick with utf8 and to define the characters yourself. It is very easy indeed:
\DeclareUnicodeCharacter{'codepoint'}{'TeX sequence'}
where codepoint is the unicode codepoint of the desired character. TeX sequence is what to print when the character matching the codepoint is met. You may find codepoints on this site. Codepoints are easy to find on the web. Example:
\DeclareUnicodeCharacter{0177}{\^y}
Now inputting 'ŷ' will effectively print 'ŷ'.
With XeTeX and LuaTeX the inputenc package is no longer needed. Both engines support UTF-8 directly and allow the use of TTF and OpenType fonts to support Unicode characters. See the Fonts section for more information.

[edit]Escaped codes

In addition to direct UTF-8 input, LaTeX supports the composition of special characters. This is convenient if your keyboard lacks some desired accents and other diacritics.
The following accents may be placed on letters. Although 'o' letter is used in most of the examples, the accents may be placed on any letter. Accents may even be placed above a "missing" letter; for example, \~{} produces a tilde over a blank space.
The following commands may be used only in paragraph (default) or LR (left-right) mode.
LaTeX commandSampleDescription
\`{o}ògrave accent
\'{o}óacute accent
\^{o}ôcircumflex
\"{o}öumlaut, trema or dieresis
\H{o}őlong Hungarian umlaut (double acute)
\~{o}õtilde
\c{c}çcedilla
\k{a}ąogonek
\lłl with stroke
\={o}ōmacron accent (a bar over the letter)
\b{o}obar under the letter
\.{o}ȯdot over the letter
\d{u}ụdot under the letter
\r{a}åring over the letter (for å there is also the special command \aa)
\u{o}ŏbreve over the letter
\v{s}šcaron/hacek ("v") over the letter
\t{oo}o͡o"tie" (inverted u) over the two letters
To place a diacritic on top of an i or a j, its dot has to be removed. The dotless version of these letters is accomplished by typing \iand \j. For example:
  • \^\i should be used for i circumflex 'î';
  • \"\i should be used for i umlaut 'ï'.
If a document is to be written completely in a language that requires particular diacritics several times, then using the right configuration allows those characters to be written directly in the document. For example, to achieve easier coding of umlauts, the babel package can be configured as \usepackage[ngerman]{babel}. This provides the short hand "o for \"o. This is very useful if one needs to use some text accents in a label, since no backslash will be accepted otherwise.
More information regarding language configuration can be found in the Internationalization section.

[edit]Less than < and greater than >

The two symbols '<' and '>' are actually ASCII characters, but you may have noticed that they will print '¡' and '¿' respectively. This is a font encoding issue. If you want them to print their real symbol, you will have to use another font encoding such as T1, loaded with the inputenc package. See Fonts for more details on font encoding.
Alternatively, they can be printed with dedicated commands:
\textless
\textgreater

[edit]Euro € currency symbol

When writing about money these days, you need the euro sign. The textcomp package features a \texteuro command which is quite far from the official symbol. An official version of the euro symbol is provided by eurosym. Load it in the preamble (optionnaly with the officialoption):
\usepackage[official]{eurosym}
then you can insert it with the \euro{} command. Finally, if you want a euro symbol that matches with the current font style (e.g., bold, italics, etc.) you can use a different option:
\usepackage[gen]{eurosym}
again you can insert the euro symbol with \euro{}.
Alternatively you can use the marvosym package which also provides the official euro symbol.
\usepackage{marvosym}
% ...

\EUR{}
Now that you have succeeded in printing a euro sign, you may want the '€' on your keyboard to actually print the euro sign as above. There is a simple method to do that. You must make sure you are using UTF-8 encoding along with a working \euro{} or \EUR{}command.
\DeclareUnicodeCharacter{20AC}{\euro{}}
% or
\DeclareUnicodeCharacter{20AC}{\EUR{}}
Complete example:
\usepackage[utf8]{inputenc}
\usepackage{marvosym}
\DeclareUnicodeCharacter{20AC}{\EUR{}
}

[edit]Degree symbol for temperature and math

A common mistake is to use the \circ command. It will not print the correct character. Use the textcomp package instead, which provides a\textdegree command.
\usepackage{textcomp}
%...

A $45\textdegree$ angle.
For temperature, you can use the same command or opt for the gensymb package and write
\usepackage{gensymb}
%...

17\degree~C
or
17\celsius
Some keyboard layouts feature the degree symbol, you can use it directly by declaring the unicode character:
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\DeclareUnicodeCharacter{00B0}{\textdegree{}
}

% ...

17°~C

[edit]Other symbols

LaTeX has lots of symbols at its disposal. The majority of them are within the mathematical domain, and later chapters will cover how to get access to them. For the more common text symbols, use the following commands:
Symbols.png
Not mentioned in above table, tilde (~) is used in LaTeX code to produce non-breakable space. To get printed tilde sign, either write\~{} or \textasciitilde{}. And a visible space ␣ can be created with \textvisiblespace.
For some more interesting symbols, the Postscript ZipfDingbats font is available thanks to the pifont package. Add the declaration to your preamble: \usepackage{pifont}. Next, the command \ding{number}, will print the specified symbol. Here is a table of the available symbols:
ZapfDingbats symbols.

[edit]In special environments

[edit]Math mode

Several of the above and some similar accents can also be produced in math mode. The following commands may be used only in math mode.
LaTeX commandSampleDescriptionText-mode equivalence
\hat{o}\hat{o}circumflex\^
\widehat{oo}\widehat{oo}wide version of \hat over several letters
\check{o}\check{o}vee or check\v
\tilde{o}\tilde{o}tilde\~
\widetilde{oo}\widetilde{oo}wide version of \tilde over several letters
\acute{o}\acute{o}acute accent\'
\grave{o}\grave{o}grave accent\`
\dot{o}\dot{o}dot over the letter\.
\ddot{o}\ddot{o}two dots over the letter (umlaut in text-mode)\"
\breve{o}\breve{o}breve\u
\bar{o}\bar{o}macron\=
\vec{o}\vec{o}vector (arrow) over the letter
When applying accents to letters i and j, you can use \imath and \jmath to keep the dots from interfering with the accents:
LaTeX commandSampleDescriptionSample with upper dot
\hat{\imath}\hat{\imath}circumflex on letter i without upper dot\hat{i}
\vec{\jmath}\vec{\jmath}vector (arrow) on letter j without upper dot\vec{j}

[edit]Tabbing environment

Some of the accent marks used in running text have other uses in the tabbing environment. In that case they can be created with the following command:
  • \a' for an acute accent
  • \a` for a grave accent
  • \a= for a macron accent

[edit]Unicode keyboard input

Some operating systems provide a keyboard combination to input any Unicode code point, the so-called unicode compose key.
Many X applications (*BSD and GNU/Linux) support the Ctrl+Shift+u combination. A 'u' symbol should appear. Type the code point and pressenter or space to actually print the character. Example:
 20AC 
will print the euro character.
Desktop environments like GNOME and KDE may feature a customizable compose key for more memorizable sequences.
Xorg features advanced keyboard layouts with variants that let you enter a lot of characters easily with combination using the aprioriate modifier, like Alt Gr. It highly depends on the selected layout+variant, so we suggest you to play a bit with your keyboard, preceeding every key and dead key with the Alt Gr modifier.

星期一, 九月 24, 2012

常见拉丁文缩写大全:cf., e.g., i.e.都是啥意思


缩写1:A.D.
拉丁文:anno Domini
释义:in the year of the Lord 耶稣纪年,公元
例句:The United States Civil War began in AD 1861.
缩写2:a.m.
拉丁文:Ante Meridiem
释义:before middday 上午,午前
例句:We will meet the mayor at 10 a.m.
缩写3:c., ca.
拉丁文:circa
释义:around, about, approximately 大约
用法:用于日期中表示大概的数。
例句:The antique clock is from c.1900.
缩写4:Cap
拉丁文:capitulus
释义:chapter 章节
用法:用于英国及其前殖民地的法律章节前。
例句:Electronic Transactions Ordinance (Cap. 553).
缩写5:cf.
拉丁文:confer
释义:"bring together" and hence "compare" 试比较
用法:提示读者比较所引用资料中的说法与文中的论述,与cp.可替换使用。
例句:These results were similar to those obtained using different techniques (cf. Wilson, 1999 and Ansmann, 1992).
缩写6:cp.
释义:compare 比较
例句:These results were similar to those obtained using different techniques (cp. Wilson, 1999 and Ansmann, 1992).
缩写7:C.V.
拉丁文:curriculum vitae
释义:course of life 简历
缩写8:etc.
拉丁文:et cetera
释义:and the others, and other things, and the rest 等等
例句:I need to go to the store and buy some pie, milk, cheese, etc.
缩写9:e.g.
拉丁文:exempli gratia
释义:for example, for instance 比如
例句:The shipping company instituted a surcharge on any items weighing over a ton; e.g., a car or truck.
缩写10:ff.
拉丁文:folio
释义:and following 以及接下去的
例句:see page 258ff.(参见第258页以及接下去的若干页)
缩写11:id.
拉丁文:idem
释义:the same (man) 同上
用法:用来避免(在引用、脚注、书目等处)重复某个男性作者的名字。如果是女性作者,用ead. (eadem)。
缩写12:i.a.
拉丁文:inter alia
释义:among other things 除了别的因素以外,特别
例句:Ernest Hemingway—author (i.a. 'The Sun Also Rises') and friend.
缩写13:i.e.
拉丁文:id est
释义:that is, in other words 即是
例句:For reasons not fully understood there is only a minor PSI contribution to the variable fluorescence emission of chloroplasts (Dau, 1994), i.e., the PSI fluorescence appears to be independent from the state of its reaction centre (Butler, 1978).
缩写14:lb.
拉丁文:libra
释义:scales 磅
缩写15:LL.B.
拉丁文:Legum Baccalaureus
释义:bachelor of laws 法学士
缩写16:M.A.
拉丁文:Magister Artium
释义:Master of Arts 文科硕士
缩写17:N.B.
拉丁文:nota bene
释义:note well 注意,留心
例句:N.B.: All the measurements have an accuracy of withi 5% as they were calibratedaccording to the procedure described by Jackson (1989).
缩写18:op.cit.
拉丁文:opere citato
释义:the work cited 在前面所引用的书中
用法:通常用于参考文献中,同ibid相似,但是ibid通常会跟着页码。

星期四, 九月 20, 2012

安裝XAMPP所遇到的問題


快速的方法:

直接下載windwos的元件:Virtual C++ 2008 Redistributable packages 安裝,即可正常啟動!!

※更新日期:20120918(用下面方式沒辦法成功,最後找到此方法,超快速解決!!)

---------------------------------------------------------------------

慢速的方法:

【步驟一】

上網下載XAMPP軟體(請直接下載『自動安裝程式』版)

※XAMPP有很多種版本,如:Linux、Windows、Mac OS X..版本。


【步驟二】

下載後直接執行[xampp-win32-1.7.7-VC9-installer.exe],(正常的話)即可安裝完成。

※林伯就是安裝中途出現問題,跳出『Ports 80 or 443 (SSL) already in use! Installing Apache2.2 service failed』錯誤訊息視窗,導致Apache Server無法啟動。







以下是找出原因並解決問題的方法:

  1. [開始] → [命令提示元] → 輸入指令 netstat -oan,會列出所有的Ports的情況,並找尋被佔用的 80 和 443 Port。[圖1]
  2. 根據上述找到 443 Port,並對應到PID為4040。 [圖2]
  3. 開啟 [Windows工作管理員] → [檢視] → [選擇欄位] → 勾選[PID(程序識別元)],並按下『確定』鈕 → 選擇[處理程序]頁籤,找尋PID為4040,且查詢是哪個程式(vmware-hostd.exe)目前在使用443 Port。 [圖3]
  4. 點選[VMware Workstation] → [Edit] → [Preferences] → 選擇[Shared VMs],即可看見443 Port目前使用在VMware Workstation Server之HTTPS。 [圖4]
  5. 將預設的HTTPS:443改為隨便數字(但不能與系統中的Port重複)。 [圖5]
  6. 移除先前安裝的xampp,再重新安裝過一次。
  7. 重新開機後,出現成功的畫面。 [圖6]





[圖1]







[圖2]
















[圖3]









[圖4]









[圖5]














[圖6]





【步驟三】
開啟[XAMPP Control Panel],檢查是否正常啟動(Running)Apache和MySql,如有正常啟動,即安裝成功。[圖6]

星期日, 五月 20, 2012

世界上最负盛名的画





2. Madonna Litta by Leonardo da Vinci





3. Sistine Madonna by Sanzio Raphael





4. The Last Supper by Leonardo da Vinci





5. Creation of Adam by Michelangelo





6. Birth of Venus by Sandro Botticelli





7. Liberty Leading the People by Delacroix





8. Arnolfini Marriage by Jan van Eyck





9. The Ballet Dancer by Edgar Degas





10. Black Square by Kasimir Malevich





11. The Japanese Bridge by Monet





12. The Persistence of Memory by Salvadore Dali





13. Flight of a Bee by Salvadore Dali





14. Sunflowers by Vincent van Gogh





15. Vitruvian Man by Leonardo da Vinci





16. Death Of Marat by Jacques-Louis David





17. Ship of Fools by Hieronymus Bosch





18. Tower of Babel by Pieter Brueghel the Elder



19. Icon of the Trinity by Andrei Rublev





20. Union of Earth and Water by Peter Paul Rubens





21. View of Toledo bu El Greco





22. Moulin de la Galette by Auguste Renoir





23. Venus of Urbino by Titian





24. Return of the Prodigal Son by Rembrandt





25. Crucifixion by Salvador Dali





26. The Kiss by Gustav Klimt





27. Haywain Hieronymus Bosch





28. Penitent Mary Magdalen by Titian





29. Massacre of the Innocents by Brueghel





30. Sacrifice of Isaac by Caravaggio





31. American Gothic by Grant Wood





32. The Starry Night by Vincent van Gogh





33. Olympia by Monet





34. School of Athens by Raphael





35. Triumph of Galatea by Raphael





36. Noli Me Tangere by Fra Angelico





37. Composition VIII by Kadinsky





38. Reclining Nude by Modigliani





39. Colossus by Goya





40. The Third of May by Goya





41. Tahitian Women by Paul Gauguin





42. The Nude Maja by Goya





43. Les Demoiselles d39;Avignon by Pablo Picasso





44. The Promenade by Marc Chagall





45. Bacchus and Ariadne by Titian





46. Guernica by Picasso





47. Girl with a Pearl Earring by Jan Vermeer





48. The Great Wave by Hokusai





49. Don Quixote by Pablo Picasso





50. The Old Guitarist by Picasso





51. The Son of Man by Rene Magritte





52. The Joy of Life by Henri Matisse





53. Carnival of Harlequins by Joan Miro





54. Marilyn Monroe by Andy Warhol





55. The Virgin of Chancellor Rolin by van Eyck





56. Burial of St. Lucy by Caravaggio





57. The Scream by Edvard Munch





58. The Ninth Wave by by Ivan Aivazovsky





59. The Broken Column by Frida Kahlo





60. Virgin of the Lilies by William Bouguereau





61. The Crucifixion of St. Peter by Caravaggio





62. Portrait of Henry VIII by Holbein





63. Danae by Rembrant





64. Autumn Rhythm by Jackson Pollock