LaTeX在处理输入文档(input file)时,首先需要的信息就是文档类型,由\documentclass这个指令来定义:


这里,"class(种类)"指定了将要被创建的文档的类型. LaTeX 也为其他种类的文件提供了额外的类型设置, 包括信件(letters)和幻灯片(slides). 选项参数(英文为options parameter, 指的应该是花括号里的内容)定义了\documentclass这个指令的行为.选项参数之间必须有逗号(comma)隔开.



上述指令告訴 Latex 在本文檔長寬 A4 紙張相同,文字採双边編排(即奇偶页左右边距正好相反),基本字體大小是 11pt。


article 科学期刊文章、演示、短小的报告、程序文档、邀请函等文档
IEEEtran for articles with the IEEE Transactions format.
proc a class for proceedings based on the article class.
minimal is as small as it can get. It only sets a page size and a base font. It is mainly used for debugging purposes.
report for longer reports containing several chapters, small books, thesis, ...
book 實體書籍寫作
slides for slides. The class uses big sans serif letters.
memoir for changing sensibly the output of the document. It is based on the book class, but you can create any kind of document with it [1]
letter 信件寫作
beamer for writing presentations (see LaTeX/Presentations).

The most common options for the standard document classes are listed in the following table:

Document Class Options
10pt, 11pt, 12pt 設定該文件主字體的大小,如果沒有設置的話會以10pt作為預設值。
a4paper, letterpaper,... Defines the paper size. The default size is letterpaper; However, many European distributions of TeX now come pre-set for A4, not Letter, and this is also true of all distributions of pdfLaTeX. Besides that, a5paper, b5paper, executivepaper, and legalpaper can be specified.
fleqn Typesets displayed formulas left-aligned instead of centered.
leqno Places the numbering of formulae on the left hand side instead of the right.
titlepage, notitlepage Specifies whether a new page should be started after the document title or not. The article class does not start a new page by default, while report and book do.
onecolumn, twocolumn 指示LaTeX此文件要以單列(onecolumne)或双列(twocolumn)進行排版
twoside, oneside Specifies whether double or single sided output should be generated. The classes article and report are single sided and the book class is double sided by default. Note that this option concerns the style of the document only. The option twoside does not tell the printer you use that it should actually make a two-sided printout.
landscape Changes the layout of the document to print in landscape mode.
openright, openany Makes chapters begin either only on right hand pages or on the next page available. This does not work with the article class, as it does not know about chapters. The report class by default starts chapters on the next page available and the book class starts them on right hand pages.
draft makes LaTeX indicate hyphenation and justification problems with a small square in the right-hand margin of the problem line so they can be located quickly by a human. It also suppresses the inclusion of images and shows only a frame where they would normally occur.

For example, if you want a report to be in 12pt type on A4, but printed one-sided in draft mode, you would use:



While writing your document, you will probably find that there are some areas where basic LaTeX cannot solve your problem. If you want to include graphics, colored text or source code from a file into your document, you need to enhance the capabilities of LaTeX. Such enhancements are called packages. Packages are activated with the


command, where package is the name of the package and options is a list of keywords that trigger special features in the package. Some packages come with the LaTeX base distribution. Others are provided separately.

Modern TeX distributions come with a large number of packages pre-installed. If you are working on a Unix system, use the command texdoc for accessing package documentation. For more information, see the Packages section.



.aux A file that transports information from one compiler run to the next. Among other things, the .aux file is used to store information associated with cross-references.
.bbl BiBTeX產生供LaTeX使用的參考書目檔
.bib 參考書目資料庫檔案
.blg BiBTeX紀錄檔
.bst BiBTeX樣式檔
.cls 定義文件外觀的類別檔,藉由\documentclass指令來進行選擇
.dtx Documented TeX. This is the main distribution format for LaTeX style files. If you process a .dtx file you get documented macro code of the LaTeX package contained in the .dtx file.
.ins The installer for the files contained in the matching .dtx file. If you download a LaTeX package from the net, you will normally get a .dtx and a .ins file. Run LaTeX on the .ins file to unpack the .dtx file.
.fd 告訴LaTeX新字體資訊的描述檔
.dvi (Device Independent File. This is the main result of a LaTeX compile run with latex. You can look at its content with a DVI previewer program or you can send it to a printer with dvips or a similar application.
.pdf Portable Document Format. This is the main result of a LaTeX compile run with pdflatex. You can look at its content or print it with any PDF viewer.
.log Gives a detailed account of what happened during the last compiler run.
.toc Stores all your section headers. It gets read in for the next compiler run and is used to produce the table of contents.
.lof This is like .toc but for the list of figures.
.lot And again the same for the list of tables.
.idx If your document contains an index. LaTeX stores all the words that go into the index in this file. Process this file with makeindex.
.ind The processed .idx file, ready for inclusion into your document on the next compile cycle.
.ilg Logfile telling what makeindex did.
.sty LaTeX Macro package. This is a file you can load into your LaTeX document using the \usepackage command.
.tex LaTeX or TeX input file. It can be compiled with latex.





\input會插入另外一個檔案的內容,叫做filename.tex;注意.tex副檔名是被省略的。 For all practical purposes, \input is no more than a simple, automated cut-and-paste of the source code in filename.tex.

The other main inclusion command is \include:


The \include command is different from \input in that it's the output that is added instead of the commands from the other files. Therefore a new page will be created at every \include command, which makes it appropriate to use it for large entities such as book chapters.

Very large documents (that usually include many files) take a very long time to compile, and most users find it convenient to test their last changes by including only the files they have been working on. One option is to hunt down all \include commands in the inclusion hierarchy and to comment them out:

%\include{filename1} \include{filename2} \include{filename3} %\include{filename4}

In this case, the user wants to include only filename2.tex and filename3.tex. If the inclusion hierarchy is intricate, commenting can become error-prone: page numbering will change, and any cross references won't work. A better alternative is to retain the include calls and use the \includeonly command in the preamble:


This way, only \include commands for the specified files will be executed, and inclusion will be handled in only one place. Note that there must be no spaces between the filenames and the commas.

Remember that the input file should omit all the commands referring to the main document structure, which should be kept in the original document file. This includes lines containing usepackages, document class, and everything but the code strictly referring to the section that is to be included. In this way you'll avoid finding characters of your code in the output document, or worse, not finding anything after the included file, in case you forget to erase the


line of your included file.


Never, ever use directories (folders) or file names that contain spaces. Although your operating system probably supports them, some don't, and they will only cause grief and tears with TeX. Make filenames as short or as long as you wish, but strictly avoid spaces. Stick to lower-case letters without accents (a-z), the digits 0-9, the hyphen (-), and the full point or period (.), (similar to the conventions for a Web URL): it will let you refer to TeX files over the Web more easily and make your files more portable. Some operating systems do not distinguish between upper-case and lower-case letters, others do. Therefore it's best not to mix them.


See chapter LaTeX/Collaborative Writing of LaTeX Documents/.

Previous: Absolute Beginners Index Next: Document Structure