Latex排版教程
发布时间
阅读量:
阅读量
文章目录
LaTeX排版指南
* 3.2字体粗细宽度设置
* 3.3 字体形状设置
* 3.4字体大小设置
* * 3.4.1英文
* 3.4.2中文
* 4\. 特殊字符
* 5\. 插入图片
* * 5.1普通插图
* 5.2浮动体环境
* 6\. 表格插入
* * 6.1普通插表
* 6.2浮动体环境
* 7.公式插入
* * 7.1单行公式
* 7.2矩阵
* 7.3多行公式
* * 7.3.1居中对齐
* 7.3.2指定对齐位置
* 7.3.3带括号
* 8.版面设计
* 9.参考文献
Latex排版教程
教程来自b站–latex中文教程-15集从入门到精通包含各种latex操作
1. Latex源文件的基本结构
% 导言区 用于全局设置
\documentclass{article} % book, report, letter
\usepackage{ctex} %中文
\title{My First Document}
\author{ZhangYue}
\date{\today}
% 正文区
\begin{document}
\maketitle %输出标题
Hello World!
\end{document}
2. 大纲目录
\section{一级标题}, \subsection{二级标题}, \subsubsection{三级标题}
空行用于分割段落, \quad 用于换行, \par 也用于换行 注意命令与文字之间使用空格分隔
\chapter{章节大纲}
\tableofcontents 生成目录
3. 文字设置
3.1字体族设置
3.1.1英文
罗马字体、无衬线字体、打字机字体
\textrm{Roman Family}%在花括号内的字体都是罗马字体
\textsf{Sans Serif Family}
\texttt{Typewriter Family}
{ %括号限制作用范围
\rmfamily Roman Family\
Xiamen, located in Fujian province, is a famous coastal city. It's not only renowned for its natural beauty, but also for its modernization.
}
\sffamily Sans Serif Family %该命令下面的字体都是是无衬线字体字体,直到新的声明出现覆盖该声明。
{\ttfamily Typewriter Family\
As far as I'm concerned, Xiamen is very clean and pretty. In that city, we can enjoy clear sky, beautiful sea, and green tropical plants. I guess living there must be very pleasant.
}

3.1.2中文
{\songti 宋体}
{\heiti 黑体}
{\fangsong 仿宋}
{\kaishu 楷书}

3.2字体粗细宽度设置
\textmd{Medium Series}
\textbf{Boldface Series}
{\mdseries Medium Series}
{\bfseries Boldface Series}
3.3 字体形状设置
直立、斜体、伪斜体、大小写
\textup{Upright Shape}
\textit{Italic Shape}
\textsl{Slanted Shape}
\textsc{Small Caps Shape}
\upshape Upright Shape
\itshape Italic Shape
\slshape Slanted Shape
\scshape Small Caps Shape

3.4字体大小设置
与文档相对
3.4.1英文
{\tiny hello}\
{\scriptsize hello}\
{\footnotesize hello}\
{\small hello}\
{\normalsize hello}\
{\large hello}\
{\Large hello}\
{\LARGE hello}\
{\huge hello}\
{\Huge hello}

3.4.2中文
\subsection{中文字号}
\zihao{-0} 你好\
\zihao{5} 你好

