卜算法学习笔记- latex必备知识

开始第一个project

创建一个.tax文件或者在overleaf中创建一个project

\documentclass{article}

\begin{document}
First document. This is a simple example, with no 
extra parameters or packages included.
\end{document}
  • 第一行表示文章的类别class为article,还有一些类别,如book、report等;
  • 之后的内容是文章的正文,包裹在\begin(document}和\end{document}中;
  • 正文里面的内容可以进行编辑,编辑之后的内容要看效果需要点击recompile,在一些简单的编辑器里面,可以在命令行输入pdflatex <your document>之后就可以看到编辑之后的效果;

绪论preamble

\begin{document}之前的部分都是绪论,定义了文章类型、文章使用的语言等;首先看一下一个常见的绪论:

\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
  • \documentclass[12pt, letterpaper]{article}
    定义了字体大小12pt,还有一些尺寸(9pt, 11pt, 12pt),默认为10pt;
    定义了纸张尺寸letterpaper,还有尺寸a4paper 和 legalpaper
    如果还有疑问访问page size and margins
  • \usepackage[utf8]{inputenc}
    定义编码

添加作者、标题、日期

需要在正文中添加\maketitle

\documentclass[12pt, letterpaper, twoside]{article}
\usepackage[utf8]{inputenc}

\title{First document}
\author{Hubert Farnsworth \thanks{funded by the Overleaf team}}
\date{February 2017}

\begin{document}

\maketitle

We have now added a title, author and date to our first \LaTeX{} document!

\end{document}

添加注释

在注释前添加%

黑体、斜体、下划线

  • 黑体:\textbf{…}
  • 斜体:\textit{…}
  • 下划线:\underline{…}
  • \emph{…}:在正常字体中斜体,在斜体中就是正常字体

加载图片

\documentclass{article}
% 在文章中加载图片需要添加的包
\usepackage{graphicx}
% 指示图片所在的文件夹
\graphicspath{ {images/} }

\begin{document}
The universe is immense and it seems to be homogeneous, 
in a large scale, everywhere we look at.

% 真正将图片添加在文章中的地方
\includegraphics{universe}

There's a picture of a galaxy above
\end{document}

图片题目、说明和引用

\begin{figure}[h]
    \centering
    \includegraphics[width=0.25\textwidth]{mesh}
    % 图片名称
    \caption{a nice plot}
    % 给图片标签
    \label{fig:mesh1}
\end{figure}

% \ref引用
As you can see in the figure \ref{fig:mesh1}, the 
function grows near 0. Also, in the page \pageref{fig:mesh1} 
is the same example.

创建列表

无序列表

\begin{itemize}
  \item The individual entries are indicated with a black dot, a so-called bullet.
  \item The text in the entries may be of any length.
\end{itemize}

有序列表

\begin{enumerate}
  \item This is the first entry in our list
  \item The list numbers increase with each entry we add
\end{enumerate}

数学公式

需要添加\usepackage{amsmath}

内联公式

\( ... \), $ ... $ or \begin{math} ... \end{math}

行内公式

\[ ... \], \begin{displaymath} ... \end{displaymath} or \begin{equation} ... \end{equation}

文章格式

摘要

\begin{document}

\begin{abstract}
This is a simple paragraph at the beginning of the 
document. A brief introduction about the main subject.
\end{abstract}
\end{document}

开始一个新段落

按两次换行

换行

\\, \newline

chapter、section

次序:
part和chapter只可以在report和book中

-1	\part{part}
0	\chapter{chapter}
1	\section{section}
2	\subsection{subsection}
3	\subsubsection{subsubsection}
4	\paragraph{paragraph}
5	\subparagraph{subparagraph}

表格

\begin{center}
\begin{tabular}{ c c c }
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\  
 cell7 & cell8 & cell9    
\end{tabular}
\end{center}
  • \begin{tabular}{ c c c }里面的{c c c}表示有三列,c表示居中,还有rl
  • 以下是一个添加分割线的例子
\begin{center}
 \begin{tabular}{||c c c c||} 
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex] 
 \hline\hline
 1 & 6 & 87837 & 787 \\ 
 \hline
 2 & 7 & 78 & 5415 \\
 \hline
 3 & 545 & 778 & 7507 \\
 \hline
 4 & 545 & 18744 & 7560 \\
 \hline
 5 & 88 & 788 & 6344 \\ [1ex] 
 \hline
\end{tabular}
\end{center}

添加表标题

Table \ref{table:data} is an example of referenced \LaTeX{} elements.

\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||} 
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex] 
 \hline\hline
 1 & 6 & 87837 & 787 \\ 
 2 & 7 & 78 & 5415 \\
 3 & 545 & 778 & 7507 \\
 4 & 545 & 18744 & 7560 \\
 5 & 88 & 788 & 6344 \\ [1ex] 
 \hline
\end{tabular}
\caption{Table to test captions and labels}
\label{table:data}
\end{table}

目录

  • section chapter自动识别目录,但是section*需要添加\addcontentsline{toc}{section}{Unnumbered Section}
\documentclass{article}
\usepackage[utf8]{inputenc}
 
\title{Sections and Chapters}
\author{Gubert Farnsworth}
\date{ }
  
\begin{document}
  
\maketitle
  
\tableofcontents

\section{Introduction}
   
This is the first section.
      
Lorem  ipsum  dolor  sit  amet,  consectetuer  adipiscing  
elit.   Etiam  lobortisfacilisis sem.  Nullam nec mi et 
neque pharetra sollicitudin.  Praesent imperdietmi nec ante. 
Donec ullamcorper, felis non sodales...
       
\section*{Unnumbered Section}
\addcontentsline{toc}{section}{Unnumbered Section}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  
Etiam lobortis facilisissem.  Nullam nec mi et neque pharetra 
sollicitudin.  Praesent imperdiet mi necante...

\section{Second Section}
       
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  
Etiam lobortis facilisissem.  Nullam nec mi et neque pharetra 
sollicitudin.  Praesent imperdiet mi necante...
         
\end{document}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值