LaTeX常用小结

在写论文,甚至有些课程的报告的时候,latex是常用的工具。这篇博文简单的记录了latex常用的一些内容。

最近发现一个在线latex网站 https://www.sharelatex.com/    以后就不用在电脑上安装CTEX了。

1 基本模块

没用过latex的读者,最想问的问题莫过于latex的 “hello world”程序长什么样。那么下面就贴一张图片来展示:

latex就是通过一些列指令来控制排版的。 一些一目了然的参数我就不解释了。第一行的\documentclass{article},article就是指一般的文档格式。可以换成,其他的,比如book,就是书的版式,分成很多章节chapter,还有一些论文的版式,例如IEEEtran,sig-alternate,这两种都是一页分两列的,看着很高端。

复制代码
%这是我的一个作业报告的前奏部分
\documentclass[a4paper,11pt]{article}
\author{leavingseason}

\title{Hello World}
\date{\today}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{bm}
\usepackage{xcolor}
\usepackage{float}
\usepackage{geometry}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
复制代码

 

\usepackage指需要使用一些宏包。 交代封面和版式的指令完之后,就开始了文档内容。用

\begin{document} 和\end{document}\begin{document} 和\end{document}
包围起来。 里面可以有摘要,很多个section等等常见的东西。

好了,大体上latex的流程就是这样。下面,我们要做的,就是实际中需要用哪些东西,再亡羊补牢。

2 常用命令

2.1一篇文章通常很长。那么就需要把它分成多个子文件。每个文件都是以.tex为后缀,用命令\input 或者\include 把它们添加进主文件中。

\input{introduction}
\input{model1}
\input{model2}
\input{model3}

\input 在插入子文件的时候不换页,\include在插入子文件的时候强制换页

2.2 引用参考文献

\bibliographystyle{plain}
\bibliography{bib/tex}

把参考文献写入一个以.bib为后缀名的文件中,例如bib/tex.bib,然后用上面的两条语句就可以了。.bib文件的内容如下

复制代码
@article{KDE,
  title = {Estimating the helpfulness and economic impact of product reviews: Mining text and reviewer characteristics},
  author = {Ghose, Anindya and Ipeirotis, Panagiotis G},
  journal = {Knowledge and Data Engineering, IEEE Transactions on},
  volume = {23},
  number = {10},
  pages = {1498--1512},
  year = {2011},
  publisher = {IEEE}
}
@inproceedings{ICDM,
  title={Modeling and predicting the helpfulness of online reviews},
  author={Liu, Yang and Huang, Xiangji and An, Aijun and Yu, Xiaohui},
  booktitle={Data Mining, 2008. ICDM'08. Eighth IEEE International Conference on},
  pages={443--452},
  year={2008},
  organization={IEEE}
}
@inproceedings{ICEC,
  title={Designing novel review ranking systems: predicting the usefulness and impact of reviews},
  author={Ghose, Anindya and Ipeirotis, Panagiotis G},
  booktitle={Proceedings of the ninth international conference on Electronic commerce},
  pages={303--310},
  year={2007},
  organization={ACM}
}

复制代码

获取这样的内容有一个小技巧:在谷歌学术中输入你要引用的论文名字,然后点开“引用”那个链接,再点击"导入BibTeX",引用的格式就出来了。

@article{KDE,article={}... 在这个命令中,KDE是这篇引用文章的索引号,是你自己定义的。在你的正文中要引用他的话,就用 \cite{KDE}

值得注意的是,如果你的正文没有引用该文章,那么即使在.bib中有该文章的信息,生成的pdf的reference列表中也不会有该文章的。

2.3 章节

\section{model1}, \subsection{...}, \subsubsection{...}等等

2.5 缩进

每段开头想要缩进,或者不要缩进: \indent \noindent

2.6 换行: \\

2.7 数学公式

记得用$ $把公式的内容包围起来,或者用

。 公式中粗体表示向量,用\mathbf{}:

\begin{equation}\label{eq:rbf}
\phi(\mathbf{x}|\mathbf{\mu},\Sigma) = f(\frac{(\mathbf{x}-\mathbf{\mu})^T(\mathbf{x}-\mathbf{\mu})}{\sigma^2})
\end{equation}

指数用 ^{指数部分}, 下标用 _{下标部分} , 分数用 \frac{分子}{分母} ,  WinEdit 上也有很好用的快捷按钮:

2.8 列表

\begin{enumerate} 

\item ..

\item ..

\end{enumerate}  

这个是带序号的列表。 把enumerate 换成itemize, 就是不带序号的。例如:

2.9 插入图片:

 

\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{pic/timeliness.JPG}
\caption{An example of review helpfulness vs. time of review.}
\label{fig:timeliness}
\end{figure}

要引用图片的时候,就用  ??? ???。 图片可以裁剪,用法如:\includegraphics[trim={0 4cm 0 2cm},clip,width=0.5\textwidth]{char_cate2.pdf}

如果版面是双栏的,图片比较大想跨双栏的话,可以用\begin{figure*}

并排显示多张图:

复制代码
\begin{figure*}[htbp]
\centering
\begin{subfigure}{.33\textwidth}
  \centering
  \includegraphics[trim={1cm 4cm 1cm 3cm},clip,width=1\textwidth]{charts/geo_auc.pdf}
  \caption{Gpredictors}
  \label{fig:g_auc}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
  \centering
  \includegraphics[trim={1cm 4cm 1cm 3cm},clip,width=1\textwidth]{charts/mobility_auc.pdf}
  \caption{U predictors}
  \label{fig:u_auc}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
  \centering
  \includegraphics[trim={1cm 4cm 1cm 3cm},clip,width=1\textwidth]{charts/ratings_auc.pdf}
  \caption{R predictors. }
  \label{fig:r_auc}
\end{subfigure}
\caption{AUC performance comparison for individual predictors of different groups..}
\label{fig:heatmap}
\end{figure*}
复制代码

 

 

 

 2.10 表格

实质上是用指令控制表格框。注意 (1) \label{tab:d2}要放在\end{table}之前,不能放在\begin{table}之后,不然引用\ref{tab:d2}的时候会出问题 (2)表格等某些元素里面不能用footnote,要用footnotemark+footnotetext代替

\begin{table} 
\centering 
\caption{Basic statistics of three cities} 
\begin{tabular}{|c|c|c|l|} \hline 
City&\#column1&\#column2&\#column3\footnotemark\\ \hline 
Shanghai&127,503 & 80,914& 7,190 \\ \hline 
Beijing&10,396 & 6,772&5,917\\ \hline 
Guangzhou & 1,273 & 1,844 & 1,747 \\ 
\hline\end{tabular} 
\label{tab:d2} 
\end{table}
\begin{table} \centering \caption{Basic statistics of three cities} \begin{tabular}{|c|c|c|l|} \hline City&\#column1&\#column2&\#column3\footnotemark\\ \hline Shanghai&127,503 & 80,914& 7,190 \\ \hline Beijing&10,396 & 6,772&5,917\\ \hline Guangzhou & 1,273 & 1,844 & 1,747 \\ \hline\end{tabular} \label{tab:d2} \end{table}

 \footnotetext{We only count the shops which has at least one review in 2012.}

 

好了,我上次用到的就这么多了。希望以后回头看看的时候,可以作为回忆的参考。 长期更新。

其他:

一份不太简短的 LATEX  介绍 http://www.mohu.org/info/lshort-cn.pdf

数学符号:

 

 

 


from: http://www.cnblogs.com/sylvanas2012/archive/2013/05/28/3102880.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值