LaTex基础知识
基本结构
包括导言区和正文区
% 导言区,保存一些参数及相关配置,引入一些包
\documentclass{article}%还可以有book,report,letter等
\title{My First Document}
\author{YG Zhou}
\date{\today}
%正文区
\begin{document}
\maketitle %输出标题、作者及日期
Hello world!
%增加一个空行即可实现换行功能
Let $f(x)$ be defined by the formula$$f(x)=3x^2+x-1$$ which is a polynomial of degree 2.
\end{document}
注:latex中单 表 示 行 列 公 式 , 双 表示行列公式,双 表示行列公式,双表示行间公式
中文处理办法
保证utf-8编码,编译器为XeLaTex
其次使用以下命令:
\usepackage{ctex}
引入中文处理宏包,就可以加入中文内容
% 导言区,保存一些参数及相关配置,引入一些包
\documentclass{article}%还可以有book,report,letter等
\usepackage{ctex}
\title{\heiti 第一个LaTex文件}
\author{\kaishu YG Zhou}
\date{\today}
%正文区
\begin{document}
\maketitle %输出标题、作者及日期
Hello world!
%增加一个空行即可实现换行功能
Let $f(x)$ be defined by the formula$$f(x)=3x^2+x-1$$ which is a polynomial of degree 2.
\begin{equation} %带序号的数学公式
AB^2 = BC^2 + AC^2.
\end{equation}
\end{document}
效果为:
字体字号设置
%字体族设置(罗马字体、无衬线字体、打字机字体)
%可以使用字体命令,作用于命令的参数
\textrm{Roman Family} \textsf{Sans Serif Family} \texttt{Typewriter Family}
%也可以使用字体声明作用于后续的文本(大括号进行分组,限定字体的作用范围)
{\rmfamily Roman Family} {\sffamily Sans Serif Family} {\ttfamily Typewriter Family}
效果:
%字体系列设置(粗细、宽度)
\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}
{\upshape Upright shape} {\itshape Italic Shape}
{\slshape Slanted Shape} {\scshape Small Caps Shape}
%中文字体
{\songti 宋体} \quad {\heiti 黑体} \quad {fangsong 仿宋} \quad {\kaishu 楷书}
效果:
设置字号前,首先要在开头设置normal size 的大小
\documentclass[10pt]{article} %设置normal size的大小为10磅 一般只有10、11、12
%字体大小
{\tiny Hello}\\
{\scriptsize Hello}\\
{\footnotesize Hello}\\
{\small Hello}\\
{\normalsize Hello}\\
{\large Hello}\\
{\Large Hello}\\
{\huge Hello}\\
{\Huge Hello}\\
%中文字号设置命令
\zihao{5} 你好!
将众多设置集成为一个命令,需要声明新的命令
声明方式:
\newcommand{\myfont}{\textbf{\textsf{\textsl{Fancy Text}}}}
%声明的写法为\newcommand{}{}第一个打括号里写命令名称,第二个打括号里嵌套命令内容
%命令使用如下
\myfont