耿楠《LaTeX 中文教程》随堂学习记录

跟着耿楠教授的视频教程 《latex中文教程》 学了一遍,并根据视频把课堂内容实际操作了一下,把实现的有关 TeX 文档记录整理到本文。

1 TeX 文件记录

1.1 LaTeX 环境的安装与配置

% test.tex

\documentclass{article}

\usepackage{ctex}

\begin{document}
你好, \LaTeX 。
\end{document}
% test_texstudio.tex

\documentclass{article}

\usepackage{ctex}

\begin{document}
	你好, \LaTeXe 。
\end{document}

1.2 LaTeX 源文件结构

% latex_basic.tex

% 导言区
\documentclass{article}
\title{My First Document}
\author{Shaofeng Gu}
\date{\today}

% 正文区
\begin{document}
	\maketitle
	
	Hello World!
	
	% here is my big formula
	Let $f(x)$ be defined by the formula $$f(x)=3x^2+x-1$$ which is a polynomial of degree 2.
\end{document}

1.3 LaTeX 中的中文处理办法

% latex_zh.tex

% 导言区
\documentclass{ctexbook}

%\usepackage{ctex}

\newcommand\degree{^\circ}

\title{\heiti 杂谈勾股定理}
\author{\kaishu 张三}
\date{\today}

% 正文区
\begin{document}
	\maketitle
	
	勾股定理可以用现代语言描述如下:
	
	直角三角形斜边的平方等于直角边的平方和。
	
	可以用符号语言表述为:设直角三角形 $ABC$,其中 $\angle C=90\degree$,则有:
	\begin{equation}
		AB^2 = BC^2 + AC^2.
	\end{equation}
	
	% here is my big formula
	Let $f(x)$ be defined by the formula $$f(x)=3x^2+x-1$$ which is a polynomial of degree 2.
\end{document}

1.4 LaTeX 的字体字号设置

% latex_textFormat.tex

% 导言区
\documentclass[10pt]{article}

\usepackage{ctex}
 
\newcommand{\myfont}{\textbf{\textsf{Fancy Text}}}

% 正文区
\begin{document}
	% 字体族设置(罗马字体、无衬底字体、打字机字体)
	\textrm{Roman Family} \textsf{Sans Serif Family} \texttt{Typewriter Family}
	
	{\rmfamily Roman Family} {\sffamily Sans Serif Family} {\ttfamily Typewriter Family}
	
	\ttfamily who you are? you find ! who you are? you find ! who you are? you find ! who you are? you find !
	
	Are you?
	
	% 字体系列设置
	\textmd{Medium Series} \textbf{Boldface Series}
	
	{\mdseries Medium Series} {\bfseries Boldface Series}
	
	% 字体形状
	\textup{Upright Shape} \textit{Italic Shape} \textsl{Slanted Shape} \textsc{Small Caps Shape}
	
	%中文字体
    {\fangsong 仿宋} \quad {\kaishu 楷书} \quad {\songti 宋体} {\heiti 黑体}
    
    {\fangsong Fangsong}
    
    \rmfamily {\fangsong Fangsong}
    
    中文字体的\textbf{粗体}与\textit{斜体}
    
    % 字体大小的设置
    {\tiny          Hello}\\
    {\scriptsize    Hello}\\
    {\footnotesize  Hello}\\
    {\small         Hello}\\
    {\normalsize    Hello}\\
    {\large         Hello}\\
    {\Large         Hello}\\
    {\LARGE         Hello}\\
    {\huge          Hello}\\
    {\Huge          Hello}\\
    
    % 中文字号设置命令
    \zihao{-0} 你好
    
    % 自定义命令
    \myfont       
\end{document}

1.5 LaTeX 文档的基本结构

% latex_docStruct.tex

% 导言区
\documentclass[10pt]{ctexbook}

%\usepackage{ctex}

% 正文区
\begin{document}
	\tableofcontents
	
	\chapter{绪论}
	\section{引言}
	虽然场面依旧不好看,虽然全场也仅有2次射门,但在拼搏之后,精神没垮,意志还在,最终结果尚可。中国队1:1战平已经从12强赛中出现的沙特队。
	
	本场比赛,沙特队虽然已经出现,但并没有直接放水,只是相对踢得比较松弛,技术优势还是力压中国队一头。这也是中国队的场面不看好的原因所在。541或者532的阵型以防守为主。力保后防不失是李霄鹏的重点。
	
	\chapter{实验结果及分析}
	\section{实验方法}
	\section{实验结果}
	\subsection{数据}
	\subsection{图表}
	\subsubsection{实验条件}
 	\subsubsection{实验过程}
	
	\chapter{结论及致谢}
	\section{结论}
	\section{致谢}

\end{document}

1.6 LaTeX 中的特殊字符

% latex_specialChar.tex

% 导言区
\documentclass{article}

\usepackage{ctex}
\usepackage{xltxtra}
\usepackage{texnames}
\usepackage{mflogo}

