\documentclass[12pt, letterpaper]{article} \begin{document} In physics, the mass-energy equivalence is started by the equation $E=mc^2$, discovered in 1905 by Albert Einstein. \end{document}
\documentclass[12pt, letterpaper]{article} \begin{document} \begin{math} E=mc^2 \end{math} is typeset in a paragraph using inline math mode —— as is $E=mc^2$, and so too is \(E=mc^2\). \end{document}
\documentclass[12pt, letterpaper]{article} \begin{document} The mass-energy equivalence is described by the famous equation \[ E=mc^2 \] discovered in 1905 by Albert Einstein.
In natural units ($c = 1$), the formula expresses the identity \begin{euqation} E=m \end{equation} \end{document}
为了排版展示模式数学,可以使用这些分隔符对:\[ … \], \begin{displaymath} … \end{displaymath} 或者\begin{euqation} … \end{equation}。历史遗留地,排版展示模式数学需要使用 $$ 符号分隔符,如:$$ …display math here …$$,但这个方法不再被推荐使用,使用\[ … \]以替代这种方式。
更完整的例子
以下的例子演示了很多使用LaTeX排版的数学内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
\documentclass{article} \begin{document} Subscripts in math mode are written as $a_b$ and superscripts are written as $a^b$. These can be combined and nested to write expressions such as
\documentclass{article} \usepackage{amsmath} % For the equation* environment \begin{document} \section{First example}
The well-known Pythagorean theorem \(x^2 + y^2 = z^2\) was proved to be invalid for other exponents, meaning the next equation has no integer solutions for \(n>2\):
\[ x^n + y^n = z^n \]
\section{Second example}
This is a simple math expression \(\sqrt{x^2+1} \) inside text. And this is also the same: \begin{math} \sqrt{x^2+1} \end{math} but by using another command.
This is a simple math expression without numbering \[\sqrt{x^2+1}\] separated from text.
This is also the same: \begin{displaymath} \sqrt{x^2+1} \end{displaymath}
\ldots and this: \begin{equation*} \sqrt{x^2+1} \end{equation*} \end{document}
\documentclass{article} \begin{document} \begin{abstract} This is a simple paragraph at the beginning of the document. A brief introduction about the main subject. \end{abstract} \end{document}
\begin{abstract} This is a simple paragraph at the beginning of the document. A brief introduction about the main subject. \end{abstract}
After our abstract we can begin the first paragraph, the press ''enter'' twice to start the second one.
This line will start a second paragraph.
I will start the paragraph and then add \\ a manual line break which causes this text to start on a new line but remains part of the same paragraph. Alternatively, I can use the \verb|\newline|\newline command to start a new line, which is also part of the same paragraph. \end{document}
更长的文章,无论(irrespective of)使用什么创作软件,通常被分为parts(部分)、chapters(章节)、sections(节)、subsections(小节)等等。LaTeX也提供文档结构命令,但是可用的命令以及他们的实现(以及他们的作用)可能取决于使用的文档类(class)。举例来说(By way of example),使用 book 类创建的文档可以被划分为parts、chapters、sections、subsections等等,但letter类不支持任何指令来做到这些。
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi necante...
\subsection{First Subsection} Praesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...
\section*{Unnumbered Section} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem... \end{document}
这个tabular环境是LaTeX的默认的创建表的方法。你必须指定一个参数给这个环境,这里是{c c c},告知LaTeX将会有三列,并且里面的文本会居中(c)。也可以使用r来右对齐文本,或者使用l来左对齐文本。对齐符号&被用来在一个表行中划定独立的表单元。为了结束一个表行可以使用\\指令。我们的表被包裹在一个center环境中,使表在页面的文本宽度内居中。
\documentclass{article} \title{Sections and Chapters} \author{Gubert Farnsworth} \date{August 2022} \begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi necante...
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi necante... \end{document}