latex learning grammar (a) basic knowledge

installation

  • Texlive 2019
  • TeX studio
  • Please install their own Baidu Tutorial

Blank distance

  • Tex source in the blank distance, no matter how cosmopolitan character is equivalent to a blank, white space characters per line will begin ignored, and a single carriage return is treated as a single space.
  • Blank line paragraph, the same function and a plurality of blank lines blank line effect.

Special characters

The following characters are reserved characters LATEX, they have a specific use in latex, as these characters want, need to add a backslash \

#
$
%
^
{
}
_
\
~
  • Note: backslash is not preceded by a backslash is obtained, contrary \\ broken line is a command used.

latex command

Case-sensitive , and there are two formats:

  • With a backslash \ start, plus the command name contains only alphabetic characters composed. After the command name spaces, ending numbers or other non-alphabetic characters in the standard order.
  • By a backslash and a special character.

If you want to get a space after the command, you can add {} after the command and blank distance you need command , {} will prevent latex devour the space after the command.

  • \ Textsl {} italic
  • \ Today today date output
  • \ Newline newline

Note

Single-line comment sign :%

If a longer comments, comment used verbatim environment provided by the set of macros, the need to add command \ usepachage in the preamble of the source file {verbatim}

\usepachage{verbatim}

\begin{comment}
	This is comment
\end{comment}

Source file structure

Latex source files need to be addressed to comply with certain structure, each latex document must start with the following command

\documentclass{...}

This command specifies the categories you wrote the document.

After that, you can add Document Control type command, or use the following command to call in some of the set of macros, and then add new functionality to the latex system

\usepackage{...}

This region is called the preamble block. (Between documentclass and begin)

When all settings are completed, you can start your document using the following commands.

\begin{document}

Begin publishing text, and use some latex command. In the final document, type the following command to tell your latex document to this end.

\end{document}

Document Class

\documentclass[options]{class}
  • The document's properties by adjusting the options, different options separated by commas
  • By adjusting the type of document class

class options

class significance
article Publishing scientific journals, short reports, program documentation, invitations and so on.
report Long multi-section report layout, short books, and other doctoral thesis.
book Typesetting books.
slides Typesetting slide. The class uses big sans serif font. It is also conceivable to use FoilTEX same effects.

options Options

options significance
10pt, 11pt, 12pt Set the font used in the document size. If no option is specified, the default will be used 10pt font.
a4paper, letterpaper, . . . Custom paper size, the default is set to letterpaper. Additionally, you can use a5paper, b5paper, executivepaper and legalpaper.
fleqn Setting this option will make mathematical formulas left-aligned instead of centered text.
leqno Setting this option will enable the number of anti mathematical formula to the left.
titlepage, notitlepage Specifies whether the title of the document (document title) to start a new page. article class does not start a new page by default, while the book document class and vice versa.
onecolumn, twocolumn LATEX to specify a single column (one column) or double row (two column) typeset document.
twoside, oneside LATEX typesetting documents designated as single-sided or double-sided format. article and use the default report format single-sided, double-sided and the book is the default format. Note that this option is applied only to the document style. twoside option does not tell the printer to make a two-sided printout.
openright, openany This option determines only the beginning of a new chapter on the right page (odd page) or in the next available page. This article document class option does not work because the class does not define "chapter" (Chapter). report new class starts chapters on the next page available and the book class in a new chapter always starts on the right page.
\documentclass[12pt, twoside, a4paper]{article}

This command specifies the output of LATEX use paper layouts, 12-point size of the font to shift this document, and get fit to print on A4 paper

Hiroshitsutsumi

When you typeset, you will find that many times the basic latex can not solve your problem, if you want to insert graphics, colored text or source code files, you need to use a macro package to enhance the latex.

\usepachage[options]{package}
  • Here is the package name of the macro package
  • options are used to start the macro package of special features Keywords

Some packages

name effect
normalfontdoc LATEX typesetting program documentation. See doc.dtxa and The LATEX Companion [3].
exscale It provides a scalable version of the math extension font. See ltexscale.dtx.
normalfontfontenc Font encoding (font encoding) statement LATEX used. See ltoutenc.dtx.
ifthen Providing command of the form: '...... If then do otherwise do....', And detailed ifthen.dtx The LATEX Companion [3].
latexsym This macro package can be transferred using the LATEX symbol in the document. See latexsym.dtx and The LATEX Companion [3].
makeidx It provides a command to generate the index. See Section 4.3 and The LATEXCompanion [3].
syntonly Only documents, but not its layout.
inputenc It allows you to declare ASCII, ISO Latin-1, ISO Latin-2,437 / 850IBM code page, Apple Macintosh, Next, ANSI-Windows or custom input code. See inputenc.dtx.

All kinds of letex file

Different file extensions are different, the following table detailing.

Different file extension

name effect
.tex LATEX or TEX source file. It can be treated with latex.
.sty LATEX macro package file. You can use the command \ usepackage load it into your LATEX file.
.dtx TEX documentation file. This is the primary format for LATEX macro package released. .Dtx by processing a file you can get the macro code LATEX document included in the packages.
.ins 为相应的.dtx 文件的安装文件。如果你在网络上下载了一LATEX 宏包,你通常会发现会有一个.dtx 和一个.ins 文件。使用LATEX 对.ins文件进行处理,可以从.dtx 文件中提取出宏包。当你运行LATEX 处理你的源文件时,会得到下列文件:
.dvi 与设备无关文件。这是LATEX 编译运行的主要结果。你可以使用DVI预览器浏览其内容,或者使用像dvips这样的应用程序输出到打印机。
.log 记录了上次编译运行时的详细信息。
.toc 存储了所有章节标题。该文件将在下次编译运行时被读入并生成目录。
.lof 类似.toc 文件,可生成图形目录。
.lot 类似.toc 文件,可生成表格目录。
.aux 另一个用来向下次编译运行传递信息的辅助文件。除了其它信息外,.aux 文件通常包含交叉引用信息。
.idx 如果你的文件中包含有索引,LATEX 使用此文件存储所有的索引词条。此文件需要使用makeindex 处理。
.ind 经过处理后的.idx 文件。可在下次编译运行时加入到你的文档中。
.ilg 运行makeindex 时生成的记录文件。

页面样式

latex支持三种预定的页眉,页脚(header/footer)格式,称为页面式样(page styles).

\pagestyle{style}
  • style参数定义了所使用的页面式样
参数名称 含义
plain 页眉为空,页脚由居中的的页码组成。这默认的页面式样。
headings 页眉由当前的章节标题和页码组成,脚为空。(这是本文档所使用的页面式样)
empty 设置页眉、页脚均为空。

可以使用下面的命令改变当前页的页面式样。

\thispagestyle{style}

大型文档

处理大型文档时,最好将源文件分成几个部分。latex有两条命令来处理这种情况。

\include{filename}
  • 在文档的正文中使用此命令可将文件名为filename.tex的内容包括进来。
\includeonly{filename,filename,...}
  • 这条命令可用在文档的引言区
  • 在所有的include命令中,只有includeonly命令参数中列出的文件才会被执行。
  • 参数中,文件名和逗号之间不能有空格。

使用syntonly 宏包可以让LATEX快速的检查你的文档:LATEX浏览你的文档,仅仅检查语法和所使用的命令是否正确,会产生DVI输出。在这种模式下,LATEX 运行的非常快,可以节省可观的时间。使用方法非常简单:

\usepackage{syntonly}
\syntaxonly
发布了289 篇原创文章 · 获赞 96 · 访问量 28万+

Guess you like

Origin blog.csdn.net/AcSuccess/article/details/104762242