$\LaTeX$笔记
基本结构
ctexart文档类型表示中文短文档,сtexbook表示中文长文档,不常用的还有book、article和report等。
1 2 3 4 5 6 7 8 9 10 11 12 13
| \documentclass{ctexart} \title{书名} \author{作者} \date{\today} \begin{document} \maketitle \newpage \tableofcontents \chapter{...} \section{...} \subsection{...} ... \end{document}
|
对于诗歌、引言等可用quote环境:
1 2 3 4 5 6
| \begin{quote} 引用小段文章 \end{quote}
|
列表环境如下,可嵌套:
1 2 3 4
| \begin{enumerate} \item ... \end{enumerate}
|
数学公式:
1 2 3 4
| \usepackage{amsmath} \begin{equation} ... \end{equation}
|
图形表格:
1 2 3 4 5 6 7 8 9 10 11 12
| \usepackage{diagbox} \usepackage{array} \usepackage{xcolor} \begin{tabular}{|c|c|c|} \hline \diagbox[linewidth=1.5pt,linecolor=blue]{姓名}{科目}&语文&数学&英语\\ \hline 张三&85&85&85\\ \hline ... \hline \end{tabular}
|
数学函数绘制:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| \usepackage{tikz} \usetikzlibrary{arrows.meta,automata,positioning,decorations.markings} \begin{tikzpicture}[ domain=0:4, label/.style={ postaction={ decorate, decoration={ markings, mark=at position .75 with \node #1; } } } ] \draw[very thin,color=gray](-0.1,-1.1)grid(3.9,3.9); \draw[->](-0.2,0)--(4.2,0)node[right]{$x$}; \draw[->](0,-1.2)--(0,4.2)node[above]{$f(x)$}; \draw[red,label={[above left]{$f(x)$=x}}]plot(\x,\x); \draw[blue,label={[below left]{$f(x)=\sin x$}}]plot(\x,{sin(\x r)}); \draw[orange,label={[right]{$f(x)=\frac{1}{20}\mathrm e^x$}}]plot(\x,{0.05*exp(\x)}); \end{tikzpicture}
|
幻灯片实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| \documentclass{beamer} \usepackage{ctex} \usetheme{Warsaw} \usecolortheme{wolverine} \usefonttheme[stillsansserifmath]{serif} \setbeamercolor{normal text}{bg=gray!20} \title{标题} \author{作者} \date{\today} \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{标题} \framesubtitle{副标题} \begin{theorem} ... \end{theorem} \begin{proof} ... \end{proof} \end{frame} \end{document}
|
命令自定义:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| \newcommand{\emphxy}[1]{\textcolor{red}{\textbf{#1}}} \newenvironment{Abstract}{ \begin{center} \normalfont \bfseries 摘要 \end{center} \begin{quote} }{ \end{quote} \par } \begin{Abstract} ... \end{Abstract}
\usepackage{xspace} \newcommand\USA{United States of America\xspace} xxx \USA xxx
|
核心知识
多国语言文字:
1 2 3 4 5
| \usepackage{ctex}
\usepackage{fontspec} \setmainfont{CMU Serif} \usepackage{xeCJK}
|
符号:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| \'a \-a \v{a} \c{a} \`a \=a \H{a} \d{a} \^a \.a \t{aa} \b{a} \"a \u{a} \r{a}
\AA \OE \IJ \O \aa \oe \ij \o \AE \SS \L \i \ae \ss \l \j \# \$ \% \& \{ \} \_ \textbackslash \usepackage{alltt} \begin{alltt} 可特殊字符 # $ \end{alltt}
This is `left single quatationi mark'. 这是‘左单引号’。
\usepackage{listings} \lstset{upquote} \begin{lstlisting} aaa'aaa"aaa \end{lstlisting} \verb<char>text<char> \verb*"a & b" %用类似于下划线的空格
|
程序段:
1 2 3 4
| \usepackage{verbatim} \begin{verbatim} int main(){} \end{verbatim}
|
打印数学公式:
1 2 3 4 5
| \usepackage{verbatim} \usepackage{fancyvrb} \begin{Verbatim} \sum_{i=1} \end{Verbatim}
|
字体修饰:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| \textbf{加粗} \usepackage{CJKfntef} \CJKunderdot{着重号} \usepackage{ulem} \uline{aaa} \uwave{aaa} \xout{aaa} \dotuline{aaa} \uuline{aaa} \sout{aaa} \dashuline{aaa} \usepackage{soul} \caps{aaa} \so{aaa} \ul{aaa} \hl{aaa} \st{aaa}
|
空格:
1 2 3
| \quad \qquad \phantom{...} \hphantom{...} \vphantom{...} 水平、垂直
|
常用字体:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| 命令 声明 textrm rmfamily textsf sffamily texttt ttfamily textmd mdseries textbf bfseries textup upshape textit itshape textsl slshape textsc scshape emph em textnormal normalfont
\texttt{aaa} {\ttfamily aaa} \begin{ttfamily} aaa \end{ttfamily}
\songti \fangsong \lishu \yahei \heiti \kaishu \youyuan \pingfang
\mathcal \mathrm \mathbf \mathsf \mathtt \mathnormal \mathit
\Huge \huge \LARGE \Large \large \normalsize \small \footnotesize \scriptsize \tiny
\usepackage{relsize} \relsize{n} \smaller{aaa} \larger{aaa} \textsmaller[n]{aaa} \textlarger[n]{aaa}
\relscale{f}{aaa} \mathsmaller{aaa} \mathlarger{aaa}
\usepackage{ctex} \zihao{1}
\usepackage{textcase} \MakeTextUppercase{aaa\NoCaseChane{bbb}ccc} \MakeTextLowercase{aaa}
\, \enspace \nobreakspace \ \hspace{2cm} \vspace{2cm} \fill \stretch{n} \hfill \vfill \hrulefill \dotfill pt 榜 em 全方 1em为1个\quad ex 字号 pc 1pc=12pt=四号字 1in=72.27pt 2.54cm=1in 1cc=12dd 1in=72bp 65536sp=1pt 10mm=1cm 1157dd=1238pt
|
段落:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| \usepackage{ctex} \indent \noindent \ctexset{ part={ format+=\raggedright, indent=3\ccwd, }, section={ format=\Large\bfseries, indent=20pt, } }
\usepackage{indentfirst} \setlength{\parindent}{2em}
\par \\ \\[2cm] \linebreak \nolinebreak \pagebreak
\begin{flushleft} \end{flushleft}
\raggedright{aaa}
\usepackage{raagged2e} \begin{FlushLeft} \end{FlushLeft}
\RaggedRight
\baselineskip{aaa} \linespread{n}{aaa} \usepackage{setspace} \singlespacing{aaa} \begin{singlespace} \end{singlespace} \setstretch{1.2} \begin{spacing}{1.2} \end{spacing}
|
首字下沉:
1 2 3 4 5 6
| \usepackage{lettrine} \lettrine{A}{bbb}... \renewcommand\LettrineFontHook{\sffamily\bfseries} \renewcommand\LettrineTextFont{\sffamily\scshape} \lettrine[lines=4,loversize=-0.1,lraise=0.1,lhang=.2,slope=0.6em,findent=-1em,nindent=0.6em]{A}{bbb}...
|
图文环绕:
1 2 3 4 5 6
| \usepackage{picinpar} \begin{window}[lines,where,commands,caption] aaa... \end{window} \fbox{aaa}
|
定理环境:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
\newtheorem{thm}{定理} \begin{thm}[某定理(可选)] ... \end{thm}
\newtheorem{lemma}{引理}[section] \begin{lemma} ... \end{lemma}
|