LaTex学习笔记

框架

输入内容

\documentclass{article}  %声明文章类型
 
\begin{document}
要输入的内容
\end{document}

设置序言

\documentclass[12pt, letterpaper]{article}  %字体大小12pt默认10pt和纸张大小(信纸)
\usepackage[utf8]{inputenc}  %文档编码
 
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the ShareLaTeX team}}
\date{February 2014}  % 一些描述

注意:序言在\begin{document}之前声明,但要在内容位置让其显示

\documentclass[12pt, letterpaper, twoside]{article}
\usepackage[utf8]{inputenc}
 
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the ShareLaTeX team}}
\date{February 2014}
 
\begin{document}
 
\begin{titlepage}  % 序言
\maketitle
\end{titlepage}

\begin{abstract}
摘要内容
\end{abstract} 

\begin{comment}
注释内容,不显示
\end{comment}

 % 另起一页内容
In this document some extra packages and parameters
were added. There is an encoding package
and pagesize and fontsize parameters.
 
\end{document}

开始一个新段落

按两次“Enter”键(插入双空白行)。注意段落的第一行前面有一个空格。也可以使用\或\newline命令插入换行点

文件类型

文件类型描述
article简短的文档和期刊文章
report较长的文件和论文
book写书
letter
slides幻灯片
beamer幻灯片格式为Beamer类
保留字符描述
#宏参数
$数学mode
%注释
^上标(数学模式)
_下标(数学模式)
&表中单独的列条目
{ }Processing block
~封闭空间
\启动命令

中文

\documentclass{ctexart}  % 简体中文用ctex文档类:ctexart、ctexrep、ctexbook、ctexbeamer
 
\begin{document}
 
\tableofcontents
 
\begin{abstract}
摘要内容
\end{abstract}
 
\section{ 前言 }
 前言内容
\section{内容}
数学、中(包括繁體)英文皆可以混排。
 内容
\end{document}

完整的本地化ctex类和包有点多余,只键入一些中文字符,可以使用xeCJK包

\documentclass{article}
\usepackage{xeCJK}
\begin{document}
 
\section{前言}
 
\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.
 
這是繁體中文。
\end{document}

CJKutf8包还可以用pdfLaTeX生成文档。中文(和日文/韩文)文本必须放置在CJK环境中,因此这通常只适用于带有中文文本的英文文档,反之亦然。

\documentclass{article}
\usepackage{CJKutf8}
 
\begin{document}
 
\begin{CJK*}{UTF8}{gbsn}
 
\section{前言}
 
\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.
 
\end{CJK*}
 
\bigskip  %% Just some white space
 
You can also insert Latin text in your document
 
\bigskip  %% Just some white space
 
\begin{CJK*}{UTF8}{bsmi}
這是繁體中文。
\end{CJK*}
 
\end{document}

段落和新行

\begin{center}
内容居中
\end{center}

换行

\par命令:启动新段落,默认段落缩进量是当前字体的1.5倍

换页

\newpage

段落对齐(文本对齐)

LATEX有以下三种环境:center、flushleft和flushright
环境基于switch命令:\raggedright(等价于flushleft)、\raggedleft(等价于flushright)和居中(等价于center)

\begin{flushleft}
文本内容
\end{flushleft}

段落缩进(Paragraph Indentation)

默认LATEX不会缩进章节的第一段。后续段落缩进的大小由\ parindent参数决定
如果想缩进一个没有缩进的段落,可以使用\缩进。注意:这个命令只有在\parindent未设置为零时才会生效
\noindent无缩进

\setlength{\parindent}{10ex}  % 缩进  “ex”等于当前字体中“x”的长度
段落内容
\noindent  %无缩进
段落内容

画图

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}

\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}
%\usepgfplotslibrary{external}
%\tikzexternalize

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    title=Exmple using the mesh parameter,
    hide axis,
    colormap/cool,
]
\addplot3[
    mesh,
    samples=50,
    domain=-8:8,
]
{sin(deg(sqrt(x^2+y^2)))/sqrt(x^2+y^2)};
\addlegendentry{$\frac{sin(r)}{r}$}
\end{axis}
\end{tikzpicture}

\end{document}

在其他pdf文档基础上接着编辑

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf{1.pdf}
\end{document}

字体

字 体 \large\color{blue}字体 命 令 \large\color{blue}命令
斜体\ underline { }
粗体\ textbf { }
斜体\ textit { }
下划线\ textbf { }
加粗字体\ textbf { }
强调文字\emph{ }

插入图片

\documentclass{article}
\usepackage{graphicx}  %导入包
\graphicspath{ {./images1/}{./images2/}}  % 声明多个图片位置,也可输入绝对路径
\begin{document}
\ includegraphics [ scale = 1.5, angle=45 ] {lion-logo }           % 插入图片 ,scale原图2.5倍,角度逆时针45度
\includegraphics[width=3cm, height=4cm]{lion-logo}       % 将图像缩放到特定的宽度和高度
\ includegraphics [ width = \ textwidth ] {universe }    % 长度单位也可以相对于文档中的某些元素

\begin{wrapfigure}{r}{0.25\textwidth} %this figure will be at the right
    \centering
    \includegraphics[width=0.25\textwidth]{mesh}
\end{wrapfigure}
 
