WinEdt(latex)详而简单教程

WinEdt(latex)详而简单教程最新的更新见 https blog csdn net Mr Cat123 article details 字体大小本文是笔者初学 WinEdt 用以编辑 Latex 的笔记

大家好,欢迎来到IT知识分享网。

最新的更新见

WinEdt(latex)详而简单教程

1.字体大小

1.字体大小

 

options—options interface—Font schemes—Font双击从右边找到FONT_SIZE将10改为自己想要的,如14—-保存—右键单击左边之前的Font—-Load Script—结束

2.分段机制

在原码中空一行,则生成的pdf会换行

3.空格

当然直接空一格也是可以得到一个空格的,如下:

 $a$, $b$, $c$. $a,\ b,\ c.$  The first three letter are a, b, c.
  • 1
  • 2
  • 3
  • 4
  • 5

4.自动补全

快捷键:Ctrl+Enter

5.数学模式与文本模式(包括行内公式和行间公式)

引入数学宏包{amssyb},American mathematics society symbol.例句如下

% !Mode::"TeX:UTF-8" \documentclass{article} \usepackage{amssymb} \begin{document} \section{symbol} 1+1=2, $$1+1=2$$, $I know 1+1=2,$  This is in text mode, $This is in math mode,$ $This\ is\ in\ math\ in\ mode.$  \end{document}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

6.输入函数

$\frac{ 
  10}{ 
  11}, \sqrt[3]{x^2+1}, \ldots, \sin x, \cos x.$
  • 1
$\frac{ 
  10}{ 
  11},$ $\sqrt[3]{x^2+1},$ $\ldots,$ $\sin x,$ $\cos x.$
  • 1

即每个函数单独用美元符号分开,并在两者之间加符号。

 $\sum_{ 
    n=1}^{ 
    \infty}$ $$\sum_{ 
    n=1}^{ 
    \infty}$$ $$\lim_{ 
    n \to \infty}(1+\frac{ 
    1}{ 
    n})^n = e,$$ $$\int_{ 
    -\infty}^{ 
    +\infty}\frac{ 
    \sin x}{ 
    x} \mathrm{ 
    d}x=I$$ $\alpha,\beta,\gamma,\delta\epsilon\varepsilon\xi\pi\rho\sigma\eta\theta\phi\varphi\omega$ $\Gamma\Phi$ $|A|,\|a\|,\vec{ 
    a},\overleftarrow{ 
    AB},\tilde{ 
    x},\widetilde{ 
    xyz},sin,\mathrm{ 
    sin}$ $\mathbb{ 
    AB},\mathbf{ 
    abAB}$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

这里写图片描述 
(1)第一行是行内公式和第二行的行间公式是不一样的,这是出于文本美观的目的。 
(2)\mathrm{d}那儿是为了和x不同,因为d是直立的而不是变量,而x是变量,这里mathrm=math roman 
(3)剩下的看到gamma等希腊字母第一个字母大写则表示输出的文本是大写,这里值得注意的是:alpha,beta,varepsilon等是没有大写形式的,因为其大写形式就是ABE,不能输入\Alpha,\Beta…… 
(4)mathbb=math blackboard, mathbf=math boldface 
实际上第行中的括号应该是大括号而不是小括号,细节见下节。




7.矩阵和大括号

先看矩阵

 \begin{equation} \left( \begin{array}{ccc} a_{ 
  11}& a_{ 
  12} & a_{ 
  13} \\ a_{ 
  21} & a_{ 
  22} & a_{ 
  23} \\ a_{ 
  31} & a_{ 
  32} & a_{ 
  33} \end{array} \right) \end{equation}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这里写图片描述 
(1)以上begin{equation}开始了一个公式环境,在这个环境中可以直接输入变量、函数等而不需要加$符号,上面等同于

 $$ \left( \begin{array}{ccc} a_{ 
  11}& a_{ 
  12} & a_{ 
  13} \\ a_{ 
  21} & a_{ 
  22} & a_{ 
  23} \\ a_{ 
  31} & a_{ 
  32} & a_{ 
  33} \end{array} \right)$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

(2)\left( and \right) are left bracket and right bracket. 能够通过括号内的内容自动改变括号大小。所以上面6中的第三行应该改为:

$$\lim_{ 
    n \to +\infty}\left(1+\frac{ 
    1}{ 
    n}\right)^n=e$$
  • 1

这里写图片描述 
(3)符号&是用来分隔列的,同一行不同列之间的元素用&分隔开 
(4){ccc}是array中必选参数,为center,center,center,表示三列都居中, 
(5)\是强制换行符号


8.分段函数

