【LaTeX】
基本使用
\documentclass
类型:文章(article)、报告(report)、书(book)
中文的文章是ctexart,中文字体是UTF8
\documentclass[UTF8]{ctexart}
[]说明可以省略不写的意思,默认可选,{}是必须写的意思
/usepackage
写个公式,做个表格。放个图片
“宏包”,加了宏包才能够写公式,做表格,放图片
\usepackage{第一个宏包,第二个宏包,……}
比如说常用的有mathtools,amsmath,graphicx,array之类
\usepackage{mathtools,amsmath,graphicx,array}
在哪里写?
先建立一个“文档环境”,这个环境里面只来访文档内容,什么宏包和文档类型都在这个外面。
环境的建立方式是:
\begin{环境名字}
内容
\end{环境名字}
\documentclass{article}\begin{document}Hello, world! \end{document}
\documentclass和\usepackage都是“命令”
\begin{document} \end{document}是“环境”
用“\”开头(转义字符),说明是用来控制排版之类的
\documentclass[UTF8]{ctexart} %我想写一篇文章
\usepackage{mathtools,amsmath,graphicx,array} %我要写一篇文章啦
\begin{document} %正在写一篇文章
文章内容
\end{document}
两行内容,中间空一行
\documentclass{article}\begin{document}Hello, world!Bye!
\end{document}
开始写
文本
段与段之间需要空一行,这样才能让输出文本分段
关于字体的几个命令/环境:
加粗:\textbf{内容}
\documentclass{article}\begin{document}Hello, world!\textbf{text}Bye!
\end{document}
字号:\normalsize \large \Large \LARGE \huge \Huge
字号大小在一个环境内或者{}之间生效
\documentclass{article}\begin{document}Hello, world!\textbf{text}\LARGEBye!
\end{document}
\documentclass{article}\begin{document}Hello, world!\textbf{text}\LARGE{Bye!}bye!
\end{document}
居中:\begin{center} 内容 \end{center}
\documentclass{article}\begin{document}Hello, world!\textbf{text}\LARGE{Bye!}\begin{center}\hugebye!\end{center}bye!
\end{document}
文章标题与作者、日期
\title{标题名}
\author{作者名}
\data{日期}
\maketile
\documentclass{article}\begin{document}\title{AAAA}\author{BBB}\date{2025-04-12}\maketitleblabla
\end{document}
章节的划分
一级章节\section{章节名}
二级章节\subsection{章节名}
三级章节\subsubsection{章节名}
添加目录
\tableofcontents
摘要环境
\begin{abstract}
摘要内容
\end{abstract}
大小,页边距
列表环境
\begin{enumerate}
\item第一个
\item第二个
……
\end{enumerate}
%\documentclass{article}
\documentclass[UTF8]{ctexart}
\usepackage{mathtools,booktabs}\begin{document}\title{小风寒讲LaTeX}\author{小风寒呐}\maketitle\tableofcontents\newpage\section{LaTeX的使用}\subsection{LaTeX的基本知识}\subsubsection{LaTeX结构}LaTeX我们可以将其分为以下三个部分:\begin{enumerate}\item 说明文档类型(我想写一篇文章);\item 说明用的宏包(我要开始写一篇文档);\item 文档环境(我正在写一篇文档);\end{enumerate}\subsubsection{LaTeX文档类型}我要说明你写的文档类型,有三个类型:文章(article)、报告(report)、书(book)。咱们写论文的话用“文章”article。中文的文章是ctexart,中文字体是UTF8。所以写的代码就是\textbackslash documentclass[UTF8]\{ctexart\}其中的[]说明可以省略不写,默认;\{ \}必须写。\subsection{1.2 LaTeX开始写作}在你这个编辑器里面找“编译”这个按钮--把tex文件里面写的代码全部“整合翻译”成好看的pdf文档如果你不知道在哪里看(或者自己没有跳出来pdf),在编译器里面找“查看”这个按钮,点一下就行了。或者说进去你保存这个tex文件的那个目录里面,里面有你的pdf和document。\end{document}