latex学习笔记

latex学习笔记

一.操作LaTeX

1.1软件的安装

软件:texstudio

1.2cmd实现对LateX文档的编写

  1. 新建一个tex文档
notepad test.tex
  1. 使用notepad编写

因为有自动补全功能比记事本好很多

documentclass{article}

egin{document}
Hello LaTeX

end{document}
  1. cmd编译tex

1.2.1使用latex

latex test.tex

  1. 操作.dvi文件,转换为pdf文件
dvipdfmx test.dvi
  1. 生成了pdf文件

1.2.2使用xelatex

xelatex test.tex

1.2.3打包命令为bat文件?

  1. 新建一个bat文件
cd.>build_pdf.bat
  1. 编写dat

del是删除

2.3.1latex

cd F
cd F:filelatex_fileexLatex_learn_cmd
latex test.tex
dvipdfmx test.dvi
del *.aux *.dvi *.log

2.3.2xelatex

F:filelatex_fileexLatex_learn_cmd
cd F
cd F:filelatex_fileexLatex_learn_cmd
xelatex test.tex
del *.aux *.dvi *.log

1.2.4使用不了中文?

  1. 使用utf-8编码

(1) 使用记事本的另存为改变为uft-8编码

(2)在tex里面设置

documentclass[11pt,UTF8,twoside,a4paper]{article}
  1. 引入宏包与文件类型
documentclass[11pt,UTF8,twoside,a4paper]{article}
usepackage{ctex}   %中文

1.3texstudio

1.3.1快捷键

F5到F9

二.LaTeX基础

2.1源文件的基本结构

%注释的内容
%导言区
documentclass[11pt,UTF8,a4paper]{article}
%book,report,letter


usepackage{ctex}%中文包

%标题页
	itle{My First Document}%标题
author{lim}%作者
date{	oday}%日期


%正文区
egin{document}
	maketitle 	%输出标题  
	
	你好,LaTeX
	
	Let $f(x)$ be defined by the formula $f(x)=3x^2+2x-1$
	
	$$y=1$$
end{document}

2.2中文和数学公式

2.2.1设置中文

  1. 设置默认编译器

  2. 设置utf-8模式

  1. texstudio设置utf-8

这个是源文件的格式

  1. 引入宏包
usepackage{ctex}%中文包

2.2.2打开Ctex宏包手册

2.2.3设置文档类宏包

%使用文档类宏包
documentclass[11pt,UTF8,a4paper]{ctexart}
%ctexart,ctexrep,ctexbook
%就不用以下
%usepackage{ctex}%中文包
%documentclass[11pt,UTF8,a4paper]{article}

2.3字体和字号设置

2.3.1字体属性

2.3.2字体族

%字体族的设置
%罗马数字,无衬线字体,打印机字体
%两种格式
%	extrm{文字}
%
mfamily   后面的文字都是这个字体
%罗马字体
	 	extrm{Roman Family}
	 
	 
mfamily Roman Family
%无衬线字体

	 	extsf{Sans Serif Family}
	 
	 sffamily Sans Serif Family
%打印机字体

	 	exttt{Typewriter Family}
	 
		tfamily Typewriter Family	

2.3.3粗细宽度

%字体系列设置
%粗细,宽度

	extmd{Medium Series}
{mdseries Medium Series}

	extbf{Boldface Series}
{fseries Boldface Series}

2.3.4字体形状

%字体形状设置
%直立,斜体,伪斜体,小型大写
%直立

	extup{Upright Shape}
{upshape Upright Shape}

%斜体
	extit{Italic Shape}
{itshape Italic Shape}

%伪斜体
	extsl{Slanted Shape}
{slshape Slanted Shape}

%小型大写
	extsc{Small Caps Shape}
{scshape Small Caps Shape} 

2.3.5中文字体

%中文字体设置
%宋体
{songti 宋体}

%黑体
{heiti 黑体}

%仿宋体
{fangsong 仿宋}

%楷书
{kaishu 楷书}

2.3.6中文的粗体斜体

%中文的粗体和斜体
%粗体
	extbf{粗体}

%斜体
	extit{斜体}

2.3.7字体大小

%字体大小设置
%这是相对的大小
%在文档的导言区设置字体大小,10磅
%只有10,11,12磅
%documentclass[10pt]{article}

{	iny Hello}\
{scriptsize Hello}\
{footnotesize Hello}\
{small Hello}\
{
ormalsize Hello}\
{large Hello}\
{Large Hello}\
{LARGE Hello}\
{huge Hello}\
{Huge Hello}\

2.3.8中文字号

%中文字号
%-表示是小
%-4表示小四号
%可以定义一个命令
%
ewcommand{myfont}{	extif{	extbf{	extsf{Fancy Text}}}}
zihao{-0} 你好!

zihao{-4} 你好!

myfont  

三.文章结构

3.1基础文档结构

%文章的基本结构
%带章节的大纲
%chapter{绪论}
section{引言}
subsection{子小节}
subsubsection{下下小节}
subsection{子小节}
%chapter{结果}
section{方法}
subsection{子小节}
subsubsection{下下小节}

%进行换行
%\
%par
%空行

3.2设置目录与标题

%输出标题	
	maketitle 
%输出目录
	ableofcontents

3.3设置标题的格式

%设置标题的格式
CTEXsetup[
format+={zihao{1}heiti      
aggedbottom},
name = {,、},
number = chinese{section},
beforeskip = 1.0ex plus 
	0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = hspace{0pt}	
]{section}


CTEXsetup[
format+={zihao{5}         heiti      
aggedbottom},
name = {,.},
number = arabic{section} 
arabic  {subsection},
beforeskip = 1.0ex plus 
0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = hspace{0pt}	
]{subsection}

