LaTeX简单常用方法笔记

简单用用吧,为了完成作业,具体用法可自行搜索

推荐LaTeX在线编辑器:
https://cn.overleaf.com/

API参考手册:
http://www.personal.ceu.hu/tex/latex.htm


标题:\title{标题}
作者:\author{作者}
学号:\studentid{123}
正文:

\begin{document}
...内容...
\end{document}

制作首页:\maketitle;如果没有这个,你的author之类的信息是不会显示的
中文支持:

\usepackage{ctex} % 导入中文宏
摘要部分

中文摘要和关键词:

\begin{abstract}         %摘要部分
\small\centering这是一篇关于勾股定理的小论文。%\small 是使用缩小字体,\centering是使内容居中
\par\textbf{Keywords:} keyword1, keyword2, keyword3
\end{abstract}

在这里插入图片描述
英文摘要和关键词:

% 由于此时是中文环境,需要定义一个新的英文摘要
\newcommand{\enabstractname}{Abstract}
\newenvironment{enabstract}{%
    \par\small
    \noindent\mbox{}\hfill{\bfseries \enabstractname}\hfill\mbox{}\par
    \vskip 2.5ex}{\par\vskip 2.5ex}  
\begin{enabstract}
    This is the abstract in English.
    \centering
    \textbf{Keywords:} Abstract, \LaTeXe, English
  \end{enabstract}

在这里插入图片描述
自动目录:

\tableofcontents  %表示目录部分开始
\section{勾股定理在古代}  %目录的前缀页面都会自动排版不需要手动排版
\section{勾股定理的近代形式}
\addcontentsline{toc}{section}{参考文献}  %用来添加文献的标准方式
\section{附录}  %要写的附录

在这里插入图片描述
加粗:\textbf{文字}
斜体:\emph{文字}
下划线:\underline{文字}
不缩进:\noindent
段落结束换行:\par
空白行:{\par\vskip 2.5ex}
图片设置英文题注:

\begin{figure}[h!]
	\centering
	\includegraphics[scale=0.5]{img/Communication Model}
     \renewcommand{\figurename}{Fig} % 设置英文题注
	\caption{Communication Model}
	\label{fig:Communication Model}
\end{figure}

表格设置英文题注:

% 主要也是这两句
\renewcommand{\tablename}{Tab}
\caption{English title}

表格:

\begin{table}[htbp]
  \centering
    \begin{tabular}{|c|c|c|c|}
    \hline
        & \multicolumn{3}{|c|}{Overall classification results (\%)} \\
    \hline
       Descriptors          & KTH   & UCF sports & TV human interaction \\
    \hline
    Trajectory & 91.67 & 74.64 & 46.43 \\
    HOG   & 86.11 & 69.88 & 44.52 \\
    MBH   & 96.3 & 72.74 & 45.88 \\
    \hline
     \hline
    Combined & 96.3 & 81.07 & 55.4 \\
    \hline
    \end{tabular}%
    \caption{An example table}
  \label{t1}%
\end{table}%

在这里插入图片描述
引用:内容内容\cite{ref1}内容内容\citep{ref1}
在这里插入图片描述
设置引用右上标:

