Record the LaTeX learning process_02

Record the LaTeX learning process_02

Here, the teaching PPT of teacher Geng Nan of the college is used as the learning material LaTeX basic knowledge_1 . This article mainly records the running account in the process of reading and practicing this PPT.

Basic understanding of writing

  1. First of all, all commands in LaTeX are similar to this: \命令[可选参数]{其他参数}, of course, commands can also take no parameters.
  2. Generally, the first line of a LaTeX file is: \documentclass[letterpaper, 12pt]{article}, this is a template command. LaTeX integrates many templates, such as article, book, letter, ctexart, etc. Using templates, you can quickly achieve the template requirements you want.
  3. \usepackage[margin=2.5]{geometry}This is an extended macro package. Drawing in LaTeX, and writing mathematical formulas are all integrated into the macro package. If we want to use it, we can add the macro package so that we can use it directly. This is a bit like when you write C/C++ programs (similar to other programming languages), you need to add some header files so that you can call them.
  4. \newcommand{name}[num]{definition}User-defined commands.
  5. manuscript.
\begin{document}
...
\end{document}

This is the manuscript command, and the content of the article you want to write is placed here. It should be noted that an article has one and only one document environment.
6. Introductory area: Generally, \documentclass{xxx}和\begin{document}there is an introductory area in between, which is used to make some global settings.

Written in Chinese:

\documentclass[12pt]{ctexart}
\begin{document}
你好!
\end{document}

There are two points to note here:
1. Chinese document classes are required: ctexart, ctexbook, ctexrep, ctexbeamer, etc.
2. Be sure to use UTF-8 encoding format , otherwise garbled characters will appear.

Basic conventions:

  1. Annotate with '%'.
  2. Add a space after the Western punctuation. (English writing standard)
  3. It is recommended that the beginning and end of each incarnation should be on a separate line. This has two advantages, one is to strengthen the organization, easy to read and modify, and the other is that if you don't do this, sometimes there will be typesetting problems.
  4. newline. A carriage return is only regarded as a space, and more than two carriage returns are regarded as a line feed. This is somewhat similar to markdown.

Line breaks, pagination, paragraphs, indentation, line spacing, alignment:

  1. If you want to output special characters, you need to use \escape, mathematical operators, greater than sign: $>$.
  2. LaTeX generally automatically breaks lines. If you need to force line breaks, you need to use \\, \\*, \newline. \\And \\*can take a length parameter to increase the distance between the current line and the new line. The parameter can be positive or negative, such as: \\[3cm]. It is recommended to break a line \linebreak[n], where n can be 0, 1, 2, 3, and 4. The larger the number, the stronger the recommendation. \linebreak means a forced line break, and the entire line is filled by increasing the word spacing. \nolinebreak[n] suggests no line break. \mbox{text content} keeps text content on the same line. Can be inserted in English words - hyphenation is suggested.
  3. segment. \paror two carriage returns.
  4. pagination. Usually automatic pagination. Force pagination \newpage. Pagination is recommended \pagebreak[n],\nopagebreak[n].
  5. Horizontal spacing, vertical spacing. Look at the teacher's PPT.
  6. First line indent. If you are using the ctex template, two Chinese characters are automatically indented; it can also be set \setlength{\parindent}{2em}; \indent and \noindent can set and cancel the first line indentation; the first line of the first paragraph of each section is not automatically indented, you can use: \hspace{\parindent},在导言区加入\usepackage{indentfirst};Paragraph spacing adjustment: \lineskip, \parskip;
  7. line spacing. \baselineskip, look at the PPT.
  8. Elastic length.
  9. List environment.
  10. Alignment. Align both sides by default.
    Center Align:
\begin{center}
...
\end{center}

Align left:

\begin{flushleft}
...
\end{flushleft}

The right-aligned use flushrightenvironment can also be implemented using the : \raggedrightand \raggedleftcommand.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325203035&siteId=291194637