\begin{wrapfigure}{l}{0.25\textwidth}
    \centering
    \includegraphics[width=0.25\textwidth]{contour}
\end{wrapfigure}
\end{document}
参数图片位置
[ h ]大概放在光标这里
[ t ]放置在页面顶部
[ b ]定位在页面底部
[ p ]。。。。。。。。。??
[ ! ]覆盖LaTeX用于确定“良好”的光标位置内部参数
[ H ]精确地放在光标位置(相当于h!)
{ l }左边
{ c }中间
{ r }右边

错误:

Cannot determine size of graphic in ./images/3.png (no BoundingB
解决办法

  • Windows上将图片转换为eps格式
    打开cmd切换到图片目录,输入bmeps -c image.jpg image.eps
    -c :输出彩色,否则为灰度图
  • texlive中有一个小工具,用这个小工具作为图片的打开方式,就会自动生成一张eps格式的彩图
    在这里插入图片描述
  • 在线转换

将.jpg图片 转换成.eps 格式图片
Windows 命令行切换目录

图表

\begin{center}  %居中
\begin{tabular}{ c c c }
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\  
 cell7 & cell8 & cell9    
\end{tabular}
\end{center}

\multicolumn{4}横跨多列
\multirow横跨多行

插入代码并显示语法高亮

设置环境

\usepackage{listings}
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Python,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}

\begin{document}
\begin{lstlisting}
% 插入python代码
\end{lstlisting}
\end{document}

列举

\begin{itemize}
\item[*] a   #  中括号内符号可自定义
\item[*] b
\end{itemize}

\begin{description}
\item[1)] a  #  中括号内符号可自定义
\item[2)] b
\end{description}

插入链接

\usepackage[colorlinks,linkcolor=blue]{hyperref}

\href{http://v.youku.com/}{Youku video} 

插入脚注

重定义脚注符号

\renewcommand{\thefootnote}{{自定义脚注符号}}
\footnote{脚注说明}

公式

LaTeX数学公式大全
alignat(可以一行有两个式子进行对齐)

\begin{alignat}{2}
 \sigma_1 &= x + y  &\quad \sigma_2 &= \frac{x}{y} \\  
 \sigma_1' &= \frac{\partial x + y}{\partial x} & \sigma_2'
    &= \frac{\partial \frac{x}{y}}{\partial x}
\end{alignat}

空两行
f ( n ) = { n 2 , if  n  is even 3 n + 1 , if  n  is odd f(n) = \begin{cases} \frac{n}{2}, & \text{if $n$ is even} \\[2ex] 3n+1, & \text{if $n$ is odd} \end{cases} f(n)=2n,3n+1,if n is evenif n is odd

公式符号

在这里插入图片描述

公式字体

Tex公式字体
花体 \mathscr{ABCDEFG} A B C D E F G \mathscr{ABCDEFG} ABCDEFG
圆体 \mathcal{ABCDEFG} A B C D E F G \mathcal{ABCDEFG} ABCDEFG
黑体 \boldsymbol{ABCDEFG} A B C a b c d \boldsymbol{ABCabcd} ABCabcd

特殊符号

TEX符号
\overset{\leftarrow}a a ← \overset{\leftarrow}a a
\boxed{a} a \boxed{a} a
\fbox{a} a \fbox{a} a
\iint ∬ \iint
\iint\limits_{\sum} ∬ ∑ \iint\limits_{\sum}
\iiiint ∭ \iiint
\nabla ∇ \nabla
\oint ∮ \oint
\triangle △ \triangle
\clubsuit ♣ \clubsuit
\lceil\frac12\rceil ⌈ 1 2 ⌉ \lceil\frac12\rceil 21
\lfloor\frac12\rfloor ⌊ 1 2 ⌋ \lfloor\frac12\rfloor 21
\biggl\lceil\frac12 \biggr\rceil ⌈ 1 2 ⌉ \biggl\lceil \frac12 \biggr\rceil 21
\biggl\lfloor\frac12\biggr\rfloor ⌊ 1 2 ⌋ \biggl\lfloor\frac12\biggr\rfloor 21
\cancel {abcd} a b c d \cancel {abcd} abcd
\sout {abcd} a b c d \sout {abcd} abcd
\checkmark ✓ \checkmark
MathJax 支持的 Latex 符号总结(各种箭头符号)

集合符号

Tex符号
\mid ∣ \mid
\in ∈ \in
\not\in ∉ \not\in
\subset ⊂ \subset
\supsetneqq ⫌ \supsetneqq
\not\subset ⊄ \not\subset
\cap ∩ \cap
\cup ∪ \cup
\overline{A} A ‾ \overline{A} A
\setminus ∖ \setminus
\emptyset ∅ \emptyset
\mathbb{R} R \mathbb{R} R

参考文献

【1】LaTeX 各种命令,符号
【2】在LaTeX中使用强大的pgfplots绘图包
【3】【工具】Latex使用方法积累
【4】LaTeX笔记|基本功能
【5】一份其实很短的 LaTeX 入门文档
【6】组织你的文章
【7】如何在LaTeX里插入漂亮的程序代码
【8】LaTex写书模板:ElegantBook
【9】Latex 箭头、下标、符号上下写文字、正方形和三角形
【10】LaTeX数学公式大全
【11】https://www.overleaf.com/learn
【12】https://www.tablesgenerator.com/#

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值