4. 特殊字符
空白字符
- 多余的英文字串会被压缩至单一字符
- 混合体段落会自然地分隔成独立段落
- 缺失的空间会被虚拟占位符填补
a\quad b % 1em(当前字体一个M的大小)
a\qquad b % 2em
a\, b 或者 a\thinspace b % 1/6的个em
a\enspace b % 0.5em
控制符
%转义字符 其中‘\’ 用\textbackslash
\# \$ \% \{ \} \~{} \_{} \^{} \& \textbackslash
引号
` ' %单引号
`` " %双引号

该博客对《LaTeX学习系列之—LaTeX的特殊字符》一文进行了深入阐述,并提供了丰富的细节。
5. 插入图片
5.1普通插图
\usepackage{graphicx} %导入图片的宏包
\graphicspath{{figures/},{pics/}} %图片搜索路径
%includegraphics[<选项>]{<文件名>}
%格式:EPS PDF PNG JPEG BMP
\includegraphics[scale=0.1]{IMG_1148}
将图像缩放为0.3倍尺寸
指定图片高度为3厘米
设定图像宽度为100点
设置为相对于文本的高度
设定为与文本宽度相当
旋转-45度
在设置多个参数时,请使用逗号分隔各参数名称
5.2浮动体环境
浮动体就是会移动的文本框
如图\ref{fig:fig-fudong}所示 %交叉引用
\begin{figure}[htbp]
\centering %居中排版
\includegraphics[scale=0.1]{IMG_1148.JPG}
%标题和标签
\caption{浮动图}\label{fig:fig-fudong}
\end{figure}
\ref交叉引用可用于公式、表格以及图片等元素的位置标注。\n\n在代码所在的上下文中:\n\n- h表示当前位置\n\n- t表示页面顶部\n\n- b表示页面底部\n\n- p表示独立成页的位置
6. 表格插入
6.1普通插表
设置宽度:p{宽度值},内容超过宽度时,自动换行
\begin{tabular}{l|c c c||r} %l 左, c 居中, r 对齐; | 竖线, || 双竖线
1 & 2 & 33333333333333 & 4 & 5\
1 & 2 & 3 & 4 & 5\
\hline %横线
1 & 2 & 3 & 4 & 5\
\hline \hline %双横线
1 & 2 & 3 & 4 & 5\
1 & 2 & 3 & 4 & 5
\end{tabular}

6.2浮动体环境
\usepackage{bigstrut,multirow,rotating}
\usepackage{booktabs}
\usepackage[table ]{ xcolor}
\begin{table}[htbp]
\centering
\begin{tabular}{lrrrr}
\toprule
& \multicolumn{2}{c}{a} & \multicolumn{2}{c}{b} \
& \multicolumn{1}{l}{type1} & \multicolumn{1}{l}{type2} & \multicolumn{1}{l}{type3} & \multicolumn{1}{l}{type4} \
\midrule
sn & 2.35 & 2.69 & 7.34 & 5.48 \
sp & 6.32 & 5.32 & 9.13 & 7.46 \
\bottomrule
\end{tabular}%
\caption{Add caption1}\label{tab:addlabel1}
\end{table}%
\begin{table}[htbp]
\centering
\begin{tabular}{crrrrr}
\toprule
& & \multicolumn{1}{l}{type1} & \multicolumn{1}{l}{type2} & \multicolumn{1}{l}{type3} & \multicolumn{1}{l}{type4} \
\midrule
\multirow{2}[1]{*}{sn} & 1 & 2.35 & 2.69 & 7.34 & 5.48 \
& \cellcolor[rgb]{ .906, .902, .902} 2 & \cellcolor[rgb]{ .906, .902, .902} 2.35 & \cellcolor[rgb]{ .906, .902, .902} 2.69 & \cellcolor[rgb]{ .906, .902, .902} 7.34 & \cellcolor[rgb]{ .906, .902, .902} 5.48 \
\multirow{2}[1]{*}{sp} & 3 & 6.32 & 5.32 & 9.13 & 7.46 \
& \cellcolor[rgb]{ .906, .902, .902} 4 & \cellcolor[rgb]{ .906, .902, .902} 6.32 & \cellcolor[rgb]{ .906, .902, .902} 5.32 & \cellcolor[rgb]{ .906, .902, .902} 9.13 & \cellcolor[rgb]{ .906, .902, .902} 7.46 \
\bottomrule
\end{tabular}
\caption{Add caption2}\label{tab:addlabel2}
\end{table}%

7.公式插入
7.1单行公式
\usepackage{amsmath}
\usepackage{amssymb}`
\begin{equation} %产生带编号的公式
f(x)=a+b
\label{eq:eq1}
\end{equation}
\begin{equation}
f(x)=a-b
\label{eq:eq2}
\end{equation}
%一个公式的多行排版, & 对齐位置
\begin{equation}
\begin{split}
\cos 2x &= \cos^2 x -\sin^2 x\
&= 2\cos^2 x - 1
\end{split}
\end{equation}
\begin{equation*}产生不带编号的公式

