Introduction to latexlatex typographical System
Tex is a computer program written by Donald E. knuth to typeset text and mathematical formulas. The most basic Tex program consists of some basic commands to complete simple typographical and programming functions. Tex also allows the use of these basic commands to define more complex advanced commands, thus quickly forming a user-friendly environment using a low-level structure. Knuth also designed a basic format named Plain Tex to echo the low-level Tex. Plain Tex format is still a basic part of Tex word processing. In fact, we can distinguish Tex from plain Tex.
The focus of plain Tex is only on how to typeset the layers. To further explore the deep features of Tex, it requires quite advanced programming skills. Leslie Lamport, an American computer scientist, developed the latex format, which provides a set of more advanced commands required to generate complex documents. It is particularly useful in generating complex tables and mathematical formulas. It can automatically give titles, chapters, table directories, cross references, formula numbers, document references, floating charts, floating graphics, and so on. After many years of updates, latex versions are fixed to 2.09.
Thanks to the popularity of latex and the expansion in many fields, a wide range of typographical formats are labeled as latex. In order to unify the various patching work carried out after latex2.09 and establish a latex improvement standard that can meet the typographical needs for a long period of time, under the leadership of Frank mittelbach, leslie Lamport, Chris Rowley, And Rainer Schopf created the latex project team to get a new version of latex 3, which creates an optimal and effective command set. In 1994, they released a new version named latex2e.
Latex typographical features
Latex typographical features:
- The typographical format specified by international authoritative academic institutions and conferences
- Symbol Formulas
- Easy to transfer documents online
- Supports multiple operating systems
- Easy to convert to PS documents, PDF documents, or HTML documents
- It is easy to expand and form a personalized typographical environment (implemented using latex macro packages)
Basic Structure of latex source file
The basic structure of each source file is as follows:
/Documentclass [font size, paper size, miscellaneous parameters] {document category}
Introduction area (preamble)
/Begin {document}
Document text area
/End {document}
Latex document category (/documentclass {})
Legal latex document categories include the following five:
- Article (Article) (Note: cctart can be used in CCT)
- Book)
- Report)
- Letter (letter)
- Slides)
In addition to the slide category, the standard document category accepts the following optional parameters to determine the font size (1pt = 1/72. 27 feet)
All document categories accept the following optional parameters to determine the paper size (letter by default)
- A4paper (29.7 £21 cm)
- A5paper (21 £14. 8 cm)
- B5paper (£ 25. 6 cm)
- Letterpaper (11 £8. 5 In)
- Legalpaper (£8. 5 In)
- Executivepaper (10.5 £7. 25 in)
There are also some optional miscellaneous Parameters
- Landscape: select the horizontal layout mode. The default is portrait layout (portrait)
- Leqno: the number of the formula is placed on the left of the formula, and the missing time is placed on the right.
- Fleqn: The left alignment of the formula is displayed, and the middle alignment of the missing time is displayed.
- Draft, final: the border with or without a ruler. The default value is final.
- Oneside and twoside: Single-sided or dual-sided printing. The default category is double-sided, and the default category is single-sided.
- Onecolumn and twocolumn: either the column or the column. The default value is the column.
Add necessary classes and package files to the INTRODUCTION AREA
To facilitate customization or expansion of the typographical system, latex saves many functions in different classes or package files. To use the function of a class or package file, you must declare (activate) in the introduction area ):
/usepackage[option]{package}
Here, package is the name of the package to be activated, and option is a list of keywords to describe specific functions or features in the package. For example,
/Usepackage [dvips, usenames] {color} % supports colors
/Usepackage {CJK} % use CJK to support Chinese Characters
/Usepackage {fancyhdr} % supports custom headers and footers
/Usepackage {fancyvrb} % supports transcription
/Usepackage {fancybox} % supports text box adding
Complete Document global settings
Sometimes you are not satisfied with the Standard settings. In this case, you can place some setup commands in the introduction area to influence the renovation document. For example:
/setlength{/textwidth}{16cm} /setlength{/textheight}{22cm}
/setlength{/oddsidemargin}{0pt} /setlength{/parindent}{0em}
/setlength{/parskip}{3mm}
/renewcommand{/baselinestretch}{1.3}
/color{black}
Composition of the document body area
Define some information about the article:
/Title {Title}
/Author {author name}
/Date {date }%/ today
/Maketitle
Latex always plays one of the following three modes when processing input files:
- Paragraph (paragraph Mode)
- Math (Mathematical Model)
- Left-to-right (from left to right model, LR mode for short)
The input of the text must be based on the selected document type and loaded macro package files, the titles, chapters, page numbers, headers, footers, footers, side notes, tables, graphs, and various complex mathematical formulas are obtained.
When processing large files, files are often divided into several parts for separate compilation. In this case, we can use the commands provided by latex.
- /Input
- /Include
- /Includeonly
/Input {texfile}
You only need to specify the basic name for the file name without the extension. Tex. It is equivalent to directly inputting the content in the file "file name. Tex" to the location of the command/input.
This command can be placed anywhere in the document (Introduction area or body area) and can be nested with each other.
You can put the frequently used introduction in a separate file, and place it at the beginning of the source file.
Add multiple/input commands between/begin {document}.../end {document}. Add/listfiles in the introduction area to get the list of read files.
/Include {texfile}
The disadvantage of using the/input command is that every modification to the articles merged by the/input command (regardless of the part) requires all files to be read and processed again. If the/input command is used to load only the specific file, the automatic numbers of all pages, chapters, illustrations, and formulas start from 1, which can lead to confusion between cross references. A better way is to use the/include command.
It can only be placed in the text area of the document and cannot be nested. It can be used with the command/shortdeonly {file list.
The file list lists the files currently being processed (the file names do not need to be suffixed with. Tex, and each file name is separated by a comma ). If the file name after the/input command is in the file list, this command is equivalent
/Clearpage/input {file name}/clearpage,
Otherwise, it is equivalent to a page feed. Therefore, the document should be separated at the Beginning of the New Page (such as between chapter and chapter. The/include command can help us save a lot of valuable compilation time. Its main advantage is that additional information about pages, Chapter sections, and formula numbers can be provided by the/shortdeonly command, for example, the/Ref and pageref commands can generate correct results. This command can be used multiple times, and only one is required in the Introduction area.
Example: edit a book consisting of eight chapters.
/Documentclass {book}
INTRODUCTION AREA
/Includeonly {.....}
/Begin {document}
/Frontmatter
/Include {TOC}
/Mainmatter
/Include {chapt1}
...
/Include {chapt8}
/Backmatter/printindex
/End {document}
The TOC. Tex file consists of the following text:
/setcounter{page}{7}
/tableofcontents
/listofcontents
/listoffigures
By adding appropriate items to the/shortdeonly command, such as/shortdeonly {TOC, chapt8}, You can selectively process each chapter (chapter 8th here ).
/Includeonly
Some commands support optional parameters enclosed by brackets.
Introduction area bookmarks
A pdf document has a feature-bookmarks, which allows you to open a tree-based index to browse the chapters of an article, which is very convenient for reading large documents. Hyperref macro package can be used in Tex to implement this function.
/usepackage[dvipdfm,CJKbookmarks,bookmarks=true,bookmarksnumbered=true]{hyperref}
Chinese bookmarks
The bookmarks of PDF has special requirements on text encoding. It can use two types of encoding: ISO Latin 1 or Unicode UTF16 big endian. Tex is a multi-byte language like Chinese. Even if the document is saved using UTF-8 encoding, it still cannot get the correct bookmarks. This requires special commands in the document.
For gb2312 encoded files, we can add a special command after it (after/begin {document ):
/AtBeginDvi{/special{pdf:tounicode GBpc-EUC-UCS2}}
For UTF-8 encoded files, use:
/AtBeginDvi{/special{pdf:tounicode UTF8-UCS2}}
After/begin {document}
Where the UTF8-UCS2 of cmap, You need to download a package to the http://project.ktug.or.kr/dvipdfmx/sample/omega/lambda-example2.zip, and then copy the UTF8-UCS2 file to the texmfhome/dvipdfm/cmap directory 2.
Define bookmarks:
/Hypersetup {colorlinks, linkcolor = blue, citecolor = blue, urlcolor = blue, % define the link Style
Bookmarksopen = true, % open the bookmarks while opening the PDF file
Wrote Highlight =/P, %/I (inverse)/n (no effect)/O (outline)/P (inset)
Pdfauthor = {michaelbibby <michaelbibby@gmail.com >}, % creator of the PDF file
Extends creator = Tex, % the tool used to create the PDF document
Subtitle Title = {tetex Chinese}, % the title of the PDF document. It is not the file name of a PDF file.
Required subject = {tetex}, %
Export KEYWORDS = {project solution}, % keyword of this document
Export startview = fith, % fitbh, fitb
Pdfpagemode = useoutlines, % useoutlines, % none, fullscreen, usethumbs
}
Gbk2uni
This tool is very useful. Sometimes bookmark should come and may need it for help. The ctex kit already comes with this tool, which requires additional downloads for UNIX platforms.
Usepackageindentifirst
Indentfirst # each Chinese section has two Chinese characters in the first line.
Because indentfirst cannot accurately use the positions of two Chinese characters, you need to add a Tex command after/begin {document:
/CJKindent
Hyperref
Hyperref macro has many options, such:
/usepackage[dvipdfm,CJKbookmarks,bookmarks=true,bookmarksnumbered=true]{hyperref}
More common options:
/Hypersetup {colorlinks, linkcolor = blue, citecolor = blue,
Urlcolor = blue,
Plainpages = flase,
Required creator = Tex,
Bookmarksopen = true,
Required Highlight =/P,
Pdfauthor = {michaelbibby <michaelbibby@gmail.com> },
Repeated creator = {ctex },
Export Title = {/latex Beamer entry },
Export KEYWORDS = {/latex Beamer entry michaelbibby },
Repeated startview = fith,
Pdfpagemode = useoutlines, % useoutlines, % none, fullscreen, usethumbs
}
Body article title
/Title {OpenBSD entry }%set the article title. Title.
/Author {Zhang huangbin} % author
/Date {/today} % date of the article
%/Newpage
/Maketitle % Use this command to generate the title information. Only the command is added to generate the article title information.
Chapter and Section
For articles in the article style, there are the following sub-commands:
/section{...}
/subsection{...}
/subsubsection{...}
/paragraph{...}
/subparagraph{...}
For reports and book-style documents, there are two other sub-section commands (the part is larger than Chapter ):
/part{...}
/chapter{...}
Because Article-style documents are not divided into chapters, it is easy to insert them into book documents as a chapter. The interval between sections. The serial number of the Section and the font size of the title are automatically set by latex. The two sub-commands have some special characteristics:
- The command/part does not affect the serial number of the chapter.
- Command/Appendix without parameters, only the serial number of the chapter is changed to a letter mark.
/Chapter has another usage method:
/Chapter [content displayed in the Directory Index] {Title displayed in the body}
In the last loop of Document compilation, latex extracts the section title and page number to generate a directory. Command
/tableofcontents
Insert the directory where it appears. To get the correct directory content, a new document must be compiled twice. Sometimes it needs to be compiled three times. At that time, latex will notify you.
Font and size (Todo) font size insert image (EPS)
Latex provides basic capabilities for processing floating objects such as images or images through the figure and table environments.
There are several ways to use the basic latex command or latex expansion macro package to generate the actual image. However, most users find these commands quite difficult to understand. Therefore, we do not intend to go into these details in this manual. For more information, see the latex companion and latex manual.
A simple way to add a graph to a document is to generate a graph file using a specific Software Package 1 and then include the final graph file in the document. The latex macro package provides many methods to do this. In this manual, we will only discuss the use of encapsulated postscript (EPS) graphics files. Because it is relatively simple and widely used.
To use an image in the EPS format, you must have a postscript printer to output the result. The graphicx macro package created by D. P. Carlisle contains a set of good commands to include graphics. It is part of a macro package called graphics. Assuming that the postscript printer and graphicx macro package are installed on your system, you can add an image to your document step by step through the following steps:
1. Use your image software to output graphics files in the EPS format.
2. In the introduction to the input file, add the following command to load the graphicx macro package.
/usepackage[driver]{graphicx}
Here, the driver is your "DVI to postscript" Conversion Program. The most commonly used is dvips. The program name is required because Tex does not specify standards that contain graphs. Knowing the driver name, graphicx macro package can select an appropriate method to insert information about the image in the. DVI file. In this way, the printer can understand the information and correctly include these. EPS files.
3. Use commands
/includegraphics[key=value, . . . ]{file}
To add the file to your document. An optional parameter is a series of keywords keys separated by commas and the corresponding value values. The key word keys can be used to change the width, height, and Rotation Angle of the contained image. The following are the most important keywords.
# Keywords used by graphicx macro package:
Width: scales the image to the specified width.
Height: scales the image to the specified height.
Angle clockwise rotation
Scale graphics
The following example helps us understand the entire process:
/begin{figure}
/begin{center}
/includegraphics[angle=90, width=0.5/textwidth]{test}
/end{center}
/end{figure}
This Code contains the graph stored in the file test. EPS to the document. First, the image is rotated 90 degrees, and then scaled to make the image width equal to 0 to 5 times the width of the standard page. Because the height of the image is not specified, the ratio of the height and width of the image is, that is, the original aspect ratio is maintained. The height and width parameters can also be specified in absolute length units.
Footnote)
Bibby/Footnote {This is a footer for "Bibby}
At this time, a number will appear in the upper-right corner of the string Bibby, indicating that this is the footer of the page. To jump to the corresponding footer by clicking this number, you need to use the hyperref package:
# Add in the introduction area:
/Usepackage {hyperref}
/Pagestyle {headings} # is written in the Introduction area. The header consists of the title and page number of the current chapter, and the footer is empty.
Reference
/begin{quote}
...
/end{quote}
Automatic Index generation
Add this sentence after/begin {document:
/tableofcontents
For the sake of appearance, you can use it like this:
/Newpage % start a new page
/Tableofcontents % Create Table of Contents automatically
/Newpage % start a new page
/Pagenumbering {Arabic} % Arabic page numbers from now on (index page by Arabic numerals)
Pagenumbering can also have the following parameters:
- Arabic numerals
- Roman lowercase roman numerals
- Roman uppercase roman numerals
- Alph lowercase letters
- Alph uppercase letters
Broken Line
Start another line instead of another one:
// or /newline
After a row is forcibly disconnected, pagination is also prohibited:
//*
Create a new page:
/newpage
String Layout
Ellipsis:
/ldots
Quotation marks
Do not use "as quotation marks as on a typewriter. There are special left and right quotation marks in the printing. In Latex, two '(the same key as the Tilde) are used to generate left quotation marks, and two' (quotation marks) are used to generate right quotation marks. One and one produce a single quotation mark.
Reference (Todo) use the fancyhdr macro package for the header and footer (Todo)
When using latex to typeset articles and books, four types of header and footer formats are defined by default:
Empty does not have a header or footer
Plain has no header, and the page number is placed in the middle of the footer.
Headings has no footer. the header contains the title and page number of the chapter.
Myheadings does not have a footer. The page number of the header and the user-defined information are displayed.
Article uses plain format by default, while book uses headings format. You can also use the/pagestyle command to set the format used in your document. For example, if/pagestyle {empty} is used in the document, no header or footer is available for the subsequent page. In general, these four formats can basically meet the typographical requirements. However, in some cases, especially when users want to define their own headers and footer formats, they may encounter many restrictions and troubles. At this time, the fancyhdr macro package can easily achieve the goal.
Using the Command provided by the fancyhdr macro package, you can easily:
- Customize the header and footer.
- Add a decorative horizontal line to the header and footer.
- The width of the header and footer can exceed the width of the body text.
- The header and footer of multiple rows.
- The even page uses different headers and footers.
- The homepage of each chapter uses different headers and footers.
- The floating object page uses different headers and footers.
- Control the font of the header and footer, including the font, family, and case.
Most of the current Tex software, such as miktex, fptex, and tetex, includes the fancyhdr macro package. If your tex software is older than emtex, you need to install it yourself. The installation method is simple. Just put fancyhdr. sty in the directory that latex can find.
Add to the introduction area:
/Usepckage {fancyhdr}
/Pagestyle {fancy}
% Basic usage:
/Lhead {}
/Chead {}
/Rhead {}
/Lfoot {}
/Cfoot {}
/Rfoot {}
Image: fancyhdr1.gif}/bfseries/leftmark}/fancyfoot [le, RO] {/thepage}/fancyfoot [Lo, re] {/cjkfamily {Kai} July 2000 AD}/renewcommand {/headrulewidth} {0.4pt}/renewcommand {/footrulewidth} {0.4pt }...... /end {CJK}/end {document}
Section)
/Section * {Section title}
/Section {Section title} # produce a numerical serial number before section title
Miscellaneous email links
/Href {mailto: michaelbibby@gmail.com} {email to me }}
URL link
- Displayed as "OpenBSD Official Website", link to 'HTTP: // www.openbsd.org ':
/Href {http://www.openbsd.org} {OpenBSD official website}
/url{http://www.openbsd.org}
- Show URL, but do not link or jump:
/nolinkurl{http://www.openbsd.org}
Subdirectory level
/Setcounter {tocdepth} {5} % to generate a maximum of five sub-directories. Combined with/tableofcontents
Narration or side note
/marginpar{}
List
Note: you cannot use '//' to manually disconnect rows in the list.
/begin{itemize}
/item The first item.
/item The second item.
...
/end{itemize}
Table (Todo)
Format:
/begin{tabular}{table spec}
/end{tabular}
Table spec defines the style of a table.
- 'L' generates left-aligned columns;
- 'R' generates right-aligned columns;
- 'C' generates a center column;
- 'P {width value width} 'generates columns with corresponding width and automatic broken line text;
- '|' Produces a straight line of lead;
- '&' Jump into the next column. It can also be determined by the symbol specified in. For example,/begin {tabular} {@ {.} is separated by a separator in the '.' column .;
- '//' Starts a new row;
- '/Hline' generates a horizontal line;
- '/Cline {J-I}' to add some table lines. J and I indicate the sequence numbers of the start and end columns of the table line, respectively;
For example:
/begin{tabular}{|l|c|c|}
...
/end{tabular}
In this table, the first column is left aligned, and the second and third columns are centered.
Merge Columns
/begin{tabular}{|c|c|}
/hline
test & test //
/hline
/multicolumn{2}{|c|}{text area} //
/hline
/end{tabular}
Special symbols
Use the alternative latex command on the document.
/Typographical command $/backslash $/textbackslash
% Resolution/% na
# Definition huge set/# Na
~ Generate a blank space /~ {}/Textasciitilde
$ Inbound (open) data mode $/textdollar
_ Generate icons in the data mode/_ {}/textunderscore
^ Generate upper mark in data mode/^ {}/textasciicircum
{Role of the tag command {/textbraceleft
} Indicates the role of the command. Optional values/}/textbraceright
<Less than symbol ___ fckpd ___ 48lt; $/textless in the data mode
> In the data mode, the value is greater than ___ fckpd ___ 48gt; $/textgreater
| Ot1 Verification Failed. The value of $ is displayed only in the data mode. | $/textbar
& Delimiter/& Na in the table
Watermark
In the introduction area:
/usepackage[all,bottom]{draftcopy}
/draftcopyName{Copyright by MichaelBibby, 2006}{50}
/draftcopySetGrey{0.8} /draftcopyPageTransform{55 rotate}
/draftcopyPageX{80}/draftcopyPageY{-25}
To generate a file, follow these steps:
latex --> dvi --> ps --> pdf
Set boundaries
Try the anysize package
/usepackage{anysize}
Put the following statement after/begin {document}
papersize{width}{height}
Set the page size. This command is optional because the standard page size can be set in the/documentclass option by default. It is generally a4paper.
/marginsize{left}{right}{top}{bottom}
Set the blank page size, which is the value of the anysize macro package. For double-sided layout such as book, the left and right pages here will be exchanged. For example:
/marginsize{1}{1}{}{}
Tipspdf merge
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf f1.pdf f2.pdf f3.pdf
Toolspdf <--> word
Http://www.grindeq.com/index.htm