% 添加:
\newcommand\myciteup[1]{
   
   {\setcitestyle{square,super}\cite{#1}}} % 使引用为上标
%使用时:
123456 \myciteup{ref1}

参考文献:

I always thought something was fundamentally wrong with the universe \citep{ref1}
\bibliographystyle{plain}
\bibliography{ref/references}

% 文献具体内容在 ref/references.bib 中,内容格式(BibTeX)如下:
@book{ref1,
  title={The Hitchhiker's Guide to the Galaxy},
  author={Adams, D.},
  isbn={9781417642595},
  url={http://books.google.com/books?id=W-xMPgAACAAJ},
  year={1995},
  publisher={San Val}
}

在这里插入图片描述

章:\chapter{名称}
小节:\section{名称}
亚节:\subsection{名称}
三级标题:\subsubsection{三级标题}
在这里插入图片描述
另起一页:\newpage
插入图片:

\begin{figure}[h!]
\centering
\includegraphics[scale=1.7]{img/universe} % 图片文件img/universe.jpg
\caption{The Universe}
\label{fig:universe}
\end{figure}

在这里插入图片描述
标签:\label{名称a},常与\ref{名称a}同用
伪代码:

先导入包:\usepackage[lined,boxed,commentsnumbered]{algorithm2e}
再添加代码:
\begin{algorithm}[H]
  \KwData{this text}
  \KwResult{how to write algorithm with \LaTeX2e }
  initialization\;
  \While{not at end of this document}{
    read current\;
    \eIf{understand}{
      go to next section\;
      current section becomes this one\;
    }{
      go back to the beginning of current section\;
    }
  }
  \caption{How to write algorithms 1}
\end{algorithm}

在这里插入图片描述
导入其他tex:\input{a.tex}
目录:\makecontents
各种列表:\listtables、\listfigures、\listalgorithms
设置页码:

\pagenumbering{arabic} %  阿拉伯数字
\setcounter{page}{1} % 数字1

在这里插入图片描述
简单公式:

行内公式:
$ c = \sqrt{a^{2}+b_{0}^{2}+e^{x}} $
行间公式:
$$ c = \sqrt{a^{2}+b_{0}^{2} +e^{x}} $$

常用数学公式代码:
xfxuezhang.cn/index.php/archives/121

在这里插入图片描述
复杂公式并编号:

\begin{equation} 
\mathbf{X} = \left(\begin{array}{ccc} 
x_{11} & x_{12} & \ldots \\ 
x_{21} & x_{22} & \ldots \\ 
\vdots & \vdots & \ddots \end{array} \right) 
\end{equation} 

在这里插入图片描述
换行:\\
空格:\

完整测试实例(仅供参考啊,实际有很多配置的):

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode

\documentclass[11pt]{article} % use larger type; default would be 10pt
%\documentclass[master,twoside]{article}
\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)

%%% PAGE DIMENSIONS
\usepackage{geometry} % to change the page dimensions
\geometry{a4paper} % or letterpaper (US) or a5paper or....
% \geometry{margin=2in} % for example, change the margins to 2 inches all round
% \geometry{landscape} % set up the page for landscape
%   read geometry.pdf for detailed page layout information

% 导入中文宏 eabstract
\usepackage{ctex}
\usepackage{graphicx} % support the \includegraphics command and options 
\usepackage{natbib}
% \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent

% 算法以及列表环境
\RequirePackage{cases,listings}
\RequirePackage{fancyvrb}
\RequirePackage{algorithmic}

%%% PACKAGES
\usepackage[lined,boxed,commentsnumbered]{algorithm2e}
\usepackage{booktabs} % for much better looking tables
\usepackage{array} % for better arrays (eg matrices) in maths
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
% These packages are all incorporated in the memoir class to one degree or another...

%%% HEADERS & FOOTERS
\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
\pagestyle{fancy} % options: empty , plain , fancy
\renewcommand{\headrulewidth}{0pt} % customise the layout...
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}

%%% SECTION TITLE APPEARANCE
\usepackage{sectsty}
\allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
% (This matches ConTeXt defaults)

%%% ToC (table of contents) APPEARANCE
\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
\usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!

%%% END Article customizations




%%% The "real" document content comes below...

\title{Freshness optimization of dense relay cache network data based on edge computing}
\author{The Author}


\begin{document}
\maketitle


\begin{abstract}         %摘要部分
    \small\centering这是一篇关于勾股定理的小论文。%\small 是使用缩小字体,\centering是使内容居中
    \par\textbf{Keywords:} keyword1, keyword2, keyword3
\end{abstract}

% 由于此时是中文环境,需要定义一个新的英文摘要
\newcommand{\enabstractname}{Abstract}
\newenvironment{enabstract}{%
    \par\small
    \noindent\mbox{}\hfill{\bfseries \enabstractname}\hfill\mbox{}\par
    \vskip 2.5ex}{\par\vskip 2.5ex}  
\begin{enabstract}
    This is the abstract in English.
    \centering
    \textbf{Keywords:} Abstract, \LaTeXe, English
\end{enabstract}


\tableofcontents  %表示目录部分开始
\section{勾股定理在古代}  %目录的前缀页面都会自动排版不需要手动排版
\section{勾股定理的近代形式}
\addcontentsline{toc}{section}{参考文献}  %用来添加文献的标准方式
\section{附录}  %要写的附录


\section{First section}

Your text goes here.

\subsection{A subsection}
\subsubsection{三级标题}

More text.

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


\begin{algorithm}[H]
  \KwData{this text}
  \KwResult{how to write algorithm with \LaTeX2e }
  initialization\;
  \While{not at end of this document}{
    read current\;
    \eIf{understand}{
      go to next section\;
      current section becomes this one\;
    }{
      go back to the beginning of current section\;
    }
  }
  \caption{How to write algorithms 1}
\end{algorithm}




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


$ c = \sqrt{a^{2}+b_{0}^{2}+e^{x}} (1)$
$$ c = \sqrt{a^{2}+b_{0}^{2} +e^{x}} $$


\begin{equation} 
\mathbf{X} = \left(\begin{array}{ccc} 
x_{11} & x_{12} & \ldots \\ 
x_{21} & x_{22} & \ldots \\ 
\vdots & \vdots & \ddots \end{array} \right) 
\end{equation} 

\renewcommand\bibname{Reference}
\bibliographystyle{plain}
\bibliography{ref/references}

\end{document}


猜你喜欢

转载自blog.csdn.net/sxf1061700625/article/details/108149160