关于latex:Y-分钟速成-latex

2次阅读

共计 5428 个字符,预计需要花费 14 分钟才能阅读完成。

源代码下载:learn-latex-cn.tex

% 所有的正文行以 % 结尾
% 没有多行正文语法

% LaTeX 不是一个“所见即所得”的文字处理软件
% 这与 MS Word,和 OpenOffice Writer 不同

% 每一个 LaTeX 命令由反斜线 (\) 开始

% LaTeX 文档以对编译对象文档的定义开始
% 这些文档包含书籍,报告,演示等
% 文档的选项呈现在中括号里
% 下例中,咱们设定文章字体为 12pt
\documentclass[12pt]{article}

% 之后咱们定义该文档所用的库
% 如果想要引入图片,黑白字,或是其余语言的源码在您的文档中
% 您须要加强 LaTeX 的性能。这将通过增加库来实现
% 下例中将要为展现数据引入 float 和 caption 库
% 为超链接引入 hyperref 库
\usepackage{caption}
\usepackage{float}
\usepackage{hyperref}

% 咱们还能够定义其余文档属性!\author{Chaitanya Krishna Ande, Colton Kohnke, Sricharan Chiruvolu \& \\
Svetlana Golubeva}
\date{\today}
\title{Learn \LaTeX \hspace{1pt} in Y Minutes!}

% 当初咱们开始注释
% 这一行之前都是“序章”\begin{document} 
% 如果想设定作者,工夫,题目字段咱们可应用 LaTeX 来建设题目页
\maketitle

% 分章节时,能够建设目录
% 咱们须要编译文档两次来保障他们程序正确
% 应用目录来离开文档是很好的做法
% 这里咱们应用 \newpage 操作符
\newpage
\tableofcontents

\newpage

% 许多钻研论文有摘要局部。这能够应用预约义的指令来实现
% 它应被放在逻辑上正确的地位,即顶部题目等的上面和文章主体的下面
% 该指令能够再报告和文章中应用
\begin{abstract}
 \LaTeX \hspace{1pt} documentation written as \LaTeX! How novel and totally not
 my idea!
\end{abstract}

% 章节指令十分直观
% 所有章节题目会主动地增加到目录中
\section{Introduction}
Hello, my name is Colton and together we're going to explore \LaTeX!

\section{Another section}
This is the text for another section. I think it needs a subsection.

\subsection{This is a subsection} % 子章节同样十分直观
I think we need another one

\subsubsection{Pythagoras}
Much better now.
\label{subsec:pythagoras}

% 应用型号咱们能够借助 LaTeX 内置的编号性能
% 这一技巧也在其余指令中无效
\section*{This is an unnumbered section} 
然而并不是所有章节都要被标序号

\section{Some Text notes}
%\section{Spacing} % 须要减少无关空白距离的信息
\LaTeX \hspace{1pt} is generally pretty good about placing text where it should
go. If 
a line \\ needs \\ to \\ break \\ you add \textbackslash\textbackslash 
\hspace{1pt} to the source code. \\ 

\section{Lists}
Lists are one of the easiest things to create in \LaTeX! I need to go shopping
tomorrow, so let's make a grocery list.
\begin{enumerate} % 此处创立了一个“枚举”环境
  % \item 使枚举减少一个单位
  \item Salad.
  \item 27 watermelon.
  \item A single jackrabbit.
  % 咱们甚至能够通过应用 [] 笼罩美剧的数量
  \item[how many?] Medium sized squirt guns.

  Not a list item, but still part of the enumerate.

\end{enumerate} % 所有环境都有终止符

\section{Math}

应用 \LaTeX \hspace{1pt} 的一个最次要的方面是学术论文和技术文章
通常在数学和迷信的畛域 
因而咱们须要在文章中插入特殊符号!\\

数学符号极多,远超出你能在键盘上找到的那些;汇合关系符,箭头,操作符,希腊字符等等 \\

汇合与关系在数学文章中很重要
如申明所有 x 属于 X $\forall$ x $\in$ X. \\
% 留神咱们须要在这些符号之前和之后减少 $ 符号
% 因为在编写时咱们处于 text-mode,然而数学符号只在 math-mode 中存在
% text mode 进入 math-mode 应用 $ 操作符
% 反之亦然,变量同时会在 math-mode 中被渲染。% 咱们也能够应用 \[\] 来进入 math mode

\[a^2 + b^2 = c^2 \]

My favorite Greek letter is $\xi$. I also like $\beta$, $\gamma$ and $\sigma$.
I haven't found a Greek letter yet that \LaTeX \hspace{1pt} doesn't know
about! \\

罕用函数操作符同样很重要:trigonometric functions ($\sin$, $\cos$, $\tan$), 
logarithms 和 exponentials ($\log$, $\exp$), 
limits ($\lim$), etc. 
在 LaTeX 指令中预约义 
让咱们写一个等式看看产生了什么:$\cos(2\theta) = \cos^{2}(\theta) - \sin^{2}(\theta)$ \\

分数能够写成以下模式:% 10 / 7
$$ ^{10}/_{7} $$

% 绝对比较复杂的分数能够写成
% \frac{numerator}{denominator}
$$ \frac{n!}{k!(n - k)!} $$ \\

咱们同样能够插入公式(equations)在环境 ``equation environment'' 下。% 展现数学相干时,应用方程式环境
\begin{equation} % 进入 math-mode
    c^2 = a^2 + b^2.
    \label{eq:pythagoras} % 为了下一步援用
