Latex使用手册记录

入门可以看一下下面的部分内容

1.LaTeX软件的安装和使用 
方法A(自助):在MikTeX的官网下载免费的MikTeX编译包(150Mb)并安装。下载WinEdt(9.5Mb)(收费)或TexMaker(32Mb)(免费)等编辑界面软件并安装。 
方法B(打包):在ctex.org下载ctex套装(203Mb或1.3Gb)(含MikTeX及WinEdt)

哈哈这一部分当然不包含在标题的30分钟里。

新人不必纠结软件问题,随便什么软件随便什么版本只要下载下来能编译出pdf来就可以,先下载了装上来试试再说。我推荐winedt也是方便我在介绍按钮样子的时候可以统一描述。在真正开始跑步之前没有必要纠结该买NIKE跑鞋还是ADI跑鞋,跑起来再说。不要瞻前顾后,just try it.

2.第一个文档 
打开WinEdt,建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8。 

documentclass{article} 
egin{document} 
  hello, world 
end{document} 

然后在WinEdt的工具栏中找到编译按钮(在垃圾桶和字母B中间),在下拉菜单中选择XeLaTeX,并点击编译。 (这里请注意一下我之前一直笔误写的XeTeX,给大家带来困扰深感歉意) 
如果顺利的话,我们就可以顺利生成出第一个pdf文件,点击工具栏中的放大镜按钮就可以快速打开生成的pdf文件。 


3.标题、作者和注释 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 

documentclass{article} 
  author{My Name} 
  itle{The Title} 
egin{document} 
  maketitle 
  hello, world % This is comment 
end{document}

%为本行右边所有内容被注释掉,在生成的pdf中不会显示。

块注释也有专门的语句,不过更方便的方式是选中一块区域点鼠标右键,点comment 


4.章节和段落 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 

documentclass{article} 
  itle{Hello World} 