7.2矩阵
\begin{equation}
\left[ \begin{matrix}
a& b& \cdots& d\
& a& \cdots& d\
& & \ddots& \vdots\
0& & & d\
\end{matrix} \right]
\end{equation}
\begin{pmatrix}
a& b& \cdots& d\
& a& \cdots& d\
& & \ddots& \vdots\
0& & & d\
\end{pmatrix}
\[
\begin{bmatrix}
a& b& \cdots& d\
& a& \cdots& d\
& & \ddots& \vdots\
0& & & d\
\end{bmatrix}
\begin{Bmatrix}
a& b& \cdots& d\
& a& \cdots& d\
& & \ddots& \vdots\
0& & & d\
\end{Bmatrix}
\begin{vmatrix}
a& b& \cdots& d\
& a& \cdots& d\
& & \ddots& \vdots\
\text{\huge 0}& & & d\
\end{vmatrix}
\begin{Vmatrix}
a& b& \cdots& d\
& a& \cdots& d\
& & \ddots& \vdots\
\text{\large 0}& & & d\
\end{Vmatrix}
\]

这是行内小矩阵
\begin{math}
\left(
\begin{smallmatrix}
x & -y \ y & x
\end{smallmatrix}
\right)
\end{math}

7.3多行公式
7.3.1居中对齐
\begin{gather}
a + b = b + a\
a - b = c
\end{gather}
%gather带编号,gather*不带编号
\begin{gather*}
a + b = b + a\
a - b = c
\end{gather*}
7.3.2指定对齐位置
\begin{align}
x &= t + \cos t + 1\
y &= 2\sin t
\end{align}

7.3.3带括号
\begin{equation}
D\left( x \right) =\left\{ \begin{array}{l}
1,if\ x>0\
0,if\ x<0\
\end{array} \right.
\end{equation}

8.版面设计
1.纸张大小的设置
\usepackage{geometry}
%\geometry{papersize={宽, 高}}
\geometry{papersize={20cm, 15cm}}
2.边距的设置
\usepackage{geometry}
%\geometry{left=左边距,right=右边距,top=上边距,bottom=下边距}
\geometry{left=5cm,right=5cm,top=5cm,bottom=5cm}
3.页眉页脚的设置
\usepackage{fancyhdr}
\pagestyle{fancy}
%设置页眉
\lhead{页眉左}
\chead{页眉中}
\rhead{页眉右}
%设置页脚
\lfoot{左页脚}
\cfoot{中页脚}
\rfoot{右页脚}
4.横分割线的设置
%\renewcommand{\headrulewidth}{上分割线的宽度}
%\renewcommand{\headwidth}{\textwidth}
%\renewcommand{\footrulewidth}{下分割线的宽度}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\headwidth}{\textwidth}
\renewcommand{\footrulewidth}{0.4pt}
5.行间距与段间距
\usepackage{setspace}
\onehalfspacing %命令:设置行间距,1.5倍
%设置段落间距
%\addtolength{\parskip}{宽度}
%导言区
\usepackage{geometry} %导入版面设置的宏包
\usepackage{fancyhdr} %导入页眉页脚需要的宏包
\pagestyle{fancy}
\usepackage{setspace} %行间距所用的包
\geometry{papersize={20cm, 15cm}} %设置纸张的大小
\geometry{left=2cm,right=5cm,top=5cm,bottom=5cm}%设置边距
%设置页首
\lhead{张一根}
\chead{理工大学}
\rhead{\today}
%设置页眉
\lfoot{左页脚}
\cfoot{\thepage}
\rfoot{右页脚}
%设置横线分割的宽度
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\headwidth}{\textwidth}
\renewcommand{\footrulewidth}{0.4pt}
\onehalfspacing %设置行间距,1.5倍
\addtolength{\parskip}{0.4em} %设置段落间距
%正文区
\begin{document}
秋风用时光的旋律,...,渲染得天地间空旷而又阳刚。
酷热的夏天刚刚过去,...说上一晚悄悄话。
\end{document}

9.参考文献
把所以的参考文献放在一个后缀名为.bib的文件里
\bibliographystyle{plain} %在导言区需要导入
%再在需要导入文献的地方,使用
\cite{标签名}
\bibliography{test.bib} %在文字末尾使用
全部评论 (0)
还没有任何评论哟~