\end{equation} % 所有 \begin 语句必须有 end 语句对应

援用咱们的新等式!Eqn.~\ref{eq:pythagoras} is also known as the Pythagoras Theorem which is also
the subject of Sec.~\ref{subsec:pythagoras}. A lot of things can be labeled: 
figures, equations, sections, etc.

求和(Summations)与整合(Integrals)写作 sum 和 int:% 一些编译器会揭示在等式环境中的空行

\begin{equation} 
  \sum_{i=0}^{5} f_{i}
\end{equation} 
\begin{equation} 
  \int_{0}^{\infty} \mathrm{e}^{-x} \mathrm{d}x
\end{equation} 

\section{Figures}

让咱们插入图片。图片的搁置十分奥妙。我在每次应用时都会查找可用选项。\begin{figure}[H] % H 是搁置选项的符号
    \centering % 图片在本页居中
    % 宽度放缩为页面的 0.8 倍
    %\includegraphics[width=0.8\linewidth]{right-triangle.png} 
    % 须要应用想象力决定是否语句超出编译预期
    \caption{Right triangle with sides $a$, $b$, $c$}
    \label{fig:right-triangle}
\end{figure}

\subsection{Table}
插入表格与插入图片形式雷同

\begin{table}[H]
  \caption{Caption for the Table.}
  % 下方的 {} 形容了表格中每一行的绘制形式
  % 同样,我在每次应用时都会查找可用选项。\begin{tabular}{c|cc} 
    Number &  Last Name & First Name \\ % 每一列被 & 离开
    \hline % 水平线
    1 & Biggus & Dickus \\
    2 & Monty & Python
  \end{tabular}
\end{table}

\section{Getting \LaTeX \hspace{1pt} to not compile something (i.e. Source Code)}
当初减少一些源代码在 \LaTeX \hspace{1pt} 文档中,咱们之后须要 \LaTeX \hspace{1pt} 不翻译这些内容而仅仅是把他们打印进去
这里应用 verbatim environment。% 也有其余库存在 (如. minty, lstlisting, 等)
% 然而 verbatim 是最根底和简略的一个
\begin{verbatim} 
  print("Hello World!")
  a%b; % 在这一环境下咱们能够应用 %
  random = 4; #decided by fair random dice roll
\end{verbatim}

\section{Compiling} 

当初你大略想理解如何编译这个美好的文档
而后失去饱受称誉的 \LaTeX \hspace{1pt} pdf 文档
(这个文档的确被编译了)。\\
失去最终文档,应用 \LaTeX \hspace{1pt} 组合步骤:\begin{enumerate}
    \item Write the document in plain text (the ``source code'').
    \item Compile source code to produce a pdf. 
     The compilation step looks like this (in Linux): \\
     \begin{verbatim} 
        > pdflatex learn-latex.tex
     \end{verbatim}
  \end{enumerate}

许多 \LaTeX \hspace{1pt} 编译器把步骤 1 和 2 在同一个软件中进行了整合
所以你能够只看步骤 1 齐全不看步骤 2
步骤 2 同样在以下情境中应用情景 \footnote{ 以防万一,当你应用援用时
 (如 Eqn.~\ref{eq:pythagoras}),你将须要屡次运行步骤 2
来生成一个媒介文件 *.aux。}.
% 同时这也是在文档中减少脚标的形式

在步骤 1 中,用一般文本写入格式化信息
步骤 2 的编译阶段则留神在步骤 1 中定义的格局信息。\section{Hyperlinks}
同样能够在文档中退出超链接
应用如下命令在序言中引入库:\begin{verbatim} 
    \usepackage{hyperref}
\end{verbatim}

有两种次要的超链接形式 \\
\url{https://learnxinyminutes.com/docs/latex/},或  
\href{https://learnxinyminutes.com/docs/latex/}{shadowed by text}
% 你不能够减少非凡空格和符号,因为这将会造成编译谬误

这个库同样在输入 PDF 文档时制作略缩的列表,或在目录中激活链接


\section{End}

这就是全部内容了!% 通常,你会心愿文章中有个援用局部
% 最简略的建设形式是应用书目提要章节
\begin{thebibliography}{1}
  % 与其余列表雷同,\bibitem 命令被用来列出条目
  % 每个记录能够间接被文章主体援用
  \bibitem{latexwiki} The amazing \LaTeX \hspace{1pt} wikibook: {\em 
https://en.wikibooks.org/wiki/LaTeX}
  \bibitem{latextutorial} An actual tutorial: {\em http://www.latex-tutorial.com}
\end{thebibliography}

% 完结文档
\end{document}

LaTeX 进阶

  • The amazing LaTeX wikibook: https://en.wikibooks.org/wiki/LaTeX
  • An actual tutorial: http://www.latex-tutorial.com/

有倡议?或者发现什么谬误?在 Github 上开一个 issue,或者发动 pull request!


原文由 Chaitanya Krishna Ande 编写,并由 3 个好心人 批改。
Translated by:Dp Leo
© 2022 Chaitanya Krishna Ande, Colton Kohnke, Sricharan Chiruvolu, Ramanan Balakrishnan, Svetlana Golubeva
本作品采纳 CC BY-SA 3.0 协定进行许可。

正文完
 0