LaTeX入门:10分钟掌握核心用法 - 详解

Latex 中的基本结构

LaTeX 文档通常以 \documentclass 开头,指定文档类型(如 article, report, book)。正文内容写在 \begin{document}\end{document} 之间。

\documentclass{article}
\begin{document}
Hello, LaTeX!
\end{document}

数学公式

LaTeX 支持行内公式和独立公式。行内公式用 $...$ 包裹,独立公式用 \[...\]equation 环境。

  • 行内公式:$E=mc^2$ 显示为 $E=mc^2$
  • 独立公式:
    \[
    \sum_{i=1}^n i = \frac{n(n+1)}{2}
    \]

常用数学符号

  • 上下标:x^2($x^2$),x_i($x_i$)
  • 分式:\frac{a}{b}($\frac{a}{b}$)
  • 根号:\sqrt{x}($\sqrt{x}$),\sqrt[n]{x}($\sqrt[n]{x}$)
  • 希腊字母:\alpha($\alpha$),\beta($\beta$)

表格与列表

  • 表格使用 tabular 环境:
    \begin{tabular}{|c|c|}
    \hline
    A & B \\ \hline
    1 & 2 \\ \hline
    \end{tabular}

  • 列表分为无序(itemize)和有序(enumerate):
    \begin{itemize}
    \item First item
    \item Second item
    \end{itemize}

插入图片

使用 graphicx 宏包和 \includegraphics 命令插入图片:

\usepackage{graphicx}
...
\includegraphics[width=0.5\textwidth]{example.png}

参考文献

使用 \cite 引用文献,配合 thebibliography 环境或 BibTeX:

\cite{key}
\begin{thebibliography}{9}
\bibitem{key} Author, Title, Year.
\end{thebibliography}

自定义命令

通过 \newcommand 定义新命令,简化重复输入:

\newcommand{\vect}[1]{\mathbf{#1}}
\vect{v}  % 显示为加粗的 v

以上是 LaTeX 的常用功能,更多细节可参考官方文档或扩展宏包(如 amsmath 用于高级数学公式)。

posted @ 2025-09-22 18:58  yxysuanfa  阅读(16)  评论(0)    收藏  举报