四.特殊字符

4.1空格

  1. 空行分段,多个空行就是1个
  2. 自动缩进,不能使用空格代替
  3. 英文中多个空格处理为1个空格,中文中的空格将被忽略
  4. 汉字与其他字符的间距会自动由Xelatex处理
  5. 禁止使用中文的全角空格
% 1.空格

% 1em,当前字体M的宽度
aquad b

% 2em
aqquad b

% 约1/6各em
a\,b    a	hinspace b

%0.5个em
aenspace b

%空格
a b

%硬空格
a~b

% 1pc=12pt=4.218mm
akern 1pc b

akern -1em b

ahskip 1em b

%占位宽度
ahphantom{xyz}b

% 弹性宽度
ahfill b

4.2控制符

%2. 控制符
# $  \% {   }   

~{} \_{}  ^{} &

%这是反斜杠/
	extbackslash

4.3标志和特殊符号

%3. Tex 标志符号
TeX{}   LaTeX{}    LaTeXe{}

%4.排版特殊符号?
S P  dag ddag  copyright pounds

4.4引号

% 5.引号
` ' `` '' ``你好''
    ``双引号''
`单引号'

五.图片

5.1插入宏包

%语法
%includegraphics[<选项>]{<文件名>}
%格式
%EPS,PDF,PNG,JPEG,BMP
%插入图片的宏包
usepackage{graphicx}
%图片在当前目录下的figures文件夹
graphicspath{{figures/}}

5.2代码实现

%使用图片
%指定缩放因子
includegraphics[scale=0.3]{Screenshot1}

%指定高度
includegraphics[height=10cm]{Screenshot1}

includegraphics[height=0.1	extheight]{Screenshot1}


%指定宽度
includegraphics[width=10cm]{Screenshot1}

includegraphics[width=0.1	extwidth]{Screenshot1}


%指定旋转角度
includegraphics[
angle=-45,
width=0.1	extwidth
]{Screenshot1}

includegraphics[
angle=85,
width=0.1	extwidth
]{Screenshot1}

六.表格

6.1基础表格

%表格
%对齐方式   
%l 左对齐   
%c 居中对齐
%r 右对齐
%p{1.5cm}  指定宽度的格子
% |是表格的竖线
% hline 是表格的横线
% hline hline 是双横线
% || 是双竖线
egin{tabular}{|l|| c |c| c| p{1.5cm}|}
	hline
	姓名&语文&数学&外语&备注\
	hline  hline
	刘津志&105&150&135&666\
	hline
end{tabular}

七.浮动体

7.1导入包

%浮动体禁止浮动
%避免浮动体跨过 section
usepackage[section]{placeins}
%禁止浮动
usepackage{float}

7.2代码分析

%浮动体

%设置相对引用,跳到这个图
见图
ef{fig-图1}
egin{figure}[htbp]%浮动体的排版对值
	centering %居中
	includegraphics[scale=0.3]{Screenshot1}
	caption{图1}%标题
	label{fig-图1}%设置标签
end{figure}

见表
ef{tab-表1}
egin{table}[H]
	centering %居中
	caption{表1}%标题
	label{tab-表1}
	egin{tabular}{|l|| c |c| c| p{1.5cm}|}
		hline
		姓名&语文&数学&外语&备注\
		hline  hline
		刘津志&105&150&135&666\
		hline
	end{tabular}
end{table}


八.数学公式

8.1基本

%数学公式
%格式1
$a+b=b+a$

%格式2,行内公式
(a+b=b+a)

%格式3
egin{math}
	a+b=b+a
end{math}

%格式4和上下标
$$3x^{20}_{11}-x_{11}+2=0$$


%格式5,行间公式
[x+1=2]

%格式6 ,行间公式

egin{displaymath}
	x+1=2 label{eq:eq1}
end{displaymath}


% 这两个是为了按章节编号
usepackage{amsmath}

umberwithin{equation}{section}


% 格式7	带编号的数学环境,行间公式
见公式
ef{eq:eq1}
egin{equation}
x+1=2 label{eq:eq1}
end{equation}

%格式8,不带编号

见公式
ef{eq:eq2}
egin{equation*}
x+1=2 label{eq:eq2}
end{equation*}

%希腊字母
$alpha$
$eta$
$gamma$
$epsilon$
$pi$
$omega$
$Gamma$
$Delta$
$Theta$
$Pi$
$Omega$

%数学函数
$log$
$sin$
$cos x$
$arcsin$
$arccos$
$ln x$
$log_2 x$
$sqrt{2}$
$sqrt[4]{x}$%指定开方的次数
$frac{2}{x}$

	

8.2矩阵

%矩阵

%无括号
[
	egin{matrix}
	0 & 1\
	1& 0 
	end{matrix}qquad
%小括号
egin{pmatrix}
0 & 1\
1& 0 
end{pmatrix}	qquad
%中括号
egin{bmatrix}
0 & 1\
1& 0 
end{bmatrix}qquad
%大括号
egin{Bmatrix}
0 & 1\
1& 0 
end{Bmatrix}qquad
%单竖线
egin{vmatrix}
0 & 1\
1& 0 
end{vmatrix}qquad
%双竖线
egin{Vmatrix}
0 & 1\
1& 0 
end{Vmatrix}
]

%常用的省略号
%dots vdots ddots
%矩阵的下标
%_{n 	imes n}
[
	A = egin{bmatrix}
	a_{11}&dots &a_{1n}\
	vdots&ddots &vdots \
	0  & dots &a_{nn} 
	end{bmatrix}_{n 	imes n}
]
原文地址:https://www.cnblogs.com/ddelicacy/p/14401667.html