latex徒手写论文之小白篇

本程序糖半月没更博客,那一定是因为本糖并没有学什么东西。嗯要说总结还差什么,那就是latex所遇问题总结,世上无难事,只怕有心人,只要你把格式调出来之后,你就舍不得弃latex奔office了。北鼻康姆昂。

1、 基本设置

  • 文章模板(B5纸,小四字, 单列,单面)
\documentclass[b5paper, 12pt, onecolumn, oneside]{article}
  • 文章页边距
\geometry{left=2.5cm,right=2.0cm,top=2.5cm,bottom=2.0cm}
  • 设置字号
\newcommand{\chuhao}{\fontsize{42pt}{\baselineskip}\selectfont}
\newcommand{\xiaochu}{\fontsize{36pt}{\baselineskip}\selectfont}
\newcommand{\yihao}{\fontsize{28pt}{\baselineskip}\selectfont}
\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont}
\newcommand{\xiaoer}{\fontsize{18pt}{\baselineskip}\selectfont}
\newcommand{\sanhao}{\fontsize{16pt}{\baselineskip}\selectfont}
\newcommand{\xiaosan}{\fontsize{15pt}{\baselineskip}\selectfont}
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont}
\newcommand{\xiaosi}{\fontsize{12pt}{\baselineskip}\selectfont}
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont}
\newcommand{\xiaowu}{\fontsize{9pt}{\baselineskip}\selectfont}
  • 标记英变中
\renewcommand\figurename{\wuhao{}}  %图的下标说明
\renewcommand\refname{\heiti{\sihao{参考文献}}} % 参考文献变成中文格式
\renewcommand{\baselinestretch}{1.5} %定义行间距
\renewcommand{\tablename}{\wuhao{}}

2、 section格式更改

\usepackage{titlesec}
\usepackage{titletoc}
\renewcommand\thesection{{\chinese{section}}}
\renewcommand\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
\renewcommand\theparagraph{({\arabic{paragraph}})}
\titleformat{\section}[block]{\centering\xiaosan\heiti\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}[block]{\centering\sihao\heiti\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{\xiaosi\heiti\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\paragraph}{\xiaosi\heiti}{\theparagraph}{1em}{}

这里,更改section为“第一章”格式,更改后发现subsection随之变为“第一章.1”,因此重设subsection、subsubsection格式。然后发现latex没有subsubsubsection,即没有四级标题,取而代之的为paragraph,这里重设paragraph为“(1)”格式。
设置完section标号的格式之后,是设置section显示的字体,按照要求设置一下即可正确显示。

3、 目录格式更改

\renewcommand{\contentsname}{\CJKfamily{song}\xiaoer\hspace*{\fill}\quad\hspace*{\fill}}

\contentsmargin{0.5em}
\titlecontents{section}
[3.5em]
{\sihao\heiti\bfseries} %目录一级标题
{\contentslabel {3.5em}}
{\hspace*{0.5em}}
{\titlerule*[0.5pc]{.}\contentspage}
\titlecontents{subsection}
[1em]
{\xiaosi\CJKfamily{song}} % 7.8 = 3.5 + 4 %目录二级标题
{\contentslabel{1.5em}}
{\hspace*{0.5em}}
{\titlerule*[0.5pc]{.}\contentspage}

这里设置目录字体格式,显示设置目录两个字格式,然后设置目录一级标号、目录一级标题、目录省略号、目录页码的格式,接着是二级目录的对应设置。

4、 程序代码的插入

\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{ %
  language=Java,                % the language of the code
  basicstyle=\small,           % the size of the fonts that are used for the code
  %basicstyle=\normalsize\monaco
  numbers=left,                   % where to put the line-numbers
  numberstyle=\small,  % the style that is used for the line-numbers
  %stepnumber=2,                   % the step between two line-numbers. If it's 1, each line
                                  % will be numbered
  numbersep=5pt,                  % how far the line-numbers are from the code
  backgroundcolor=\color{white},      % choose the background color. You must add \usepackage{color}
  showspaces=false,               % show spaces adding particular underscores
  showstringspaces=false,         % underline spaces within strings
  showtabs=false,                 % show tabs within strings adding particular underscores
  frame=single,                   % adds a frame around the code
  rulecolor=\color{black},        % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. commens (green here))
  tabsize=2,                      % sets default tabsize to 2 spaces
  captionpos=b,                   % sets the caption-position to bottom
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  title=\lstname,                   % show the filename of files included with \lstinputlisting;
                                  % also try caption instead of title
  keywordstyle=\color{blue},          % keyword style
  commentstyle=\color{dkgreen},       % comment style
  stringstyle=\color{mauve},         % string literal style
  escapeinside=``,            % if you want to add LaTeX within your code
  morekeywords={*,...},               % if you want to add more keywords to the set
  %escapeinside=``
}

调节代码显示为带框、带行号、识别java代码等设置。然后,插入代码时,用\ begin{lstlisting}、\ end{lstlisting}。

5、 图片的插入

\begin{figure}[htb!]
  \centering
  \includegraphics[width=1\textwidth]{figure/BUseCase.eps}
  \caption{\wuhao{业务用例图}}
  \label{fig31}
\end{figure}

其中label是与ref成对使用,即标记与引用。要引用该图即是“如图\ ref{fig31}所示”。
在table或者figure 后加 [!htb] 是系统忽略“美学”标准,把表格和图片插入到你的代码中是动的,但是不加感叹号,它就是按顺序选择h(此处),t(上方),b(下方),所以为了让图片随着你的代码移动,最好加一个[!htb]

6、 表格内强制换行

\begin{table}[!h]
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
  \caption{\wuhao{用例规约}}
  \label{table3}
  \centering
  \begin{tabular}{|m{2.2cm}|m{10.3cm}|}
  \hline
  \rule{0pt}{8pt}
  {\textbf{某某某}}&某某某\\
  \hline
  \rule{0pt}{8pt}
  {\textbf{某某某}}&某某某\\
  \hline
  {\textbf{某某某}}& \tabincell{m{10.3cm}}{(1)某某某
     \\ (2)某某某
     \\ (3)某某某
     }\\
  \hline
  \end{tabular}
\end{table}

把“/newcommand{/tabincell}[2]{/begin{tabular}{@{}#1@{}}#2/end{tabular}}”放在导言区,然后使用“&/tabincell{c}{}&”就可以在表格中强制换行。
m{2.2cm}为文字靠左显示,列宽为2.2cm。

7、 表格内上下左右居中

  \begin{tabular}{|m{2cm}<{\centering}|m{5cm}<{\centering}|m{5cm}<{\centering}|}

就酱紫

8、 设定enumerate编号样式

\usepackage{enumerate}
\begin{enumerate}[(i)]
\item Sugar
\item Fish
\item FishSugar
\end{enumerate}

可以使用 A,a,I,i,1 作为可选项产生 \Alph,\alph,\Roman,\roman,\arabic 的效果。

9、 参考文献

\newpage
\begin{thebibliography}{00}
\renewcommand{\baselinestretch}{0.85}
\bibitem{KBH2014}
Kononenko O, Baysal O, Holmes R, et al. Mining modern repositories with elasticsearch[C]// ACM, 2014:328-331.
\end{thebibliography}

引用处为“\cite{KBH2014}”,其中格式分为:
\bibitem{article1}文章标题 作者 期刊 年代 页码
\bibitem{book1}书标题 作者 出版社 年代

然后,就酱紫知其然而不知其所以然的结束(?)了latex恼人的bug之旅,希望论文院级优秀(我淼护体)。

  • 4
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值