Latex常用命令

Latex安装教程(Texlive和TexStudio)和辅助插件

更新中……


一、Latex基本结构

1.1 导言区

导言区:对全局进行设置。

\documentclass{article} % 文本类型:book、report、letter……
\usepackage{ctex}  % 引入ctex宏包,中文包

\title{\heiti 我的文章标题}  % 黑体
\author{\kaishu 张三}  % 楷书
\date{\today}

1.2 正文区

正文区:对文档进行编写。

\begin{document}  % 只能有一个document环境
	\maketitle
	你好,\LaTeX
	\begin{equation}  % 用于产生带编号的行间公式
		AB^2 = BC^2 + AC^2  
	\end{equation}
\end{document}

二、字体设置

在Latex中,一个字体有五种属性:字体编码、字体族、字体系列、字体形状、字体大小 。

% 导言区
\documentclass {article}
\usepackage{ctex} 


% 正文区
\begin{document}  % 只能有一个document环境
	% 字体族设置(罗马字体、无衬线字体、打字机字体)
	\textrm{Roman Family 罗马字体}
	\textsf{Sans Serif Family 无衬线字体}
	\texttt{Typewriter Family 打字机字体}
	
	{\rmfamily Roman Family 罗马字体}  
	{\sffamily Sans Serif Family 无衬线字体}
	{\texttt Typewriter Family 打字机字体}
	
	% 字体系列设置(粗细、宽度)
	\textmd{Medium Series}
	\textbf{Boldface Series}
	
	{\mdseries Medium Series}
	{\bfseries Boldface Series}
	
	% 字体形设置(直立、斜体、伪斜体、小型大写)
	\textup{Upright Shape}
	\textit{Italic Shape}
	\textsl{Slanted Shape}
	\textsc{Small Capse Shape}
	
	{\upshape Upright Shape}
	{\itshape Italic Shape}
	{\slshape Slanted Shape}
	{\scshape Small Caps Shape}
	
	% 中文字体
	{\songti 宋体}
	{\heiti 黑体}
	{\fangsong 仿宋}
	{\kaishu 楷体}
	
	{\textbf{粗体}}
	{\textit{斜体}}
	
	% 字体大小
	{\tiny Hello}\\
	{\scriptsize Hello}\\
	{\footnotesize Hello}\\
	{\small Hello}\\
	{\normalsize Hello}\\
	{\large Hello}\\
	{\Large Hello}\\
	{\LARGE Hello}\\
	{\huge Hello}\\
	{\Huge Hello}\\
	
\end{document}

ctex中文字体设置的细节在ctex宏包手册(上面介绍了怎么打开该文档)中的第五节。

三、文档基本结构

小节:section、subsection、subsubsection
目录:tableofcontents
在这里插入图片描述

% 导言区
\documentclass {article}
\usepackage{ctex} 

% 正文区
\begin{document} 
	\tableofcontents
	
	\section{引言}
	大盘鸡掉怕我哈佛iaehfoiaehfoueashf发呢肤色暗访双方的违法威风威风肺癌搜房网微风撒冯绍峰五位粉丝方法
	
	的阿峰按省份按双方威风威风色粉微风撒冯绍峰二分法峰峰我是个如果认购的人生观代人受过热带水果二个人第三个人工让国人
	\section{实验方法}
		\subsection{数据}
			\subsubsection{数据1}
			\subsubsection{数据2}
		\subsection{图标}	
	\section{实验结果}
	\section{结论}
	\section{致谢}
\end{document}

参考:https://www.bilibili.com/video/BV15x411j7k6?p=5

四、特殊符号

参考:https://www.bilibili.com/video/BV15x411j7k6?p=6

4.1 换页

换页:\newpage

4.2 换行

换行:\\

4.3 空一行

空一行:~\\

4.4 条目编号

条目编号:

\begin{itemize}
	\item[1)] xxx
	
	\item[2)] xxx
	
	\item[3)] xxx
	
	\item[4)] xxx
\end{itemize}

效果:
在这里插入图片描述

五、插图

参考:https://www.bilibili.com/video/BV15x411j7k6?p=7

5.1 插入一张图片

需要引入的包:\usepackage{graphicx}

\begin{figure}[h]  % h代表固定位置
	\centering  % 表示图片居中
	\includegraphics[scale=0.5]{figur/Figure_1.png}  % [scale=0.5]表示图像缩放0.5;{figure_SVM/Figure_3.png}图像在项目内的目录。
	\caption{图片的名称}
	\label{引用时使用的标签}	
\end{figure}

5.2 插入并列图片

需要引入的包:

\usepackage{graphicx}
\usepackage{subfigure}

引入图片的代码:

\begin{figure}[h]
	\begin{center}
		\subfigure[图1的名称]{
			\includegraphics[scale=0.38]{figur/1.png}
		}
		\subfigure[图2的名称]{
			\includegraphics[scale=0.38]{figur/2.png}
		}
		\caption{总体的名称}
		\label{标签}
	\end{center
\end{figure}

效果图如下:
在这里插入图片描述

六、表格

参考:https://www.bilibili.com/video/BV15x411j7k6?p=8

七、浮动体

实现灵活分页,避免无法分割的内容产生的页面留白;给图标添加标题;交叉引用等。

参考:https://www.bilibili.com/video/BV15x411j7k6?p=9

八、数学公式

参考:
简单数学公式:https://www.bilibili.com/video/BV15x411j7k6?p=10
矩阵:https://www.bilibili.com/video/BV15x411j7k6?p=11
多行公式:https://www.bilibili.com/video/BV15x411j7k6?p=12

九、参考文献

BibTex:https://www.bilibili.com/video/BV15x411j7k6?p=13
BibLatex:https://www.bilibili.com/video/BV15x411j7k6?p=14

十、插入代码

10.1 插入Matlab代码

1 下载宏包

首先需要下载M-code LaTeX Package,进入网站点击Download。

在这里插入图片描述
将下载好的mcode.sty放在项目.tex文件所在目录下。

2 使用

在tex文件内的导言区内使用mcode声明
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

在正文中添加代码

\begin{lstlisting}
    content...
\end{lstlisting}

10.2 插入Python代码

在Latex中插入Python代码,需要一个第三发的宏包pythonhighlight

1 下载宏包

下载链接Github

将下载好的pythonhighlight.sty放在项目.tex文件所在目录下。

2 使用

在tex文件内的导言区内需要使用pythonhighlight声明
\usepackage{pythonhighlight}

在正文中添加代码

\begin{python}
    content..	
\end{python}
  • 4
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

望天边星宿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值