Jack's Blog

流淌的心,怎能阻拦,吹来的风,又怎能阻挡。

Latex -- 入门学习

Jacob posted @ Aug 07, 2017 07:28:59 PM in LaTex with tags latex , 734 阅读

Before we go:

LaTex 的特点:

1.LaTeX是一类用于编辑和排版的软件,用于生成PDF文档。
2.LaTeX编辑和排版的核心思想在于,通过\section和\paragraph等语句,规定了每一句话在文章中所从属的层次,从而极大方便了对各个层次批量处理。
3.LaTeX在使用体验方面,最不易被Word替代的有四个方面:方便美观的数学公式编辑、不会乱动的退格对齐、非所见即所得

因此可以在编辑的时候用退格和换行整理思路,但生成PDF出来不影响美观、部分导师和刊物不接受Word排版的文章。


1.hello world

\documentclass{article}
\begin{document}
hello, world
\end{document}

ps:why the first test sample is always hello world?

quote from my teacher:"Because this proves you have successfully installed the needed environment.

2.标题、作者和注释

\documentclass{article}
\author{My Name}
\title{The Title}
\begin{document}
\maketitle
hello, world % This is comment
\end{document}

默认是有时间的,如果不想要日期的话
\documentclass{article}
\author{My Name}
\title{The Title}
\date{}
\begin{document}
	\maketitle
	hello, world % This is comment
\end{document}

3.章节和段落

