Latex环境安装与基础入门

介绍:vscode+latex实现论文排版

一、环境准备

1.latex下载

这里建议使用中科大的镜像Index of /CTAN/systems/texlive/Images/

清华的镜像下载速度太慢,文件下载textlive.iso

下载好后直接 点击文件,找到里面的install-tl-windows.bat就会出现引导安装界面了,跟着流程走,这里注意:安装地址最好是英文,如果是中文容易安装失败。安装速度比较慢,耐心等待。

2.vscode下载

Visual Studio Code - Code Editing. Redefined

根据自己的系统选择合适的版本进行安装

下载好会出现exe文件,点击即可进入安装引导。

安装好软件进去之后 ,下载两个插件,插件下载在界面的左上角的几个小矩形那里,如下图所示

注意:汉化插件重启软件后才起效 

3.latex编译配置文件

在 VSCode 中使用快捷键 Ctrl+Shift+P,出现一个搜索框,输入 JSON,选择 Preferences:Open User Settings(JSON)这个,从而就能打开 settings.json,进行环境配置了。

进入 Settings.json后初始只有一对花括号,全选删除,打开本文附带的settings.json文件,全选复制粘贴到该界面中并保存。

或者直接复制下列代码也行:

{
    "latex-workshop.latex.tools": [
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
                "-shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "lualatex",
            "command": "lualatex",
            "args": [
                "-shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ]
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ]
        }
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "PDFLaTeX",
            "tools": [
                "pdflatex"
            ]
        },
        {
            "name": "XeLaTeX",
            "tools": [
                "xelatex"
            ]
        },
        {
            "name": "LuaLaTeX",
            "tools": [
                "lualatex"
            ]
        },
        {
            "name": "latexmk",
            "tools": [
                "latexmk"
            ]
        },
        {
            "name": "BibTeX",
            "tools": [
                "bibtex"
            ]
        },
        {
            "name": "pdflatex -> bibtex -> pdflatex*2",
            "tools": [
                "pdflatex",
                "bibtex",
                "pdflatex",
                "pdflatex"
            ]
        },
        {
            "name": "xelatex -> bibtex -> xelatex*2",
            "tools": [
                "xelatex",
                "bibtex",
                "xelatex",
                "xelatex"
            ]
        }
  ],
  }

在保存后,在界面的左上角会有TEX的图标,找到并点击

下图右侧显示的代码是模板代码,笔者存放在文末,直接复制就好了,刚开始点击下图左侧的编译按钮Reciper:PDFLaTe进行编译

二、基础功能介绍 

模板代码开头介绍

在\begin{}与\end{}之间就都是正文 ,可以输入文字

代码与pdf中文字互相定位,前提你的鼠标光标要在你需要定位地方

(1)代码定位文字:Ctrl+Alt+J

(2)文字定位代码:Ctrl+鼠标左键

其他基础代码

(3)\\ 换行

(4)& 对齐

(5)\par 分段

