\documentclass[12pt, letterpaper]{article} \title{My first LaTeX document} \author{Hubert Farnsworth\thanks{Funded by the Overleaf team.}} \date{August 2022} \begin{document} \maketitle We have now added a title, author and date to our first \LaTeX{} document! \end{document}
\documentclass[12pt, letterpaper]{article} \title{My first LaTeX document} \author{Hubert Farnsworth\thanks{Funded by the Overleaf team.}} \date{August 2022} \begin{document} \maketitle We have now added a title, author and date to our first \LaTeX{} document!
% This line here is a comment. It will not be typeset in the document. \end{document}
7. 粗体、斜体和下换线
粗体:\textbf{}
斜体:\textit{}
$\underline{下划线}$:\underline{}
1 2 3
Some of the \textbf{greatest} discoveries in \underline{science} were made by \textbf{\textit{accident}}.
8. 添加图像
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
\documentclass{article} \usepackage{graphicx} %LaTeX package to import graphics \graphicspath{{images/}} %configuring the graphicx package \begin{document} The universe is immense and it seems to be homogeneous, on a large scale, everywhere we look.
% The \includegraphics command is % provided (implemented) by the % graphicx package \includegraphics{universe} There's a picture of a galaxy above. \end{document}
\begin{figure}[h] \centering \includegraphics[width=0.75\textwidth]{mesh} \caption{A nice plot.} \label{fig:mesh1} \end{figure} As you can see in figure \ref{fig:mesh1}, the function grows near the origin. This example is on page \pageref{fig:mesh1}.
\documentclass{article} \begin{document} \begin{itemize} \item The individual entries are indicated with a black dot, a so-called bullet. \item The text in the entries may be of any length. \end{itemize} \end{document}
其效果:
An example of bulleted lists in
LaTeX
有序列表:
1 2 3 4 5 6 7
\documentclass{article} \begin{document} \begin{enumerate} \item This is the first entry in our list. \item The list numbers increase with each entry we add. \end{enumerate} \end{document}
效果:
An example numbered list produced in
LaTeX
11. Adding math to LaTeX
11.1 inline math mode
1 2 3 4 5 6
\documentclass[12pt, letterpaper]{article} \begin{document} In physics, the mass-energy equivalence is stated by the equation $E=mc^2$, discovered in 1905 by Albert Einstein. \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{equation} E=m \end{equation} \end{document}
\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
\[ T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q}) \] We write integrals using $\int$ and fractions using $\frac{a}{b}$. Limits are placed on integrals using superscripts and subscripts:
\[\int_0^1 \frac{dx}{e^x} = \frac{e-1}{e} \]
Lower case Greek letters are written as $\omega$$\delta$ etc. while upper case Greek letters are written as $\Omega$$\Delta$.
Mathematical operators are prefixed with a backslash as $\sin(\beta)$, $\cos(\alpha)$, $\log(x)$ etc. \end{document}
\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}
Image showing a range of math typeset in
LaTeX
12. 基本文档结构
12.1 摘要
1 2 3 4 5 6 7
\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}
Image showing an abstract typeset in
LaTeX
12.2 段落与换行
写好摘要后,我们可以开始书写第一个段落。用 \\ 手动换行
or \newline 命令。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
\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}
After our abstract we can begin the first paragraph, then press ``enter'' twice to start the second one.
This line will start a second paragraph.
I will start the third 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}
Image showing the creation of paragraphs
in LaTeX
12.3 章节 - chapter
较长的文档通常被分为若干部分,章节、小节等。LaTeX中提供了文档结构化命令,但可用的命令和功能取决于文档类\documentclass。例如,\documentclass { book }
支持将文档划分为部分,但 \documentclass { letter }
不支持。
1 2 3 4 5 6 7 8 9 10 11 12 13
\documentclass { book } \begin { document }
\chapter {第一章}
\section {简介} 这是第一部分。 Lorem ipsum dolor 坐在 amet,consectetuer adipiscing elit。 Etiam lobortisfacilisis sem。 Nullam nec mi et neque pharetra sollicidin。 Praesent imperdietmi nec ante。 Donec ullamcorper,felis non sodales... \section {第二节} Lorem ipsum dolor sat amet,consectetuer adipiscing elit。 Etiam lobortis facilisissem。 Nullam nec mi et neque pharetra sollicidin。 Praesent imperdiet mi necante... \subsection {第一小节} Praesent imperdietmi necante。 Donec ullamcorper,felis non sodales... \section* {未编号部分} Lorem ipsum dolor sat amet,consectetuer adipiscing elit。 Etiam lobortis facilisissem... \end {文档}
\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... \section*{Unnumbered Section} \addcontentsline{toc}{section}{Unnumbered Section}
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}
Graphic showing a table of contents
produced by LaTeX