% 正文区
\begin{document}
	\section{空白符号}
	你多大How old     are you?
	
	% 1em(当前字体中M的宽度)
	a\quad b
	
	% 2em
	a\qquad b
	
	% 1/6em
	a\,b
	
	% 0.5em
	a\enspace b
	
	% 空格
	a\ b
	
	% 硬空格
	a~b
	
	% 1pc=12pt=4.218mm
	a\kern 1pc b
	
	a\kern -2em b
	
	a\hskip 1em b
	
	a\hspace{35pt} b
	
	% 占位宽度
	axyzabcb
	
	a\hphantom{abcxyz}b
	
	% 弹性长度
	a\hfill b
	
	\section{\LaTeX 控制符}
	\# \$ \% \{ \} \~{} \_{} \textbackslash
	
	\section{排版符号}
	\S \P \dag \ddag \copyright \pounds
	
	\section{\TeX 标志符号}
	% 基本符号
	\TeX{} \LaTeX{} \LaTeXe{}
	\XeLaTeX{}
	
	\section{引号}
	``你好''
	
	\section{连字符}
	a-b a--b a---b
	
	\section{非英文字符}
	\oe \OE \ae \AE \aa \AA \o \b \l \L \SS \ss !` ?`
	
	\section{重音符号}
	\`o \'o \^o \''o \~o \=o \.o \u{o} \v{o} \H{o} \r{o} \t{o} \b{o}
\c{o} \d{o}
	 

\end{document}

1.7 LaTeX 中的插图

% latex_graphics.tex

% 导言区
\documentclass{ctexart}

\usepackage{graphicx}
\graphicspath{{pics/}}

% 正文区
\begin{document}
	\LaTeX{}中的插图:
	
	
	
	\includegraphics[height=5cm,angle=-45]{ping}
	
\end{document}

1.8 LaTeX 中的表格

% latex_table.tex

% 导言区
\documentclass{ctexart}

%\usepackage{ctex}

% 正文区
\begin{document}
	\begin{tabular}{| c | c | c | p{1.5cm} |}
		\hline 
		姓名 & 语文 & 数学 & 备注 \\
		\hline 
		张三 & 86 & 90 & 优秀 \\
		\hline
		李思思 & 75 & 52 & 补考另行通知 \\
		\hline
		
	\end{tabular}

\end{document}

1.9 LaTeX 中的浮动体

% latex_float.tex

% 导言区
\documentclass{ctexart}

%\usepackage{ctex}

\usepackage{graphicx}
\graphicspath{{pics/}}

% 正文区
\begin{document}
	\LaTeX{}中\TeX 系统的吉祥物--- 小狮子见图\ref{fig-lion}。
	\begin{figure}[htbp]
		\centering
		\includegraphics[scale=0.3]{lion}
		\caption{\TeX 系统的吉祥物--- 小狮子}\label{fig-lion}
	\end{figure}

    \LaTeX{}中的成绩单见表\ref{tab-score}。
	\begin{table}[htbp]
		\centering
		\caption{成绩单}\label{tab-score}
		\begin{tabular}{| c | c | c | p{2cm} |}
			\hline 
			姓名 & 语文 & 数学 & 备注 \\
			\hline 
			张三 & 86 & 90 & 优秀 \\
			\hline
			李思思 & 75 & 52 & 补考另行通知 \\
			\hline
		\end{tabular}
	\end{table}

\end{document}

1.10 LaTeX 数学公式初步

% latex_mathBasics.tex

% 导言区
\documentclass{article}

\usepackage{ctex}
\usepackage{amsmath}

% 正文区
\begin{document}
	\section{简介}
	\LaTeX{}将排版内容分为文本模式和数学模式
	\section{行内公式}
	\subsection{美元符号}
	交换律是 $a+b=b+a$,如 $1+2=2+1=3$。
	\subsection{小括号}
	交换律是 \(a+b=b+a\),如 \(1+2=2+1=3\)。
	\subsection{math环境}
	交换律是 \begin{math}a+b=b+a\end{math},如 \begin{math}1+2=2+1=3\end{math}。
	\section{上下标}
	\subsection{上标}
	$3x^{20}-x + 2 = 0$
	
	$3x^{3x^{20}-x + 2}-x + 2 = 0$
	\subsection{下标}
	$a_0, a_1, a_2$
	
	$a_0, a_1, ..., a_{100}$
	\section{希腊字母}
	$\alpha$
	
	$\pi$
	
	$\Pi$
	\section{数学函数}
	$\sin^2 x + \cos^2 x = 1$
	
	$\sqrt[3]{2}$
	\section{分式}
	大约是原体积的$\frac{3}{4}$。
	
	$\frac{x}{x^2 + x + 1}$
	
	$\frac{\sqrt{x-1}}{\sqrt{x+1}}$
	
	$\frac{1}{1 + \frac{1}{x}}$
	
	$\sqrt{\frac{x}{x^2 + x + 1}}$
	\section{行间公式}
	\subsection{美元符号}
	交换律是
	$$a+b=b+a$$
	如
	$$1+2=2+1=3$$
	\subsection{中括号}
	交换律是
	\[a+b=b+a\]
	如
	\[1+2=2+1=3\]
	\subsection{displaymath}
	交换律是
	\begin{displaymath}
		a+b=b+a
	\end{displaymath}
    如
    \begin{displaymath}
    	1+2=2+1=3
    \end{displaymath}
    \subsection{自动编号公式equation环境}
    交换律见式\ref{eq:commutative}:
    \begin{equation}
    	a+b=b+a \label{eq:commutative}
    \end{equation}
	\subsection{不编号公式equation*环境}
	交换律见式\ref{eq:commutative2}:
	\begin{equation*}
		a+b=b+a \label{eq:commutative2}
	\end{equation*}

\end{document}

1.11 LaTeX 数学公式的矩阵

% latex_matrix.tex

% 导言区
\documentclass{ctexart}

%\usepackage{ctex}
\usepackage{amsmath}

% 正文区
\begin{document}
	\[
	\begin{matrix}
		0 & 1 \\
		1 & 0
	\end{matrix} \qquad
	\begin{pmatrix}
		0 & 1 \\
		1 & 0
	\end{pmatrix} \qquad
	\begin{bmatrix}
		0 & 1 \\
		1 & 0
	\end{bmatrix} \qquad
	\begin{Bmatrix}
		0 & 1 \\
		1 & 0
	\end{Bmatrix} \qquad
	\begin{vmatrix}
		0 & 1 \\
		1 & 0
	\end{vmatrix} \qquad
	\begin{Vmatrix}
		0 & 1 \\
		1 & 0
	\end{Vmatrix} \qquad
	\]
	
	% 可以使用上下标
	\[
	A = \begin{pmatrix}
		a_{11}^2 & a_{12}^2 & a_{13}^2 \\
		0 & a_{22} & a_{23} \\
		0 & 0 & a_{33}
	\end{pmatrix}
	\]
	
    % 常用省略号:\dots,\vdots,\ddots
	\[
	A = \begin{bmatrix}
		a_{11}^2 & \dots & a_{1n}^2 \\
		& \ddots & \vdots \\
		0 & & a_{nn}
	\end{bmatrix}_{n \times n}
	\]
\end{document}

1.12 LaTeX 数学公式的多行公式

% latex_multiMath.tex

% 导言区

\documentclass{ctexart}

%\usepackage{ctex}
\usepackage{amsmath}
\usepackage{amssymb}

% 正文区
\begin{document}
	\begin{gather}
		a + b = b + a   \notag \\
		ab = ba
	\end{gather}
	\begin{gather*}
		3 + 5 = 5 = 3 = 8 \\
		3 \times 5 = 5 \times 3 = 15
	\end{gather*}
	\begin{gather}
		3 + 5 = 5 = 3 = 8 \notag \\
		3 \times 5 = 5 \times 3 = 15  \\
		5 - 3 = 2
	\end{gather}
	\begin{align}
		a + b &= b + a  \\
		ab &= ba
	\end{align}
	\begin{align*}
		a + b &= b + a  \\
		ab &= ba
	\end{align*}
	\begin{align}
		a + b = b + a&  \\
		ab = ba&
	\end{align}
	\begin{equation}
		\begin{split}
			a + b &= b + a  \\
			ab &= ba
		\end{split}
	\end{equation}
	\begin{equation}
		D(x) = \begin{cases}
			1, & \text{如果} x \in \mathbb{Q}; \\
			0, & \text{如果} x \in \mathbb{R} \setminus \mathbb{Q}.
		\end{cases}
	\end{equation}
	
\end{document}

1.13 LaTeX 中的参考文献 BibTex

% latex_reference.tex

\documentclass{ctexart}

%\usepackage{ctex}

\bibliographystyle{alpha}

\begin{document}
	这是另一个参考文献的引用:\cite{mittelbach2004}
	
	这是另一个参考文献的引用:\cite{_latex_2015}
	
	\nocite{*}
	\bibliography{test1,cnzi}
	
\end{document}

1.14 LaTeX 中的参考文献 BibLaTex

(略过)

1.15 LaTeX 中的自定义命令和环境

% latex_newCommand.tex

\documentclass{ctexart}

\newcommand\PRC{People's Republic of \emph{China}}

\newcommand\loves[2]{#1 喜欢 #2}

\newcommand\hatedby[3][喜欢]{#2 #1 #3}

\begin{document}
	\PRC
	
	\loves{小猫}{鱼}
	
	\hatedby[最爱]{小猫}{鱼}
\end{document}

2 《LaTeX 中文教程》随堂练习源文件

《LaTeX 中文教程》随堂练习源文件下载:随堂练习资料 (提取码:lfse)
在线写作平台: Overleaf,Online LaTeX Editor

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值