(6\newpage 分页命令

(7)\setlength{\parindent}{长度}  首行缩进

(8)& 对齐

公式

(1)插入在文中的特殊字符和短公式

$公式$

(2)单行公式带编号

\begin{equation}\label{公式标签}

输入你需要的公式

\end{equation}

自动引用

在需要引用的地方\autoref{公式标签},编译后会在相应的pdf位置出现一个equation1,点击这个会跳转到对应的公式,equation后面跟的数字代码自己会调整,在这里公式标签的作用就是来自动引用的

例子1:

\autoref{eq1}
\begin{equation}\label{eq1}
  \alpha +\beta =\gamma ^2
\end{equation}

(3)无编号公式

\[公式\]或者$$公式$$ 

(4)多行公式

\begin{split}

\end{split}

例子2:注意&是对对其符号

\autoref{eq1}
\begin{equation}\label{eq1}
  \begin{split}
    &x+y=z\\
    &\alpha +\beta =\gamma ^2\\
    &sin\vartheta +cos\vartheta =1
  \end{split}
\end{equation}

 编译效果如下图所示:

例子3:分类讨论

\begin{cases}

\end{cases}

\autoref{eq2}
\begin{equation}\label{eq2}
  F(x)=
 \begin{cases}
  0&,\text{if $x>3$}\\
  x+1&,\text{if $x>1$}\\
  1&,\text{otherwise.}
 \end{cases}
\end{equation}

 插入图片

例子4:插入图片

\begin{figure}[htbp]%htbp是图片位置放置偏好
  \centering%居中
  %图片的大小与路径
  \includegraphics[width=12cm]{D:/P/毕业设计/配图/bode.png}
  \caption{bode}%图片的标题
\end{figure}

插入表格

例子5:插入列表

以下网址直接生成表格代码

 LaTeX Tables Editor

\begin{table}
  \centering
  \caption{wisdom}
  \begin{tblr}{
    column{1} = {c},
    hline{1-2,5} = {-}{},
  }
  name & num \\
  a    & 1   \\
  b    & 2   \\
  c    & 3   
  \end{tblr}
  \end{table}

如果生成的代码具有%,若可以正常编译,则忽略即可,若无法正常编译,请将那行代码%去掉并剪切到代码开头\usepackage{}那里去,即可正常编译,这里是加载相应的依赖包

注意:可能代码表格位置与pdf上的位置不一样,解决方法在\begin{table}加上[h],代码如下

\begin{table}[h]

文献引用

加载依赖包式使用bib,在代码开头加上下列代码

\bibliographystyle{unsrt}%bib管理文献

在参考文献处输入以下代码: 

\bibliography{refer}

 在.tex文件同级目录创建xxx.bbi文件,bib文件名字与上列代码\bibliography{refer}花括号里的名字相同,比如笔者的bib文件为refer.bib,那么\bibliography{refer}花括号里的名字保持一致
然后去谷歌学术引用bbi格式文献引用

点击之后会自动跳转进入一个新网页,复制所有内容到xxx.bbi,反复多次将要引用的全部文献的bib格式全部复制到xxx.bib文件中去,如下图所示:

注意参考文献处代码 \bibliography{refer}中的refer就是.bib文件的名字,也就是xxx。引用使用\cite{},编译使用bib编译,如下图所示:

 上面的引用尾注效果如下图所示:

 要想实现尾注在右上方,需要在加载依赖包的地方加一个命令

\newcommand{\upcite}[1]{\textsuperscript{\cite{#1}}}

而且引用论文\cite{}变为\upcite{}

效果如下图所示:

补充一下编译方式,根据需要编译的内容进行编译,编译错了下次选对了可能也会报错

------------------------------------------------更新日志-------------------------------------------------------------

2024.5.27初次上传

5.28更改错别字,翔实细节 

 模板代码

\documentclass{mcmthesis}
\mcmsetup{CTeX = false,   % 使用 CTeX 套装时,设置为 true
        tcn = 1111111, problem = ABCDEF,
        sheet = true, titleinsheet = true, keywordsinsheet = true,
        titlepage = false, abstract = true}
%加载依赖包
\usepackage{newtxtext,newtxmath}
\usepackage{palatino}
\usepackage{lipsum}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}%多行公式依赖包
\usepackage{hyperref}
\usepackage{tabularray}
\newcommand{\upcite}[1]{\textsuperscript{\cite{#1}}}
\bibliographystyle{unsrt}%bib管理文献
\title{Your Paper's Title(SHUMOJIAYOUZHAN)}
% 这一段是备忘录部分,如果题目没有让写备忘录 或者书信 可以不要
% \author{\small \href{http://www.latexstudio.net/}
%    {\includegraphics[width=7cm]{mcmthesis-logo}}}
% \date{\today}

%  \memoto{\LaTeX{}studio}
% \memofrom{Liam Huang}
% \memosubject{Happy \TeX{}ing!}
% \memodate{\today}
%\memologo{\LARGE I'm pretending to be a LOGO!}

\begin{document}
\begin{abstract}
% lipsum为随机生产的内容,这一部分为摘要,使用时把\lipsum[1]替换为你摘要的内容
\lipsum[1]%随机生成文字
\\
hello!this is wisdom
\begin{keywords}
keyword1; keyword2; Coal
\end{keywords}
\end{abstract}
\maketitle
%% Generate the Table of Contents, if it's needed.
 \tableofcontents
 \newpage
%%
%% Generate the Memorandum, if it's needed.


%%\section为一级标题,\subsection为二级标题 \subsubsection为三级标题

\section{Introduction Stomatic}
It was the best of times, it was the worst of times,
 \\
 \autoref{eq0}
\begin{equation}\label{eq0}
  \alpha +\beta =\gamma ^2+\kappa \lambda 
\end{equation}
it was the age of wisdom, \par
it was the age of foolishness, 
it was the epoch of belief, it was the epoch of incredulity,
it was the season of Light,it was the season of darkness,
it was the spring of hope, it was the winter of despair.$\alpha +\beta $
\autoref{eq1}
\begin{equation}\label{eq1}
  \begin{split}
    &x+y=z\\
    &\alpha +\beta =\gamma ^2\\
    &sin\vartheta +cos\vartheta =1
  \end{split}
\end{equation}
%无编号公式
$$\alpha +\beta =\gamma ^2$$
\autoref{eq2}
\begin{equation}\label{eq2}
  F(x)=
 \begin{cases}
  0&,\text{if $x>3$}\\
  x+1&,\text{if $x>1$}\\
  1&,\text{otherwise.}
 \end{cases}
\end{equation}

\begin{figure}[htbp]%htbp是图片位置放置偏好
  \centering%居中
  %图片的大小与路径
  \includegraphics[width=12cm]{D:/P/毕业设计/配图/bode.png}
  \caption{bode}%图片的标题
\end{figure}


\begin{table}
  \centering
  \caption{wisdom}
  \begin{tblr}{
    column{1} = {c},
    hline{1-2,5} = {-}{},
  }
  name & num \\
  a    & 1   \\
  b    & 2   \\
  c    & 3   
  \end{tblr}
  \end{table}
% \begin{itemize}……\end{itemize}为列表文本
\lipsum[2]
\begin{itemize}
% \item为要点强调,表现为黑色圆点
\item minimizes the discomfort to the hands, or 
\item maximizes the outgoing velocity of the ball.
\item minnum of aust
\end{itemize}
We focus exclusively on the second definition.
\begin{itemize}
\item the initial velocity and rotation of the ball,
\item the initial velocity and rotation of the bat,
\item the relative position and orientation of the bat and ball, and
\item the force over time that the hitter hands applies on the handle.
\end{itemize}
\lipsum[3]
\begin{itemize}
\item the angular velocity of the bat,
\item the velocity of the ball, and
\item the position of impact along the bat.
\end{itemize}
\lipsum[4]
% 下述几种格式的效果可以去PDF里查看应用
\emph{center of percussion} [Brody 1986], \lipsum[5]
\begin{Theorem} \label{thm:latex}
\LaTeX
\end{Theorem}
\begin{Lemma} \label{thm:tex}
\TeX .
\end{Lemma}
\begin{proof}
The proof of theorem.
\end{proof}

\subsection{Other Assumptions of Abc}
\lipsum[6]
\begin{itemize}
\item hello
\item nihao
\item
\item
\end{itemize}

\lipsum[7]

\begin{algorithm}
  \caption{111}
  \begin{algorithmic}[1]
  \State $\text{Lambda} \gets 0.04$
  \State $\text{dr}_0 \gets 0.2$
  \State $t|\text{NR} \gets 0$
  \State $i \gets 0$
  \While{$i < n$}
      \State $r \gets \Call{Random}$
      \State $p \gets \Call{Exponential}{\text{Lambda}, t|\text{NR}}$
      \If{$r \leq p$}
          \State $\text{day}_\text{n} \gets \Call{RandomDays}$
          \For{$j \gets 1$ \textbf{to} $\text{day}_\text{n}$}
              \State $\text{dr}_j \gets 0.15 \cdot r + 0.6$
          \EndFor
      \Else
          \State $\text{dr} \gets \text{dr}_0$
          \State $t|\text{NR} \gets t|\text{NR} + 1$
      \EndIf
      \State $i \gets i + 1$
  \EndWhile
  \end{algorithmic}
  \end{algorithm}

\section{Analysis of the Problem}
% 
\begin{figure}[h]
\small
\centering
\includegraphics[width=12cm]{mcmthesis-aaa.eps}
\caption{aa} \label{fig:aa}
\end{figure}

\lipsum[8] \eqref{aa}

% \begin{equation}……\end{equation} 这种形式可以实现右编号
\begin{equation}
a^2 \label{aa}
\end{equation}
% \[   \]这种形式无编号
\[
  \begin{pmatrix}{*{20}c}
  {a_{11} } & {a_{12} } & {a_{13} }  \\
  {a_{21} } & {a_{22} } & {a_{23} }  \\
  {a_{31} } & {a_{32} } & {a_{33} }  \\
  \end{pmatrix}
  = \frac{{Opposite}}{{Hypotenuse}}\cos ^{ - 1} \theta \arcsin \theta
\]
\lipsum[9]

\[
  p_{j}=\begin{cases} 0,&\text{if $j$ is odd}\\
  r!\,(-1)^{j/2},&\text{if $j$ is even}
  \end{cases}
\]

\lipsum[10]

\[
  \arcsin \theta  =
  \mathop{{\int\!\!\!\!\!\int\!\!\!\!\!\int}\mkern-31.2mu
  \bigodot}\limits_\varphi
  {\mathop {\lim }\limits_{x \to \infty } \frac{{n!}}{{r!\left( {n - r}
  \right)!}}} \eqno (1)
\]

\section{Calculating and Simplifying the Model  }
\lipsum[11]

\section{The Model Results}
\lipsum[6]

\section{Validating the Model}
\lipsum[9]

\section{Conclusions}
\lipsum[6]

\section{A Summary}
\lipsum[6]

\section{Evaluate of the Mode}

\section{Strengths and weaknesses}
\lipsum[12]

\subsection{Strengths}
\begin{itemize}
\item \textbf{Appliep.p=p.s widely}\\
This  system can\upcite{qi2022waste} be used for many types of airplanes, and it also
solves the interference during  the \upcite{duan2024fma}procedure of the boarding
airplane,as described above we can get to the  optimization
boarding time.We also know that all the service is automate.
\item \textbf{Improve the quality of the airport service}\\
Balancing the cost of the cost and the benefit, it will bring in
more convenient  for airport and passengers\upcite{jiang2023review}.It also saves many
human resources\upcite{woo2023convnext} for the airline. \item \textbf{}
\end{itemize}

%使用bib引用文献
\bibliography{refer}


% %引用文献
% \begin{thebibliography}{99}
% \bibitem{1} D.~E. KNUTH   The \TeX{}book  the American
% Mathematical Society and Addison-Wesley
% Publishing Company , 1984-1986.
% \bibitem{2}Lamport, Leslie,  \LaTeX{}: `` A Document Preparation System '',
% Addison-Wesley Publishing Company, 1986.
% \bibitem{3}\url{http://www.latexstudio.net/}
% \bibitem{4}\url{http://www.chinatex.org/}
% \end{thebibliography}

\begin{appendices}

%  备忘录正文部分
%  \begin{memo}[Memorandum]
% 	\lipsum[1-3]
% \end{memo}

\section{First appendix}

\lipsum[13]

Here are simulation programmes we used in our model as follow.\\

\textbf{\textcolor[rgb]{0.98,0.00,0.00}{Input matlab source:}}
\lstinputlisting[language=Matlab]{./code/mcmthesis-matlab1.m}

\section{Second appendix}

some more text \textcolor[rgb]{0.98,0.00,0.00}{\textbf{Input C++ source:}}
\lstinputlisting[language=C++]{./code/mcmthesis-sudoku.cpp}

\end{appendices}
\end{document}

%% 
%% This work consists of these files mcmthesis.dtx,
%%                                   figures/ and
%%                                   code/,
%% and the derived files             mcmthesis.cls,
%%                                   mcmthesis-demo.tex,
%%                                   README,
%%                                   LICENSE,
%%                                   mcmthesis.pdf and
%%                                   mcmthesis-demo.pdf.
%%
%% End of file `mcmthesis-demo.tex'.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值