egin{document} 
  maketitle 
  section{Hello China} China is in East Asia. 
    subsection{Hello Beijing} Beijing is the capital of China. 
      subsubsection{Hello Dongcheng District} 
        paragraph{Tian'anmen Square}is in the center of Beijing 
          subparagraph{Chairman Mao} is in the center of Tian'anmen Square 
      subsection{Hello Guangzhou} 
        paragraph{Sun Yat-sen University} is the best university in Guangzhou. 
end{document} 

退格只是我个人偏好,看起来层次清晰美观。实际操作上未必要如此,每一行之前的空格不影响编译生成PDF的排版结果。 


5.加入目录 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察现象。 

documentclass{article} 
egin{document} 
  ableofcontents 
  section{Hello China} China is in East Asia. 
    subsection{Hello Beijing} Beijing is the capital of China. 
      subsubsection{Hello Dongcheng District} 
        paragraph{Hello Tian'anmen Square}is in the center of Beijing 
          subparagraph{Hello Chairman Mao} is in the center of Tian'anmen Square 
end{document} 

6.换行 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 
documentclass{article} 
egin{document} 
  Beijing is 
  the capital 
  of China. 

  Washington is 

  the capital 

  of America. 

  Amsterdam is \ the capital \ 
  of Netherlands. 
end{document}

空一行为另起一段,\为段内强制换行。

我对之前手滑写出New York is the capital of America这类低级错误表示非常抱歉。

7.数学公式 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 

documentclass{article} 
  usepackage{amsmath} 
  usepackage{amssymb} 
egin{document} 
  The Newton's second law is F=ma. 

  The Newton's second law is $F=ma$. 

  The Newton's second law is 
 

F=maF=ma

 

  The Newton's second law is 
 

F=maF=ma

 

  Greek Letters $eta$ and $mu$ 

  Fraction $frac{a}{b}$ 

  Power $a^b$ 

  Subscript $a_b$ 

  Derivate $frac{partial y}{partial t} $ 

  Vector $vec{n}$ 

  Bold $mathbf{n}$ 

  To time differential $dot{F}$ 

  Matrix (lcr here means left, center or right for each column) 
  [ 
    left[ 
      egin{array}{lcr} 
        a1 & b22 & c333 \ 
        d444 & e555555 & f6 
      end{array} 
    ight] 
  ] 

Equations(here & is the symbol for aligning different rows) 
egin{align} 
  a+b&=c\ 
  d&=e+f+g 
end{align} 


  left{ 
    egin{aligned} 
      &a+b=c\ 
      &d=e+f+g 
    end{aligned} 
  ight. 


end{document} 

具体细节可以自行搜索LaTeX的数学符号表或别人给的例子。

$...$是开启行内数学模式,用于和文本合在一起使用。

......

......

是另起一行居中开启数学模式。通常用起来差别不是很大,不过$$会修改默认的公式行间距,有时可能会对文章的整体效果有影响。

有一些网站可以通过画图的方式来生成公式,有的编辑器集成了各种数学功能按钮。这对于公式需求少的人来说很方便,具体信息可以自己去搜索。但是如果你的文章中要出现大段的证明过程,就会发觉还是老老实实地google一篇latex数学符号表,然后不懂的去查代码,自己用手指敲来得干脆利索。再进阶一点,可以去搜一下有关LaTeX的自定义command的内容去看一下,在敲公式时能省很多力气。

8.插入图片 
将待插入的图片姑且先命名为figure1.jpg 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,放在和图片文件同一个文件夹里,编译并观察现象。 

documentclass{article} 
  usepackage{graphicx} 
egin{document} 
  includegraphics[width=4.00in,height=3.00in]{figure1.jpg} 
end{document}

在老版本的LaTeX中是只支持eps图片格式的,现在的LaTeX对jpg、bmp、png等等常见图片都可以支持。

9.简单表格 
建立一个新文档,将以下内容复制进入文档中,保存,保存类型选择为UTF-8,编译并观察对比现象。 

documentclass{article} 
egin{document} 
  egin{tabular}{|c|c|} 
    aaa & b \ 
    c & ddddd\ 
  end{tabular} 

  egin{tabular}{|l|r|} 
    hline 
    aaaa & b \ 
    hline 
    c & ddddd\ 
    hline 
  end{tabular} 

  egin{center} 
    egin{tabular}{|c|c|} 
      hline 
      a & b \ hline 
      c & d\ 
      hline 
    end{tabular} 
  end{center} 
end{document}

注意观察有无hline和有无egin{center}的区别。注意观察egin{tabular}后的lcr的区别,分别是left对齐,center对齐和right对齐。 

详细的Latex手册可以看下这篇博客

https://blog.csdn.net/gsww404/article/details/78684278?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase

可以看一下一部分完成的工作展示、

documentclass{article}
usepackage{CJK}
usepackage{ctex}
usepackage{amsmath}
egin{document}
egin{CJK*}{GBK}{song}

作业一:\

要使公式$maxlimits_{p_{1},...,p_{m}}-sumlimits_{k=1}^{m}p_{k}logp_{k}$ 熵最大,根据最大熵原则可以引入拉格朗日因子$w_{0}$来表示对$sumlimits_{k=1}^mp_{k}=1$ 的限制。有定义一个拉格朗日函数:
egin{equation}
L(p,w)=sumlimits_{i=1}^{m}p(y_{i})logp(y_{i})+w_{0}(sumlimits_{i=1}^{m}p(y_{i})-1)
end{equation}

根据拉格朗日对偶性,可以通过求解拉格朗日对偶最优化问题得到原始最优解的解,所以求解
egin{equation}
maxlimits_{w}minlimits_{p}L(p,w)
end{equation}
首先可以先求解关于P的极小化问题,固定w0,求偏导数:
egin{equation*}
egin{aligned}
partial L(p,w)/partial p(y_{1}) &= 1+logp(y_{1}) + w0
\
partial L(p,w)/partial p(y_{2}) &= 1+logp(y_{2}) + w0
\
......
\
partial L(p,w)/partial p(y_{m}) &= 1+logp(y_{m}) + w0
\
end{aligned}
end{equation*}
令各偏导数为零,解得:
egin{equation*}
egin{aligned}
p(y_{1})=p_{2}=...=p(y_{m})=e^{-w0-1}
end{aligned}
end{equation*}
带入于是得
egin{equation*}
egin{aligned}
minlimits_{p}L(p,w) = L(p_{w},w) = -me^{-w_{0}-1}-w_{0}
end{aligned}
end{equation*}
再求解$L(p_{w},w)$关于w得极大化问题:
egin{equation*}
egin{aligned}
maxlimits_{w}L(p,w) = L(p_{w},w) = -me^{-w_{0}-1}-w_{0}
end{aligned}
end{equation*}
分别对$L(P_{w},w)$对$w_{0}$的偏导数并令其为0,得到:$me^{-w_{0}-1}= 1$
所以$e^{-w_{0}-1} = 1/m$因此当每个$p_{i}=1/m$时取得最大熵,代入求得最大熵是$logm$


作业二:

因为
egin{equation*}
egin{aligned}
因为int_{x}p_{data}(x)logD(x)\, dx + int_{x}p_{G}(x)log(1-D(x))\, dx
\
=int_{x}[p_{data}(x)logD(x) + p_{G}(x)log(1-D(x))]\, dx
end{aligned}
end{equation*}
为简化表示,此时令$a = p_{data}(x)$, $b = logD(x)$, $c =p_{G}(x) $, $D = log(1-D(x))$
寻找一个x,这个最优化的D*使式子$aD + bD$最大即可,有
egin{equation*}
egin{aligned}
df(D)/dD &= a*1/D + b*1/(1-D)*(-1) = 0\
a*1/D^{*} &= b*1/(1-D^{*})\
a*(1-D^{*}) &= b*D^{*}\
a - a*D^{*} &= b*D^{*}\
D^{*} &= a/(a+b)\
所以 D*(x) &= p_{data}(x)/p_{data}(x)+P_{G}(x)\
end{aligned}
end{equation*}
为最优判别器
end{CJK*}
end{document}

原文地址:https://www.cnblogs.com/henuliulei/p/13779500.html