分段函数是在矩阵的基础之上的,比如如下的分段函数

 \begin{ 
   equation} f(x)= \left\{ 
    \begin{ 
   array}{ 
   cc} \int \mathrm{ 
   d}^3p\int_{ 
   0}^{ 
   \infty}\mathrm{ 
   d}x x^2 \frac{ 
   \delta(E-\sqrt{ 
   p^2+m^2})}{ 
   2E} , & x \geq 0 \\ 0,& x < 0 \end{ 
   array} \right. \end{ 
   equation}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

这里写图片描述 
这里写图片描述
(1)不需要右括号 
(2)&的作用是使得列对齐


9.加载宏包doc文档

10.输入中文以及宏包安装

输入中文需要用到ctex包,这是专门针对中文而设计的包,使用时在前面将

\document{article}
  • 1

改为

\document[UTF8]{ctexart}
  • 1

即可,(有的不需要加方括号中的内容),或者\document{article}不变,在其下加入一个宏包为

\usepackage[UTF8]{ctex}
  • 1

此外,中文包还可以使用

\usepackage{CJK}
  • 1

11.插入图片

插入图片需要加载宏包

\usepackage{graphicx}
  • 1

\usepackage{graphics}
  • 1
 \begin{ 
   figure}[ht] \centering \includegraphics[width=10cm]{ 
   hh} \caption{ 
   这个是图片}\label{ 
   bbb} \end{ 
   figure}
  • 1
  • 2
  • 3
  • 4
  • 5

当然也有不在工作目录下的方法,这个google一下by yourself.在此不累赘。(好吧,让我再告诉你好了,其实就是使用绝对路径

\includegraphics[width=10cm]{ 
  D:/software/tex/hh.png}
  • 1
\includegraphics[width=10cm]{fig/hh}
  • 1

(4)caption{这个是图片}表示对图片的描述,将出现在图片的底下。label{bbb}表示对这张图片的标签,相当于给定了这张图片的名字。图片较多时,建议使用容易看懂的名字,如label{fig.sub.1}。这个label的作用是方便以后引用这个图时只需要用其标签就可以,比如

see,figure\ref{fig.sub.1}
  • 1

结果就是:see,figure x(x表示刚刚插入的图的序号,如图3)

(5)这样插入的图片是一个浮动图,也就是latex自动找到最好的位置来放置此图,而不是你代码设置的地方,想要得到不浮动的图可以将

\includegraphics[width=10cm]{fig/hh}
  • 1

这句单独提取出来放置想要放的代码中即可,但这个时候是不能加

\caption{xxx}
  • 1

这一句的,也就是没法加入标题。如果要给不浮动的图形加标题,那么可以看看nonfloat 包或者自己google(这回是朕是真的不打算给你找了)。

12.表格

 \begin{tabular}{|c|c|} \hline % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ... Name & score \\ \hline 小明 & 50 \\ 小华 & 45 \\ \hline \end{tabular}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
\\ \hline
  • 1
 \begin{ 
   table} \centering \begin{ 
   tabular}{ 
   |c|c|} \hline % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ... Name & score \\ \hline 小明 & 50 \\ 小华 & 45 \\ \hline \end{ 
   tabular} \caption{ 
   这是一个表格} \end{ 
   table}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

同样的\centering是表格居中,否则居左。其他都讲过了,很easy.最后可以使用caption宏包,这个需要自行google。

彩色表格和字体

彩色表格

彩色表格需要用到宏包

\usepackage{xcolor}
  • 1

没有需要按照上面的方法先安装。因为是针对表格,所以需要支持表格,使用时要如下:

\usepackage[table]{xcolor}
  • 1

上面的例子可以加入彩色如下:

... \usepackage[table]{xcolor} ... ... \begin{table} \centering \rowcolors[\hline]{ 
  2}{orange}{red!30!yellow} \begin{tabular}{|c|c|} \rowcolor{red!20} Name & score \\ 小明 & 50 \\ 小华 & 45 \\ \hline \end{tabular} \caption{这是一个表格} \end{table}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
 \rowcolors[\hline]{2}{orange}{red!30!yellow}
  • 1
\rowcolor{red!20}
  • 1

如果没有则是白色。如果想要单独每行自行设置,也可以如下单独每行设置颜色

 \begin{ 
   table} \centering \begin{ 
   tabular}{ 
   |c|c|} \hline \rowcolor{ 
   red!20} Name & score \\ \hline \rowcolor{ 
   yellow} 小明 & 50 \\ \hline \rowcolor{ 
   orange} 小华 & 45 \\ \hline \end{ 
   tabular} \caption{ 
   这是一个表格} \end{ 
   table}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

彩色字体

同样是xcolor包

{\color{violet}{哇,这是我的第一个 \LaTeX{} Article!}}
  • 1

这里写图片描述 
这一行是通过一个大花括号括起来的(即最左和最后的括号),如果没有则整篇文章都是这种颜色的字体,括起来后就只有这一句话是这个颜色。

更多颜色设置见官网 and it’s pdf article

13.交叉引用(corss-reference)

关于引用部分上面已经提及了一些,上面11的(4)我们用的是\ref {xxx}这个命令。这个命令有一个缺点是它只给出图、定理等的序号,比如“如图2所示”当我们使用\ref时需要写成:

如图\ref{xxx}所示 
  • 1

当我们并不知道这个\ref{xxx}是图还是表格还是定理等等的时候就比较麻烦,或者我们不想输入“图”,“表格”这样的字眼,这时可以使用宏包(同样,如果没有宏包先按照上面的方法安装)

\usepackage{hyperref}
  • 1

然后将\ref {xxx}改为\autoref{xxx},e.g.

...... \usepackage{ 
   hyperref} ... ... \begin{ 
   equation} f(x)= \left\{ 
    \begin{ 
   array}{ 
   cc} \int \mathrm{ 
   d}^3p\int_{ 
   0}^{ 
   \infty}\mathrm{ 
   d}x x^2 \frac{ 
   \delta(E-\sqrt{ 
   p^2+m^2})}{ 
   2E} , & x \geq 0 \\ 0,& x < 0 \end{ 
   array} \right. \label{ 
   myequation} \end{ 
   equation} We all know \autoref{ 
   myequation} is a important equation
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

14.文章布局

(1)页面大小

使用tex得到的pdf很窄,左右空的地方很大,如果我们想让它跟微软中的word一样的页面,可以在导言部分加入以下命令

\usepackage[top=2.54cm, bottom=2.54cm, left=3.18cm,right=3.18cm]{geometry}
  • 1

(2)页眉页脚

参考文献见这里

使用宏包

\usepackage{fancyhdr}
  • 1

在导言部分加入

\usepackage{ 
   fancyhdr} \pagestyle{ 
   fancy} \lhead{ 
   wudl} \chead{ 
   $wudl's$ $tutorial article$} \rhead{ 
   \thesection} \cfoot{ 
   \thepage}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
\usepackage{ 
   fancyhdr} \usepackage{ 
   lastpage} \pagestyle{ 
   fancy} \lhead{ 
   wudl} \chead{ 
   $wudl's$ $tutorial article$} \rhead{ 
   \thesection} \cfoot{ 
   Page \thepage of \pageref{ 
   LastPage}}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

 

(3)列举 
这里写图片描述

这里写图片描述

 

(4)参考文献

A.手动输入

手动输入采用thebibliography环境,手动输入适合参考文献比较少的情况

 As is stated in \cite{bibitem1} blahblah\dots \begin{thebibliography}{9} \bibitem{bibitem1} 天朝. 朕的江山和子民[M]. 朕的天朝:天朝出版社. 2018 \bibitem{bibitem2} blahblah(ditto)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

B.使用Bibtex

这个比较复杂,以后再补充

15.超链接

使用

hyperref
  • 1

实际上面都用过这个了。

16.插入代码

参考百度知道

%导言部分 ... ... \usepackage{listings} %加入宏包 \lstset{language=Python} %Python语言 \lstset{breaklines} %自动将长的代码换行排版 \lstset{extendedchars=false} %解决代码跨页时,章节标题,页眉等汉字不显示的问题 ... ... %需要插入代码的地方 \begin{lstlisting} 放入代码 \end{lstlisting}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

例:自定义颜色(参考conding算子) 

自定义颜色使用了listings和color两个宏包

 

\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=Octave, % the language of the code basicstyle=\footnotesize, % the size of the fonts that are used for the code numbers=left, % where to put the line-numbers numberstyle=\tiny\color{gray}, % 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 }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

 

导入模块 

参考gaojiaxing 和 instant以python为例,下载python版本的hightlighting,地址点这里。下载完成要将pythonhighlight.sty和放在工作目录下。 
可以有两种方法来加载自己写的python代码。其一是将python代码在python自己的编辑器中写完保存为.py文件放到工作目录下(如test.py),之后加载的时候只需要\inputpython…即可,这种方法可以节省大量的WinEdt书写空间

 

... ... \usepackage{graphicx} \usepackage{pythonhighlight} ... ... \inputpython{test.py}{ 
  1}{ 
  41}#导入python文件test.py第一行到第41行 ...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

其二,可以通过

\begin{xxx} 代码 \end{xxx}
  • 1
  • 2
  • 3

例如:

 \begin{python} # from pyx import * def f(): g = graph.graphxy(width=8) g.plot(graph.data.function("y(x)=sin(x)/x", min=-15, max=15)) g.writePDFfile("function") print r'\includegraphics{function}' return f \end{python}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

17.目录

插入目录使用

\tableofcontents
  • 1

注意这句话要在\begin{document}之后,end之前,例如:

\documentclass{ 
   article} \usepackage{ 
   hyperref} \begin{ 
   document} \tableofcontents \section{ 
   A section} This is a section \paragraph{ 
   A paragraph} This is a paragraph \subsection{ 
   A subsection} This is a subsection \end{ 
   document}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

这里写图片描述 
注意上面的代码使用了超链接

\usepackage{hyerref}
  • 1

如果没有这个超链接是不会有红色部分的。

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/133024.html

(0)
上一篇 2025-07-26 21:33
下一篇 2025-07-26 21:45

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信