准备写论文了,需要用到latex,特次文章与大家分享下。
latex 一般是发表国外的高质量文章的工具,确实很好用,目前也只是刚入手,写点学到的东西,做个备忘。
安装Latex,我安装的tex live 2016,这个还是比较好用的。(链接:http://pan.baidu.com/s/1slyGimx 密码:8trb)
安装后,使用Teworks,这个编辑器还是不错的,
基本用法:
样例:
%这是一个.tex文件
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{宋体}
\begin{document}
\section{hello china}
\qquad china is in east asia,世界,你好。
\subsection{hello Sichuan} Sichuan is the city of China
\end{document}
一般的结构:
\documentclass{article}
\begin{document}
………………(内容)
\end{document}
语法:
注释:%
退格(一格):\quad
退格(两格):\qquad
一级标题:\section{title}
二级标题:\subsection{title}
二级标题:\subsubsection{title}
段落(两格):\subparagraph
生成目录:\tableofcontents %%这个很方便,我很喜欢
增加安装包:\usepackage{name} ps:name:xeCJK
设置中文字体:\setCJKmainfont{字体名} ps:宋体,前提你的电脑已经安装了该字体
数学公式:
F=ma
$F=ma$
$$F=ma$$
\[F=ma\]
斜体:$\eta$ $\mu$
Fraction $\frac{a}{b}$ ps: a/b
Power $a^b$ ps: a的b次方
Subscript $a_b$ ps: a 下标为b
Vector $\vec{n}$ ps:向量n
$\dot{F}$ ps:F上加小圆点
矩阵:
\[
\left[
\begin{arrary}{lcr}
a1 & b2 & c3 \\
d4 & e5 & f6 \\
d4 & e5 & f6
%j加空行没有问题 注意语法 \[ \]、\left[ \right]、\\、\begin{arrary} \end{arrary} ,参数:lcr 这些一个不能少,本质上矩阵就是数组arrary
\end{arrary}
\right]
\]
插入图片:
加入\usepackage{graphicx}
这个需要用eps格式的,方法:进入cmd 执行命令:bmeps -c …/1.png …/1.eps
\includegraphics[width=4.00in,height=3.00in]{*.eps}
插入表格:
\begin{tabular}{|c|c|}
a & b \\
c & d \\
\end{tabular}
%加入横线hline
\begin{tabular}{|c|c|}
\hline
a & b \\
\hline
c & d \\
\hline
\end{tabular}
%居中center在最开始前后加入\begin{center} \end{center} 即可
附录(学习时,写的):
% 这是一个.tex文件
%latex hello_world(.tex)
%导言区
\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{xeCJK}
\usepackage{amsmath}
\usepackage{amssymb}
\setCJKmainfont{宋体}
\begin{document}
%add to \tableofcontents
\tableofcontents
\section{hello china}
\quad China is in east asia,世界,你好。
\subsection{hello Sichuan}
\quad Sichuan is the province of China
\subsubsection{hello Mianyang}
\quad Mianyang is the city of Sichuan
%\paragraph{Tian'anmen Square} is in the center of Beijing.
\subparagraph{Southwest University of Science and Technology}is the pretty university of Sichuan.
\section{hello Ameria}
\quad Sichuan is the province of China
\subsection{hello New York}
\quad New York is the city of Ameria
%\paragraph{Tian'anmen Square} is in the center of Beijing.
\subparagraph{Southwest University of Science and Technology}is the pretty university of Sichuan.
\subparagraph{ } 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$
Vector $\vec{n}$
Bold $\mathbf{n}$
To time differential $\dot{F}$
Matrix (1cr here means left,center or right for each column
\[
\left[
\begin{array}{lcr}
a1 & b2 & c3 \\
d4 & e5 & f6 \\
d4 & e5 & f6
%j加空行没有问题 注意语法 \[ \]、\left[ \right]、\\、\begin{arrary} \end{arrary} ,参数:lcr 这些一个不能少,本质上矩阵就是数组arrary
\end{array}
\right]
\]
Equations(here \& is 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]
\]
\centering
\includegraphics[width=4.00in,height=3.00in]{11.eps}
%表格
\begin{tabular}{|c|c|}
a & b \\
c & d \\
\end{tabular}
\quad
\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}