Overleaf/Latex(一) —— 基础&示例 (sty,cls,bst文件)

Overleaf

Overleaf就是在线Latex

Overleaf, Online LaTeX Editor

注册要用gmail,126、163等都会提示无效

创建一个样例项目

最开始 其中只有这三个文件

.tex文件是主文件

.bib文件存放的是引文的信息

        即生成的论文在文中一点就可以跳到文末索引的对应位置,就是因为bib文件的索引信息

        像github中常带的

        

        这就是添加到bib文件中来引用这篇paper的语句

.sty文件是Latex中的用于增加功能的补足文件

取style的前三个字母,用来控制排版风格

这个文件用下面的命令加载。

 \usepackage{titlesec} 

很多常用的包是会直接保存在tex的安装目录中了,所以可以直接调

overleaf的话是保存在其服务器上了

.cls文件,定义了常用的格式和环境

这是用下面的命令加载

 \documentclass{} 

页边距的设定就是在cls文件中定义的

如果在当前tex文件中,某些命令的定义没找到,就去cls文件中找,ACM模板就是这样

最基本的document class是

\documentclass{article}

还有很多内置类

\documentclass{report}
\documentclass{book}
\documentclass{letter}
\documentclass{beamer}

.bst文件是bibtex样式文件

一般由征稿的杂志、会议给出

通常模板引用的时候是这样,

\bibliographystyle{ACM-Reference-Format}
\bibliography{sample-base}

bibliographystyle读的就是sty文件

bibliography读的就是bib文件

它规定了引用文献在 LaTeX 文档中的呈现方式,包括引用条目在文中的格式(例如作者名、标题、期刊名的顺序和样式)以及在文末参考文献列表中的格式。

\bibliographystyle{plain}

\bibliographystyle{ACM-Reference-Format}

完整的tex文件

下面举例一个包含引入上述类型文件的tex文件模版

假设在当前目录下有下列文件:main.texA.clsB.styC.bstD.bib

%main.tex文件
\documentclass{A}     % 或者不使用自定义的排版文件时,使用最普通的\documentclass{article}
\usepackage{B}        % 以及导入一些其他常用的宏文件,如amsmath、amssymb、amsthm等数学相关的宏文件
\begin{document}
XXX
XXX
XXX
% 正文结束
\bibliography{D}      % 导入正文中引入文献的数据
\bibliographystyle{C} % 导入参考文献的格式文件C.bst
\end{document}

导言区

在 LaTeX 中,导言区(preamble)是指文档中 \documentclass 命令和 \begin{document} 命令之间的部分。这段区域是用来设置文档的全局配置、加载宏包、定义命令和设置格式的地方

@内部命令

latex有个不成文的规则就是内部命令最好用@

即在普通文档中不直接使用的命令。这些命令通常是在类文件(.cls)、宏包(.sty)或其他高级设置中定义的。

 模板

Templates - Journals, CVs, Presentations, Reports and More - Overleaf, Online LaTeX Editor

\usepackage{}

就类似于写代码导入的包,比如规定上下左右页边距,能不能识别汉字,颜色之类的,一般不用动

示例

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{test}
\author{hxxjxw }
\date{March 2021}

\usepackage{natbib}
\usepackage{graphicx}

\begin{document}

\maketitle

\section{Introduction}
There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.
There is another theory which states that this has already happened.

\begin{figure}[h!]
\centering
\includegraphics[scale=1.7]{universe}
\caption{The Universe}
\label{fig:universe}
\end{figure}

\section{Conclusion}
``I always thought something was fundamentally wrong with the universe'' \citep{adams1995hitchhiker}

\bibliographystyle{plain}
\bibliography{references}
\end{document}

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值