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 \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 [backend=biber]{biblatex} \addbibresource {references.bib} \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 正文内容... \printbibliography \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 }{点击这里访问网站}
参考文献
引入必要的宏包1 2 3 \usepackage [backend=biber]{biblatex} \addbibresource {references.bib}
创建 .bib
文件:在 Overleaf
的项目中,新建一个名为 references.bib
的文件。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}