一、常用LaTex功能总结
设备:Macbook pro 15款
软件:TexStudio
%A4纸大小,文档类型
\documentclass[a4paper]{article}
%中文字体包\usepackage{xeCJK}
%默认字体
\setmainfont{Times New Roman}\setCJKmainfont{宋体-简}
\setCJKfamilyfont{Heiti}{黑体-简} %黑体 Heiti
\newcommand{\Heiti}{\CJKfamily{Heiti}} %新建命令:用Heiti表示黑体
\setCJKfamilyfont{Simsun}{宋体-简} %宋体 Simsuni
\newcommand{\Simsun}{\CJKfamily{Simsun}}
%字号设置
\newcommand{\chuhao}{\fontsize{42pt}{\baselineskip}\selectfont} %初号\newcommand{\xiaochuhao}{\fontsize{36pt}{\baselineskip}\selectfont} %小初号
\newcommand{\yihao}{\fontsize{28pt}{\baselineskip}\selectfont} %一号
\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont} %二号
\newcommand{\xiaoerhao}{\fontsize{18pt}{\baselineskip}\selectfont} %小二号
\newcommand{\sanhao}{\fontsize{15.75pt}{\baselineskip}\selectfont} %三号
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont}% 四号
\newcommand{\xiaosihao}{\fontsize{12pt}{\baselineskip}\selectfont} %小四号
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont} %五号
\newcommand{\xiaowuhao}{\fontsize{9pt}{\baselineskip}\selectfont} %小五号
\newcommand{\liuhao}{\fontsize{7.875pt}{\baselineskip}\selectfont} %六号
\newcommand{\qihao}{\fontsize{5.25pt}{\baselineskip}\selectfont} %七号
%设置每页上下左右页间距
\usepackage{geometry}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
%使用行间距
\usepackage{setspace}
\begin{spacing}{1.3} %1.5倍行距
\end{spacing}
%表格
\usepackage{makecell}
\begin{tabular}{|r|r|r|}
\hline
\makecell{函数名} & \makecell{功能简介} \\ \hline
initKeyMapping & 初始化关键字 \\
initOperMapping & 初始化操作符 \\
\hline
\end{tabular}
%列表
\usepackage{enumitem}
\setenumerate[1]{itemsep=0pt,partopsep=0pt,parsep=\parskip,topsep=2pt}
\begin{enumerate}
\item 第一点
\item 第二点
\item 第三点
\item 第四点
\end{enumerate}
\setlength{\itemsep}{0.5ex} %条目间距
%图片
\usepackage{graphicx}
%将图片放入.tex文件夹中,按顺序或者内容命名(建议)
%htbp是比较好的插入方式,如果还是放不下或者位置不对,最好调整width=0.6\textwidth,像word放不下一样的策略
\centering
%放不下时调整width=0.6\textwidth,{1}为图片名字,不用带.jpg/.png等
\includegraphics[width=0.6\textwidth]{1}
\caption{测试程序} %图片下标名字
\label{fig:1}
\end{figure}
% 添加首行缩进,两个字符
\usepackage{indentfirst}
\setlength{\parindent}{2em}
%该行不缩进
\noindent
%强制缩进!
\par\setlength\parindent{2em}此处为另起一段的新内容
%代码插入
\usepackage{listings}
\begin{lstlisting}[ language=C]
%代码,可以直接打{}
%有自动缩进
\end{lstlisting}
%目录
\tableofcontents \newpage %内容在新的一页中
%分段
\section{\Heiti\sihao 第一章}
\subsection{\Heiti\wuhao 1.1}
%数学符号表示,加$$
$\rightarrow$
%加粗
\textbf{加粗}
%双引号表示,注意要用``波浪号位置,不应像平时输入中文一样的""符号
``''
%左右大括号表示加反斜杠
\{\\
\}
%各种距离设置
\setlength{\leftmargin}{1.2em} %左边界
\setlength{\parsep}{0ex} %段落间距
\setlength{\topsep}{1ex} %列表到上下文的垂直距离
\setlength{\itemsep}{0.5ex} %条目间距
\setlength{\labelsep}{0.3em} %标号和列表项之间的距离,默认0.5em
\setlength{\itemindent}{1.1em} %标签缩进量
\setlength{\listparindent}{0em} %段落缩进量
\setlength\parindent{0em}%等同\noindent
二、常用包添加和初始化设置
\documentclass[a4paper]{article}
%中文字体包
\usepackage{xeCJK}
%默认字体
\setmainfont{Times New Roman}
\setCJKmainfont{宋体-简}
\setCJKfamilyfont{Heiti}{黑体-简} %黑体 Heiti
\newcommand{\Heiti}{\CJKfamily{Heiti}} %新建命令:用Heiti表示黑体
\setCJKfamilyfont{Simsun}{宋体-简} %宋体 Simsuni
\newcommand{\Simsun}{\CJKfamily{Simsun}}
%字号设置
\newcommand{\chuhao}{\fontsize{42pt}{\baselineskip}\selectfont} %初号
\newcommand{\xiaochuhao}{\fontsize{36pt}{\baselineskip}\selectfont} %小初号
\newcommand{\yihao}{\fontsize{28pt}{\baselineskip}\selectfont} %一号
\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont} %二号
\newcommand{\xiaoerhao}{\fontsize{18pt}{\baselineskip}\selectfont} %小二号
\newcommand{\sanhao}{\fontsize{15.75pt}{\baselineskip}\selectfont} %三号
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont}% 四号
\newcommand{\xiaosihao}{\fontsize{12pt}{\baselineskip}\selectfont} %小四号
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont} %五号
\newcommand{\xiaowuhao}{\fontsize{9pt}{\baselineskip}\selectfont} %小五号
\newcommand{\liuhao}{\fontsize{7.875pt}{\baselineskip}\selectfont} %六号
\newcommand{\qihao}{\fontsize{5.25pt}{\baselineskip}\selectfont} %七号
%设置每页上下左右页间距
\usepackage{geometry}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
%表格
\usepackage{makecell}
%列表
\usepackage{enumitem}
\setenumerate[1]{itemsep=0pt,partopsep=0pt,parsep=\parskip,topsep=2pt}
%图片
\usepackage{graphicx}
%代码
\usepackage{listings}
%使用行间距
\usepackage{setspace}
\begin{document}
\begin{spacing}{1.3} %1.5倍行距
内容
\end{spacing}
\end{document}
三、参考
大家可以看看以下内容学LaTex:
1、《大家来学LATEX》看一下开头大概了解一下Latex
2、《Latex插图指南GRAPHICS》关于插图的相关内容
3、http://blog.csdn.net/simple_the_best/article/details/51244631,不耐烦看书可以先看看这个,写的很好很详细
4、http://blog.sina.com.cn/u/1291622001,LaTex命令速查,熟悉一些之后可以用这个来查命令,比较全