理解性小知识
1.在Latex中,空一行和空两行一样,最后编译出来都是空一行
基础符号
\documentclass{article} % 设置文档
\title{\Huge Section1}
\date{\large 2021-12-06}
\author{\large Chen JX}
\ % 表示后面的是一个指令
{} % 表示的环境
\begin{document} % 主体的开始
\pagenumbering{gobble} % 不显示页码
\maketitle % 显示之前设置的title,否则不会显示
\newpage % 新建一页
\pagenumbering{roman} %
\section{ } % 一个小节的主标题
\subsection{ } % 一个小节的副标题
\\ % 空行
\hspace*{0.6cm} % 空一定的距离
\quad % 空格
\noindent % 取消缩进
\end{document} % 主体的结束
配置环境
1.我喜欢的整体排版
\documentclass{article}
\usepackage{geometry} % 设置页边距
\geometry{a4paper,scale=0.76}
\usepackage{setspace} % 设置行间距和段间距
\setlength{\baselineskip}{20pt}
\setlength{\parskip}{3pt}
\usepackage{titlesec} % 设置标题的距离
\titlespacing*{\section}{0pt}{1.2ex plus .0ex minus .0ex}{.3ex plus .0ex}
\titlespacing*{\subsection}{0pt}{1.2ex plus .0ex minus .0ex}{.3ex plus .0ex}
\usepackage{ctex} % 语言环境
2.配置代码环境
\usepackage{xcolor}
\usepackage{listings}
\lstset{%
alsolanguage=Java,
%alsolanguage=[ANSI]C, %可以添加很多个alsolanguage,如alsolanguage=matlab,alsolanguage=VHDL等
alsolanguage= matlab,
alsolanguage= XML,
tabsize=4, %
frame=shadowbox, %把代码用带有阴影的框圈起来
commentstyle=\color{red!50!green!50!blue!50},%浅灰色的注释
rulesepcolor=\color{red!20!green!20!blue!20},%代码块边框为淡青色
keywordstyle=\color{blue!90}\bfseries, %代码关键字的颜色为蓝色,粗体
showstringspaces=false,%不显示代码字符串中间的空格标记
stringstyle=\ttfamily, % 代码字符串的特殊格式
keepspaces=true, %
breakindent=22pt, %
numbers=left,%左侧显示行号 往左靠,还可以为right,或none,即不加行号
stepnumber=1,%若设置为2,则显示行号为1,3,5,即stepnumber为公差,默认stepnumber=1
%numberstyle=\tiny, %行号字体用小号
numberstyle={\color[RGB]{0,192,192}\tiny} ,%设置行号的大小,大小有tiny,scriptsize,footnotesize,small,normalsize,large等
numbersep=8pt, %设置行号与代码的距离,默认是5pt
basicstyle=\footnotesize, % 这句设置代码的大小
showspaces=false, %
flexiblecolumns=true, %
breaklines=true, %对过长的代码自动换行
breakautoindent=true,%
breakindent=4em, %
aboveskip=1em, %代码块边框
tabsize=2,
showstringspaces=false, %不显示字符串中的空格
backgroundcolor=\color[RGB]{245,245,244}, %代码背景色
%backgroundcolor=\color[rgb]{0.91,0.91,0.91} %添加背景色
escapeinside=``, %在``里显示中文
%% added by http://bbs.ctex.org/viewthread.php?tid=53451
fontadjust,
captionpos=t,
framextopmargin=2pt,framexbottommargin=2pt,abovecaptionskip=-3pt,belowcaptionskip=3pt,
xleftmargin=4em,xrightmargin=4em, % 设定listing左右的空白
texcl=true,
% 设定中文冲突,断行,列模式,数学环境输入,listing数字的样式
extendedchars=false,columns=flexible,mathescape=true}
% numbersep=-1em
引用代码方式
\lstinputlisting[language=matlab]{Morris_random.m}
我觉得这个真的是特别的方便了,因为代码改了直接重新编译latex就可以,不用修改正文!
3.配置图片环境
\usepackage{graphicx}
\usepackage{caption,subcaption}
图片
单张图片
\begin{figure}[h!]
\centering
\includegraphics[scale=0.32]{set.jpg}
\caption{距离集合化网络}
\label{set}
\end{figure}
很多图片
\begin{figure}[h!]
\centering
\subcaptionbox{\label{1}}{\includegraphics[width = .48\linewidth]{process1.jpg}}\hfill
\subcaptionbox{\label{2}}{\includegraphics[width = .48\linewidth]{process2.jpg}}
\subcaptionbox{\label{3}}
{
\includegraphics[width = .48\linewidth]{process3.jpg}}
\subcaptionbox{\label{4}}
{
\includegraphics[width = .48\linewidth]{process4.jpg}}
\caption{矩阵构建过程}
\label{process}
\end{figure}
可以用 \ref {} 的形式完成对于图片的引用。