Overleaf
,一款免费的在线云编辑器,其使用Latex
作为编辑语言,只要掌握一些基础的语法,就可以地创作出布局精良的论文,再也无须为论文排版而烦恼,下面就来介绍下其中的一些常用的语法格式
Overleaf
官方网址
一键配置 复制以下代码来一键配置初始化论文文档,记得将右上角菜单中的编译器改为LuaLatex
,以使用中文编写1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 \documentclass {article}\usepackage [UTF8]{ctex}\usepackage {graphicx}\usepackage {soul,color,xcolor}\usepackage {titlesec}\setcounter {secnumdepth}{4}\setcounter {tocdepth}{4}\usepackage [letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}\usepackage {type1cm} \usepackage {float}\usepackage {tocloft}\usepackage {listings}\usepackage {pdfpages}\usepackage {amsmath}\usepackage [colorlinks=true, allcolors=blue]{hyperref}\usepackage {cite}\lstset { breaklines=true, breakatwhitespace=true, numbers=left, numberstyle=\tiny , keywordstyle=\color {blue!70}, commentstyle=\color {red!50!green!50!blue!50}, frame=shadowbox, rulesepcolor=\color {red!20!green!20!blue!20}, escapeinside=``, xleftmargin=2em, xrightmargin=2em, aboveskip=1em, framexleftmargin=2em } \title {title}\author {}\date {}\begin {document}\maketitle \tableofcontents 正文内容... \bibliographystyle {unsrt}\bibliography {references} \end {document}
原生语法 基本结构 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \documentclass {article} \usepackage {graphicx} \title {} \author {} \date {} \begin {document} \maketitle Hello, world! \end {document}
标题结构 1 2 3 4 5 \section {一级标题}\subsection {二级标题}\subsubsection {三级标题}\paragraph {四级小标题}\subparagraph {五级小标题}
行内样式 1 2 3 \textbf {加粗文本} \textit {斜体文本} \underline {下划线文本}
列表 有序列表 无序列表
1 2 3 4 \begin {enumerate} \item 项目 1 \item 项目 2 \end {enumerate}
1 2 3 4 \begin {itemize} \item 项目 1 \item 项目 2 \end {itemize}
数学公式 行内公式: 这是一个行内公式:$E=mc^2$
独立公式: 1 2 3 4 \begin {equation} a^ 2 + b^ 2 = c^ 2 \end {equation}
宏包语法 文档语言 由于Overleaf
原生不自带中文,所以需要使用宏包切换中文 随后需要在左上角菜单将编译器改为LuaLatex
则可使用中文
文档结构和版面布局 1 2 3 4 \setcounter {secnumdepth}{4} \setcounter {tocdepth}{4} \usepackage [letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
标题样式和文本格式 1 2 \usepackage {titlesec} \usepackage {soul,color,xcolor}
使用方法: 1 2 \hl {高亮内容} \textcolor {blue}{蓝色文本}
插入图片 1 2 3 \usepackage {graphicx} \includegraphics [width=\textwidth ]{image.png}
浮动体图片 1 2 3 4 5 6 7 8 9 10 \usepackage {graphicx} \usepackage {float} \begin {figure}[H] \centering \includegraphics [width=0.75\linewidth ]{login.jpg} \caption {Login Page} \label {fig:Login Page} \end {figure}
浮动体同时还可应用于表格
目录 1 2 3 4 5 6 7 8 9 \usepackage {tocloft} \begin {document}\maketitle \tableofcontents \end {document}
代码块 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 \usepackage {listings} \lstset { breaklines=true, breakatwhitespace=true, numbers=left, numberstyle=\tiny , keywordstyle=\color {blue!70}, commentstyle=\color {red!50!green!50!blue!50}, frame=shadowbox, rulesepcolor=\color {red!20!green!20!blue!20}, escapeinside=``, xleftmargin=2em, xrightmargin=2em, aboveskip=1em, framexleftmargin=2em }
插入PDF文件 1 2 3 \usepackage {pdfpages} \includepdf [pages=1-2]{document.pdf}
更高级的数学公式 1 2 3 4 5 6 7 \usepackage {amsmath}\begin {align} a + b & = c \\ d - e & = f \end {align}
超链接 1 2 3 \usepackage [colorlinks=true, allcolors=blue]{hyperref} \href {http://example.com }{点击这里访问网站}
参考文献 这里提供两种使用参考文献的方式,推荐使用第一种cite
,因为其相对简洁,并且提供一种自定义列表,即你可以根据不同的标准定义参考文献格式,相对来说biblatex
包则需要引入格外配置来支持增强功能
使用cite包(推荐) 使用biblatex包
引入必要的宏包
创建 .bib
文件 在 Overleaf
的项目中,新建一个名为 references.bib
的文件(确保.bib
格式即可) 文件内容格式:该文件为bibTeX格式,引用时一般可以直接选择用该方式引用1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 @book{lamport1994, author = {Leslie Lamport}, title = {LaTeX: A Document Preparation System}, publisher = {Addison-Wesley}, year = {1994}, edition = {2nd}, } @article{einstein1905, author = {Albert Einstein}, title = {Zur Elektrodynamik bewegter K{\"o}rper}, journal = {Annalen der Physik}, volume = {322}, number = {10}, pages = {891--921}, year = {1905}, publisher = {Wiley-VCH}, }
在正文中引用文献 使用 \cite{引用标签}
在正文中插入参考文献。例如
1 爱因斯坦的广义相对论首次出现在 \cite {einstein1905}。
显示参考文献列表
1 2 3 \bibliographystyle {unsrt}\bibliography {references}
指定格式:
plain,按字母的顺序排列,比较次序为作者、年度和标题
unsrt,样式同plain,只是按照引用的先后排序
alpha,用作者名首字母+年份后两位作标号,以字母顺序排序
abbrv,类似plain,将月份全拼改为缩写,更显紧凑
ieeetr,国际电气电子工程师协会期刊样式
acm,美国计算机学会期刊样式
siam,美国工业和应用数学学会期刊样式
apalike,美国心理学学会期刊样式
来源:参考文章
完整代码示例1 2 3 4 5 6 7 8 9 10 11 \documentclass {article}\usepackage [utf8]{ctex}\usepackage {cite}\begin {document}这是参考文献的引用示例 \cite {lamport1994} 和 \cite {einstein1905}。 \bibliographystyle {unsrt}\bibliography {references}\end {document}
引入必要的宏包1 2 3 \usepackage [backend=biber]{biblatex} \addbibresource {references.bib}
创建 .bib
文件 在 Overleaf
的项目中,新建一个名为 references.bib
的文件(确保.bib
格式即可) 文件内容格式:该文件为bibTeX格式,引用时一般可以直接选择用该方式引用1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 @book{lamport1994, author = {Leslie Lamport}, title = {LaTeX: A Document Preparation System}, publisher = {Addison-Wesley}, year = {1994}, edition = {2nd}, } @article{einstein1905, author = {Albert Einstein}, title = {Zur Elektrodynamik bewegter K{\"o}rper}, journal = {Annalen der Physik}, volume = {322}, number = {10}, pages = {891--921}, year = {1905}, publisher = {Wiley-VCH}, }
在正文中引用文献,使用 \cite{引用标签}
在正文中插入参考文献。例如1 爱因斯坦的广义相对论首次出现在 \cite {einstein1905}。
显示参考文献列表
完整代码示例1 2 3 4 5 6 7 8 9 10 \documentclass {article}\usepackage [utf8]{ctex}\usepackage [backend=biber]{biblatex} \addbibresource {references.bib} \begin {document}这是参考文献的引用示例 \cite {lamport1994} 和 \cite {einstein1905}。 \printbibliography \end {document}