Tag Archives: 【LaTeX】

11. Center text

\centerline

Syntax: centerline {text}

This is the original command of Tex for centering short text.

Center environment

Grammar:

\begin{center}

First line\\

The second line\\

\end{center}

Center environment can realize the alignment of multiple lines.

In the center environment, if the “first line” is too long, it will wrap automatically, and the text of the wrap is still center aligned, so this is a very common way.

example

Here is a very practical example. When writing a paper, you need to write a title, and it is usually stipulated that the title above is in Chinese and the title below is in English

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

\documentclass[11pt,a4paper]{article}

\usepackage{CJK}

\usepackage{type1cm}

\usepackage{times}

\newcommand{\song}{\CJKfamily{song}}

\newcommand{\xiaoer}{\fontsize{18pt}{18pt}\selectfont}

\newcommand{\xiaosan}{\fontsize{15pt}{22pt}\selectfont}

\Renewcommand {baselinestretch} {1.8}% double spacing

\begin{document}

\begin{CJK*}{GBK}{song}

\begin{center}

The shortest path algorithm: ~ classification system and research progress}} \

{Xiaoer shortest path algorithms: ~ taxonomy and advance in research}% Times New Roman, sophomore

\end{center}

\vspace{20pt}

\Centerline {Xiaosan for Quad: Lu Feng}% can be used for shorter text

\end{CJK*}

\end{document}

The results are as follows

Let’s get started with latex 05, line feed, paragraph feed, page feed, first line indent, etc

Line feed command

\\: wrap.

\\[offset]: newline, and the line spacing with the next line is the original line spacing + offset.

\Newline: same as \ \.

\Linebreak: force line break. The difference between linebreak and newline is that the current line of linebreak is aligned separately.

Segment command

\Par: segmentation.

Paging command

\Newpage: paging command.

\Clearpage: similar to the new page. When we use the CJK environment, we will add the clearpage at the end of the environment.

text-indent

The simplest way is to set the length of the parent as follows: setlength {parent} {length}. If you want to indent the first line by two Chinese characters, then set the length as follows: setlength {parent} {2em}.

If you are in CJK environment, you can indent the first line immediately after “begin {CJK} {GBK} {song}”.

By default, the first line of the first paragraph is not indented. If you want the first line of the first paragraph to be indented, you can use ﹣ usepackage {indentfirst}.

If you want a paragraph not to be indented on the first line, you can precede the paragraph with the word “no indent”.

If you want the first line of the whole article not to be indented, then: setlength {parent} {0pt}

Note: in latex, one carriage return represents a space and two carriage returns represent a segment.

Usually, in practice, we expand according to the following template:

\documentclass[12pt,a4paper]{article}

\Usepackage {CJK}% import CJK macro package

\Setlength {parskip} {10pt}% sets the interval between partial paragraphs

\begin{document}

\Begin {CJK *} {GBK} {song}% to start CJK environment

\Cjktilde% redefines “~”

\CJ kindent% set first indent

This paper reflects on the history and development of the latex Project Public License (lppl)

\No indent in late June, the tug 2010 conference was held in San Francisco to great success

\clearpage

\End {CJK *}% end CJK environment

\end{document}

\Setlength {parskip} {10pt}: the paragraph interval is the sum of ⁃ lineskip and ⁃ parskip. The value of ⁃ parskip is set here to increase the paragraph interval.

\CJ kindent: indent the first line in the CJK environment.