一. 基本架构
二. 细化内容
2.1. 注释
中的行注释符是%
若想在文档中显示
%
, 可以通过加斜杠的方式:\%
多行注释的话需要使用额外的包verbatim
, 如下
\documentclass{article}
\usepackage{verbatim}
\begin{document}
\begin{comment}
Multi-line comment content
Multi-line comment content
Multi-line comment content
\end{comment}
\end{document}
2.2. 文档序言
2.2.1. 序言定义
在 \begin{document}
之前输入的都称为序言, 序言定义了文档的类型、文档使用到的包、文档语言、文档显示效果等
2.2.2. 文档类型定义
设置字体大小为12pt
,
设置纸张大小为letterpaper
\documentclass[12pt, letterpaper]{article}
2.2.3. 中英文文档
2.2.3.1. 纯英文文档
\documentclass[12pt, letterpaper]{article}
2.2.3.2. 包含了中文的文档
\documentclass[UTF8]{cteart}
2.3. 标题、作者、日期
必须在主体begin
和end
之间添加\maketitle
才能显示添加的信息
2.3.1. 添加标题
\documentclass{article}
\title{LaTeX Learning}
\begin{document}
\maketitle
Hello, \LaTeX{}!
\end{document}
2.3.2. 添加作者
\documentclass{article}
\title{LaTeX Learning}
\author{Tomas Yang}
\begin{document}
\maketitle
Hello, \LaTeX{}!
\end{document}
2.3.3. 添加日期
2.3.3.1. 使用当前日期
编译后显示编译时刻的日期
\documentclass{article}
\title{LaTeX Learning}
\author{Tomas Yang}
\date{\today}
\begin{document}
\maketitle
Hello, \LaTeX{}!
\end{document}
2.3.3.2. 使用自定义日期
\documentclass{article}
\title{LaTeX Learning}
\author{Tomas Yang}
\data{December 2019}
\begin{document}
\maketitle
Hello, \LaTeX{}!
\end{document}
效果图:
2.4. 主体内容
位于begin
和end
之间的内容
2.4.1. 字体效果
2.4.1.1. 粗体字
textbf{}
, 括号内为加粗内容
2.4.1.2. 斜体字
textit{}
, 括号内为加粗内容
自适应斜体字的话是根据文字的内容自动判断是斜体还是非斜体, 使用方法是 \emph{}
, 括号内为加粗内容
2.4.1.3. 下划线
underline{}
, 括号内为下划线内容
2.4.2. 列表
2.4.2.1. 无序列表
\documentclass{article}
\begin{document}
\begin{itemize}
\item 123456789
\item 987654321
\end{itemize}
\end{document}
2.4.2.2. 有序列表
\documentclass{article}
\begin{document}
\begin{enumerate}
\item 123456789
\item 987654321
\end{enumerate}
\end{document}
2.4.3. 数学公式
2.4.3.1. 行内模式
数学公式存在于段落之间
\documentclass{article}
\begin{document}
In physics, $E=mc^2$ is very important.
\end{document}
2.4.3.2. 行间模式
单独成为一行的数学公式
\documentclass{article}
\begin{document}
In physics, this is very important.
$$E=mc^2$$
\end{document}
2.4.4. 图片
2.4.4.1. 上传图片
待上传的照片testLaTex.jpg
和.tex
在同一个目录下
\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {images/} }
\begin{document}
\includegraphics[scale=0.4]{testLaTeX.jpg}
%\includegraphics[width=5cm, height=5cm]{testLaTeX.jpg}
\end{document}
2.4.4.2. 图片放置位置控制(使用figure
环境)
首先交代控制参数:
符号 | 动作 |
---|---|
h | here, 表示在源码对应位置处插入图像 |
t | top, 表示在页顶部插入图像 |
b | bottom, 表示在页底部插入图像 |
p | page, 表示单独一页插入图像 |
使用方法:
\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {images/} }
\begin{document}
We can see some examples.
\begin{figure}[h]
%居中显示
\centering
\includegraphics[width=0.25\textwidth]{testLaTeX.jpg}
% 图像的标题
\caption{Test LaTeX}
%在文档中引用图片,用这个命令设置一个标签。标签自动对图像进行编号,并允许您引用它
\label{fig:mesh1}
\end{figure}
% \ref{fig:mesh1}引用标签号
As we showed in \ref{fig:mesh1}.
\end{document}
2.4.5. 超链接
为了引入超链接的使用, 需要使用hyperref
包,
其中:
\url{}
是直接插入地址, 即在正文中也显示为网络地址\href{}{}
则插入地址, 但在正文中可以显示为其他字样
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\url{https://www.baidu.com}
\href{https://www.baidu.com}{baidu}
\end{document}