Latex入门文档

很久没用latex写过东西了,再加上编辑器从Emacs换成了VScode,于是为了写下面↓那个slide就找了点资料熟悉一下。
找到了这一份:https://liam0205.me/2014/09/08/latex-introduction/
感觉写得很好,而且作者似乎是CTeX的主要维护者之一?大力推荐啊!

然后这是我这次用到的一些命令,在这里存个档:

1. insert a picture
\usepackage{graphicx}
\graphicspath{{./figs/}}
\includegraphics[width=100pt]{vfk}

2. 居中
\begin{center}
\end{center}

3. 字号
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge

4. buff
\textbf{文字}
\emph{文字}

5. 换页
\clearpage
\newpage

6. 原样输出
\begin{verbatim}
\end{verbatim}

7. gif
\usepackage{animate}
\animategraphics[loop,autoplay,width=200pt]{12}{blo-}{0}{119}

8. 段落缩进
\usepackage{indentfirst}
\setlength{\parindent}{\ccwd}

9. beamer暂停
\pause

10. 行间距调整
\vspace{10pt}

11. 多行公式
$\begin{aligned}
  \sum\limits_{i = 1}^{n}{k \mod i} & = \sum\limits_{i = 1}^{n}{(k - \lfloor \frac{k}{i} \rfloor \cdot i)} \\
  & = n \cdot k - \sum\limits_{i = 1}^{n}{\lfloor \frac{k}{i} \rfloor \cdot i}
\end{aligned}$
带编号的话就去掉"ed"
单行不带编号:\notag

12. 列表
\usepackage{enumerate}
\begin{enumerate}[1.]
  \item 
\end{enumerate}

13. 插入链接
\href{https://233.com}{233}

14. 分栏
\usepackage{multicol}
\begin{multicols}{3}
  \tableofcontents
\end{multicols}

15. 公式编号
\begin{equation}
  233 = 233
\end{equation}

16. 文章内引用
\begin{equation}
  233
  \label{convolution}
\end{equation}
\eqref{convolution}

17. 空格
\qquad
\quad

18. 取模
$a^{n!} \pmod{p}$

19. 证毕
\qed

20. 整段缩进
\begin{enumerate}[\hspace{15mm}]
  \item 666

  \item 233
\end{enumerate}

21. 反斜杠
\usepackage{slashed}
$\slashed{\le}$

22. 数学公式字体大小
\textstyle{233}
\displaystyle
\scriptstyle
\scriptscriptstyle

【Latex】分类讨论

之前一直不知道下面这种东西的标准写法:
$$
\begin{equation}
\text{最终得分} =
\begin{cases}
\text{所有操作的分数之和}, & F=0\\
\left \lfloor \frac{\text{所有操作的分数之和}}{2^d} \right \rfloor, & F=1
\end{cases}
\end{equation}
$$

现在知道了:
\begin{equation}
\text{最终得分} =
\begin{cases}
\text{所有操作的分数之和}, & F=0\\\\
\left \lfloor \frac{\text{所有操作的分数之和}}{2^d} \right \rfloor, & F=1
\end{cases}
\end{equation}

参考资料:http://uoj.ac/problem/4

【Latex】Latex里的各种数

前言

之前在$latex$里写组合数这类东西的时候都是用得竖排数组
比如\left( \begin{array}{l}a\\b\end{array} \right)
但众所周知,这样是不优雅的
今天查了查,果然有解决方案

解决方案

我们可以看下面两篇文章

[1]http://www.combinatorics.net/weblib/commands/command.html
[2]http://jingyan.baidu.com/article/915fc414f5dbe351384b2043.html

不过遗憾的是,我们需要加载amsmath这个宏包
也就是说$MathJax$不支持 (╯‵□′)╯︵┻━┻

—————————— UPD 2017.4.1 ——————————
似乎组合数还是支持的

【Latex】Latex里插入GIF/动画

在latex文件里,如果要插入静态图片,那直接这样就好

\includegraphics{}

但如果要插入GIF呢?

我们可以用animate!
这个库可以把一堆图片搞成连续播放的样式
也就是说,可以把动画/GIF给搞成一帧一帧的,然后弄进去
效果可以参见这里:http://tex.stackexchange.com/questions/240243/getting-gif-and-or-moving-images-into-a-latex-presentation

具体的用法方面,先包这个库

\usepackage{animate}

如果你想把照片放到其他地方的话,需要用这一句

\graphicspath{{./figs/}}

要插入文件的时候这样写

\animategraphics[loop,autoplay,control,width=200pt]{a}{fig-}{l}{r}

其中$a$是每秒播放的帧数
你的源文件名需要长成fig-i这样,其中$i \in (l,r)$

参考资料
[1] http://tex.stackexchange.com/questions/240243/getting-gif-and-or-moving-images-into-a-latex-presentation
[2] http://drgan.net/2010/10741/

【Latex】Latex进阶

1. Mathjax相关

话说Mathjax在Wordpress的插件不支持 $...$
于是只能用 \(...\)
但这样会大大降低写作的效率

于是有两个解决方案:
1. 修改Mathjax的插件,将 $...$ 强行改成 \(...\)
2. 在wordpress的 header.php 里加上

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>

参考资料:
1. http://hzwer.com/5913.html
2. https://mathjax-chinese-doc.readthedocs.io/en/latest/start.html

2. MathType相关

如果你使用Mathtype来编辑数学公式
那么每一次导出成latex时,开头和结尾都是\[之类的,每次都要改很麻烦
于是我们直接找到这个文件:MathJax-LaTeX (base vars).tdl
然后把里面的var/"BeginMathDisplay" = "\[";之类的改成自己想要的就好啦!
比如改成:var/"BeginMathDisplay" = " $";