\documentclass{article}
\title{Brief Introduction}
\begin{document}
	\maketitle
	\section{Hello China} China is in East Asia.
	\subsection{Hello Beijing} Beijing is the capital of China.
	\subsubsection{Hello Dongcheng District}
	\paragraph{Tian'anmen Square}is in the center of Beijing
	\subparagraph{Chairman Mao} is in the center of Tian'anmen Square
	\subsection{Hello Guangzhou}
	\paragraph{Harbin Institute of Technology} is the best university in the northeast China.
\end{document}

4.加入目录

\documentclass{article}
\begin{document}
\tableofcontents
\section{Hello China} China is in East Asia.
\subsection{Hello Beijing} Beijing is the capital of China.
\subsubsection{Hello Dongcheng District}
\paragraph{Hello Tian'anmen Square}is in the center of Beijing
\subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square
\end{document}

5.数学公式

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
The Newton's second law is F=ma.

The Newton's second law is $F=ma$.

The Newton's second law is
$$F=ma$$

The Newton's second law is
\[F=ma\]

Greek Letters $\eta$ and $\mu$

Fraction $\frac{a}{b}$

Power $a^b$

Subscript $a_b$

Derivate $\frac{\partial y}{\partial t} $

Vector $\vec{n}$

Bold $\mathbf{n}$

To time differential $\dot{F}$

Matrix (lcr here means left, center or right for each column)
\[
\left[
\begin{array}{lcr}
a1 & b22 & c333 \\
d444 & e555555 & f6
\end{array}
\right]
\]

Equations(here \& is the symbol for aligning different rows)
\begin{align}
a+b&=c\\
d&=e+f+g
\end{align}

\[
\left\{
\begin{aligned}
&a+b=c\\
&d=e+f+g
\end{aligned}
\right.
\]

\end{document}

如果想用其他格式的话可以是去查看手册或者参考别人的文档

5.插入图片

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=4.00in,height=3.00in]{Model.png}
\end{document}
注:图片要和文档放在同一文件夹下面

6.插入表格

\documentclass{article}
\begin{document}
\begin{tabular}{|c|c|}
a & b \\
c & d\\
\end{tabular}

\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d\\
\hline
\end{tabular}

\begin{center}
\begin{tabular}{|c|c|}
\hline
a & b \\ \hline
c & d\\
\hline
\end{tabular}
\end{center}
\end{document}

7.中文支持

\documentclass{ctexart}
\begin{document}
你好,世界
\end{document}

只需要把开头的\documentclass{atricle}换成\documentclass{ctexart}就可以了。
如果是第一次使用ctexart的话,会自动下载和安装宏包和模板,之后就不会再下载了。


写在最后:

1.宏包
\package{}就是在调用宏包,对计算机实在外行的同学姑且可以理解为工具箱。
每一个宏包里都定义了一些专门的命令,通过这些命令可以实现对于一类对象(如数学公式等)的统一排版(如字号字形),或用来实现一些功能(如插入图片或制作复杂表格)。
通常在\documentclass之后,在\begin{document}之前,将文章所需要涉及的宏包都罗列上。
对于新人而言比较常用的宏包有

编辑数学公式的宏包:\usepackage{amsmath}和 \usepackage{amssymb}
编辑数学定理和证明过程的宏包:\usepackage{amsthm}
插入图片的宏包:\usepackage{graphicx}
复杂表格的宏包:\usepackage{multirow}

差不多了,对于新人来说,这五个宏包已经基本够用了。如果有其他的特殊需求,就通过google去寻找吧。
补充说明一下,现在ctexart模板里集成了中文支持,所以CJK宏包并不是必需品。

 


2.模板
模板就是在\documentclass{}后面的大括号里的内容。
在这一份教程中,我们使用的是LaTeX默认自带的模板article,以及中文模板ctexart。
模板就是实现我之前所介绍的LaTeX的经验总结的第二点的实现方式。
一篇文章,我们定义了section,定义了paragraph,就是没有定义字体字号,因为字体字号这一部分通常来说是在模板中实现的。
一个模板可以规定,section这个层级都用什么字体什么字号怎么对齐,subsection这个层级用什么字体什么字号怎么对齐,paragraph又用什么字体什么字号怎么对齐。当然模板里还可以包含一些自定义的口令,以及页眉页脚页边距一类的页面设置。由于模板的使用,在我的使用经验里来看,绝对不可能算是基本入门级的内容,所以在正文里当然不会提及。如果有人实在想学,如果LaTeX已经接触到这个程度上了,那么再去翻其他厚一些的教材,也不亏了。



3.参考文献和制作幻灯片
做参考文献的时候,文章也已经快写到尾声了,而幻灯片更不是进阶一些的需求。对这两个功能有需求的LaTeX user,使用LaTeX也已经相当熟练了,自己去google一下或查阅其他厚教程是很理所当然的,一点也不冤枉。
在此我就只提供两个搜索关键词,参考文献可以搜bibtex,制作幻灯片可以搜beamer。

  • 无匹配
Avatar_small
Paisabazaar Cibil Sc 说:
2022年8月08日 01:33

Transunion CIBIL who provides the CIBIL score and the credit report to the customers also has their enterprise where they allow different third-party websites like PaisaBazar to show customers their CIBIL reports. PaisaBaza is a well-known financial decision information provider service that also provides users now with CIBIL score reports that we are going to discuss further in this article. Paisabazaar Cibil Score: Check Follow the steps below to learn how to use of PaisaBazar’s official website to check your CIBIL score credit report.Many of you might hear that the CIBIL score credit report may sent to your email address timely, but that is for CIBIL paid membership. In case of free, the finest option is to use the PaisaBazar service to check your report. Subscribe to their service where they will send free CIBIL score report updates via WhatsApp directly.

Avatar_small
UK Board Model Paper 说:
2022年8月29日 21:26

Students Download Uttarakhand 10th Model Paper 2023 at Official Website Only, UBSE Announce its 10th Results in Month of Jun, High School Students across Uttarakhand Board are advised to Visit this Board page on Regular basis to get their Uttarakhand 10th Practical Exam Question Paper 2023. UK Board Model Paper so if you are also among those students who have Registered them self as a Regular or Private Student are Suggested to Download these Uttarakhand Board 10th Sample Paper 2023 must Prepare all Subjects. Model Papers are very helpfull Material that is Provided by the official education Board.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter