Latex基本模版

\documentclass[a4paper,onecolumn,10pt]{article}%定义文档格式:
%a4paper 用a4纸张大小
%onecolumn 单排 亦可以使双排 twocolumn
%10pt 11pt 12pt
%article 文档样式,report book slides

%\usepackage[raggedright]{titlesec}%raggedleft (居左,默认), raggedright (居右)。
%\titleformat{\section}{\centering\Huge\bfseries}{第\,\thechapter\,章}{1em}{}
%\titleformat{command}[shape]{format}{label}{sep}{before}[after]
%format rm sf tt md bf up it sl sc ||||big medium small tiny |||raggedleft center raggedright
%command 是要重新定义的各种标题命令,比如 \part,\chapter,\section,\subsection,\subsubsection,\paragraph,\subparagraph等
%shape 是用来设定段落形状的,可选的参数有 hang 、 block 、 display 等,详见 titlesec 文档,
%label 用于定义定义标题的标签,就是标题内容前面的标号;
%sep 定义标题的标签与标题内容之间的间隔距离。
%before 用于在标题内容前再加些内容;
%after 用于在标题内容后再加些内容。


\usepackage{amsmath}%数学公式

\usepackage{CJK}%中文支持
%使用时应该用
%\begin{CJKs}
%%
%\end{CJK*}

\usepackage{indentfirst}%首行缩进(针对英文)

\usepackage{setspace}%行间距包,
%需要在用的时候
%\begin{spacing}{value}

%\end{spacing}

\usepackage{graphicx}%图片
%使用方法
%\begin{figure}[h]\centering
%\includegraphics[width=6cm]{figure1.jpg}
%\caption{单源点最短路径问题}\label{fig:shortestpath}
%\end{figure}

\usepackage{listings}%粘贴c代码
\lstset{language=TeX}%这条命令可以让LaTeX排版时将代码突出显示 LateX,Tex, C, C++, Java
\lstset{breaklines}%这条命令可以让LaTeX自动将长的代码行换行排版
\lstset{extendedchars=false}%这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
\lstset{
%numbers=left,
%stepnumber=1,
numbersep=5pt,
keywordstyle=\color{blue!70},
commentstyle=color{red!50!green!50!blue!50},
frame=single
}

\usepackage{caption}%定义表格的对齐方式,默认是中间
%\captionsetup[table]{justification=raggedleft,singlelinecheck=off}%加上这句话就是左对齐

\usepackage{geometry}%页眉页脚
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}%设置页边距

\pagestyle{plain}%设置页面样式 plain heading empty

\graphicspath{{MyFigures/}}%图片路径
\renewcommand\arraystretch{1.5}%表格行间距

%自定义中文字体
\newcommand{\song}{\CJKfamily{song}}    % 宋体
\newcommand{\fs}{\CJKfamily{fs}}             % 仿宋体
\newcommand{\kai}{\CJKfamily{kai}}          % 楷体
\newcommand{\hei}{\CJKfamily{hei}}         % 黑体
\newcommand{\li}{\CJKfamily{li}}               % 隶书


\usepackage{sectsty}%设置章节样式
\allsectionsfont{\mdseries\nohang\large\em}

%\subsectionfont{字体命令}    小节标题字体
%\subsubsectionfont{字体命令}    小小节标题字体
%\paragraphfont{字体命令}    段标题字体
%\subparagraphfont{字体命令}    小段标题字体
%\minisecfont{字体命令}    \minisec标题字体
%\partnumberfont{字体命令}    部序号字体
%\parttitlefont{字体命令}    部标题字体
%\chapternumberfont{字体命令}章序号字体
%\chaptertitlefont{字体命令}章标题字体
%\nohang 多行标题时不缩排

%以上是导言区
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{CJK*}{GBK}{song}
\rm %\rm全文使用Time new rome字体 当然还可以使用\tt(该命令表示使用typewriter字体),\it(表示Italic字体)

\normalsize
%Latex 设置字体大小命令由小到大依次为:
%\tiny  5
%\scriptsize 7
%\footnotesize 8
%\small 9
%\normalsize 10
%\large 12
%\Large 14
%\LARGE 17
%\huge 20
%\Huge 25

\title{ \TeX{} 常用命令}
\author{Tao Kong}
\maketitle

\renewcommand\figurename{图}%图例样式
\renewcommand\tablename{表}%表例样式

\begin{spacing}{1.5}%行间距
%\tableofcontents%目录


\section{添加代码}

\begin{lstlisting}
return 0;
\end{lstlisting}

\section{添加表格}
\begin{table}[!hbp]%开始表格
%其中参数[!hbp] 的意思是:
%!表示尽可能的尝试 h(here) 当前位置显示表格,
%t表示在上边
%如果实在不行显示在 b(bottom) 底部,
%p表示浮动
\centering

%表格居中显示 也可以是
\begin{tabular}{|c|cccccccccc|}%开始绘制表格
%{|c|c|c|c|c|} 表示会有5列, 每个的方式未居中(c),这里可以设置表格样式
\hline
长度 $i$&1&2&3&4&5&6&7&8&9&10\\
\hline
价格 $p_{i}$&1&5&8&9&10&17&17&20&24&30\\
\hline
\end{tabular}
\caption{钢条价格表} \label{ref1}%表格的名称
\end{table}
%表格结束

\section{添加公式}

如果一个最优解将钢条切割为$k$段,那么最优切割方案为
\begin{equation}\label{eq1}
  n=i_{1}+i_{2}+ \ldots + i_{k}
\end{equation}

将钢条切割为长度分别为 $i_{1}, i_{2}, \ldots , i_{k}$的小段,得到的最大收益
\begin{equation}\label{eq2}
  r_{n}=p_{i_{1}}+p_{i_{2}}+ \ldots + p_{i_{k}}
\end{equation}

我们从底层开始构造:
\begin{equation*}
  r_{0}=p_{0}=0
\end{equation*}
\begin{equation*}
   r_{1}=p_{1}+r_{0}
\end{equation*}
\begin{equation*}
   r_{2}=\max \{ p_{1}+r_{1},p_{2}+r_{0} \}
\end{equation*}
\begin{equation*}
   \vdots
\end{equation*}
\begin{equation*}
   r_{k}=\max \{ p_{i}+r_{k-i} \}(i=1,2, \ldots , k)
\end{equation*}

这样就可以自底向上构造最优解。
\end{spacing}

get it
\section{添加图片}
\begin{figure}[h]\centering
\includegraphics[width=6cm]{figure1.jpg}
\caption{单源点最短路径问题}\label{fig:shortestpath}
\end{figure}

\end{CJK*}
\end{document}

生成的pdf文档

 

posted @ 2014-08-07 15:09  Tao Kong  阅读(3465)  评论(0编辑  收藏  举报