type
status
date
slug
summary
category
tags
password
icon
🌻
A quick checklist of basic LaTeX typographic syntax.

Overview LaTeX Typesetting

  • \documentclass{article} Indicates that the type of the document is defined as an article.
  • begin and end always occur in pairs; these two control sequences, and the content in between, are referred to as "environments"; the first required parameter after them is always the same, and is referred to as the environment name.
  • Only content in the document environment is output to the document properly
  • The section before \documentclass{article} to \begin{document} is called the introductory area (the global formatting area).
For example, we usually set the page size, header and footer styles, chapter title styles, etc. in the introductory area.

Mixed Chinese and English

The second common problem faced by Chinese TeX users is probably the implementation of mixed Chinese and English. Now, XeTeX supports Unicode natively and can easily call system fonts. It can be said that it solves the big problem that has been bothering Chinese TeX users for many years.

Introduction

The so-called macro package is a collection of control sequences. These control sequences are so commonly used that people find it too tedious to write them in the introduction area each time, so they are packaged in the same file, which becomes the so-called macro package.
\usepackage{} can be used to invoke a macro package.

Author, title, date

The introductory area is much more complex, but there is only one major difference from the previous document: the definition of title, author, and date.
In addition to the original hello, world! in the document environment, there is an additional control sequence, maketitle, which displays the title, author, and date defined in the introductory area in a predefined format.
The above default format can be modified using the titling macro package. Refer to TeXdoc.

Layout Settings

Margins

To set the margins, the geometry macro package is recommended. Its documentation can be found here.
For example, if I want to set the length of the paper to 20cm, the width to 15cm, the left margin to 1cm, the right margin to 2cm, the top margin to 3cm, and the bottom margin to 4cm, I can add a few lines like this in the introductory area:

Header and footer

To set up headers and footers, we recommend using the fancyhdr macro package. Its documentation can be found here.
For example, I would like to have my name on the left side of the header, today's date in the center, and my phone number on the right side; a page number in the center of the footer; and a horizontal line 0.4pt wide separating the header from the text, you can add the following lines in the introductory area:

First line indentation

The CTeX macro already takes care of the first line indentation (two Chinese character widths before the natural paragraph). Therefore, we do not need to be concerned about first-line indentation when using the CTeX macro set for mixed Chinese and Western typesetting.
If for some reason you choose not to apply the CTeX macros (not recommended) for Chinese support and layout, you will need to do some additional work.
  • Call the indentfirst macro package. Specifically, the Chinese custom is to indent the first line of each natural paragraph by leaving two Chinese character lengths of the paragraph head, but the Western custom is not to indent after logical sections ( \sections, etc.). Use the macro package to make LaTeX indent the first line of every natural paragraph.
  • Set the length of the first indent \setlength{\parindent}{2\ccwd}. Where \ccwd is a macro defined by xeCJK, it indicates the width of a Chinese character in the current font size.

Line Spacing

We can adjust the line spacing with the commands provided by the setspace macro package. For example, you can set the line spacing to 1.5 times the font size by adding the following to the introduction area:
See the documentation for this macro package.
Note the difference in wording:
  • Line spacing is 1.5 times the font size;
  • 1.5 times the line spacing.
In fact, this is not the correct way to set 1.5x line spacing, see this blog post. In addition, RuixiZhang has developed the zhlineskip macro package, which provides more fine-grained line spacing control for mixed Chinese and Western text.

Paragraph Spacing

We can adjust paragraph spacing by changing the value of length \parskip. For example, if you add the following to the introduction
then you can increase the paragraph spacing by 0.4em, and if you want to decrease the spacing, just change the value to a negative one.

Text

Sections and Paragraphs

Save and compile the following document with XeLaTeX to see the effect:
In the document class article/ctexart, five control sequences are defined to adjust the organization of the lines. They are
  • \section{-}
  • \subsection{-}
  • \subsubsection{-}
  • \subparagraph{-}
  • \subparagraph{-}
In report/ctexrep, there is also \chapter{-}; in the document class book/ctexbook, \part{-} is also defined.

Inserting a Table of Contents

In the previous section of the document, find \maketitle and insert the control sequence \tableofcontents underneath it.
Notice that in the "Hello China" section, there is a blank line sandwiched between "China in East Asia." twice, but the output has only one newline and no blank line. This is because LaTeX treats a newline as a simple space, and if you need a newline to start a new paragraph, you need to use two newlines (and a blank line) to do so.

Images

There are many ways to insert pictures into LaTeX. The best one is to utilize the \includegraphics command provided by the graphicx macro package. For example, if you have a picture named a.jpg in the same directory as your TeX source file, you can insert it into the output document in this way:
The image may be large, exceeding the paper size of the output file, or you may simply find the output unpleasant. You can control this with the optional parameters of the \includegraphics control sequence. For example
so that the width of the image is scaled to eighty percent of the width of the page and the total height of the image is scaled proportionally.
The \includegraphics control sequence has a number of other optional parameters that are not normally used. If you are interested, you can check the documentation of the macro package.

Tabular

The tabular environment provides the simplest table functionality. It uses the \hline command for horizontal lines, and | for vertical lines in column formatting; & for columns, and \\\ for line breaks; each column can be left, center, or right horizontally aligned with l, c, or r, respectively.
💡
You are welcome to leave a message in the comment section at the bottom (the comment section can be logged in or not and anonymous), and communicate with each other~!
 
LaTex Common Simple TemplatesPicture beds
Loading...
Liang
Liang
An ordinary dry rice man.
最新发布
Writing in Chinese|Markdown Grammar Quick Start & Quick Checklist
2025-4-22
Writing in Chinese|What are some good online disk services?
2025-4-22
Writing in Chinese|Ulysses is the ultimate writing software!
2025-4-22
Writing in Chinese|Mythical Words - Demonstrations for Indie Developers
2025-4-22
Writing in Chinese|Zotero 7 Installation and Getting Started Tutorials|Windows Demo
2025-4-22
Writing in Chinese|Zotero Beginner's Complete Guide
2025-4-22
公告
🎉Welcome to my blog🎉