$\mathrm\LaTeX$ 公式输入基础教程(二)
环境
环境是指 \(\verb"\begin{...} ... \end{...}"\) 这样的东西,环境在真 LaTeX 中不一定要用来打公式,但这里我们只讲跟公式输入有关的常用环境。
多行公式输入环境
最常用的:align 或 align* 或 aligned
第一个会对每行公式自动编号,第二个则不编号,第三个属于“次环境”暂时不介绍(其实是不知怎么说)。
例:如下代码
\(\verb"\begin{align}"\)
\(\verb"f(x) & = ax^2+bx+c\\"\)
\(\verb"& = a(x-x_1)(x-x_2)\\"\)
\(\verb"& = \cdots"\)
\(\verb"\end{align}"\)
将显示
\begin{align}
f(x) & = ax^2+bx+c\\
& = a(x-x_1)(x-x_2)\\
& = \cdots
\end{align}
注:在 & 处对齐,\\ 为换行,最后一行后面不必再换行。
如果不想某些编号,可以在该行的公式后 \\ 前加 \notag;如果想引用编号,要先在该行公式中加入标签 \(\verb"\label{...}"\) 然后引用时用 \(\verb"\eqref{...}"\),花号里可填任意的英文或数字(冒号什么的好像也可以,但建议不要用别的符号以免出问题)。下面也演示一下:
代码:
\(\verb"\begin{align}"\)
\(\verb"f(x) & = ax^2+bx+c \notag \\"\)
\(\verb"& = a(x-x_1)(x-x_2) \label{asdf01234} \\"\)
\(\verb"& = \cdots"\)
\(\verb"\end{align}"\)
将显示
\begin{align}
f(x) & = ax^2+bx+c \notag \\
& = a(x-x_1)(x-x_2) \label{asdf01234} \\
& = \cdots
\end{align}
可以看到,第一行没编号了,现在要引用第二行的编号,只要输入 \(\verb"\eqref{asdf01234}"\) 即得 \eqref{asdf01234}。
这种引用的好处在于那些号码是自动编的,也就是说即使前面突然增加或减少一些公式的编号,编号数字变化时引用也跟着自动变更,不需要手动去改那数字。而且还可以点击跳转,大家不妨试试。
此外,单个行间公式需编号时,可以用 equation 环境,引用方法同上。
\(\verb"\begin{equation}\label{csineq}"\)
\(\verb"\left(\sum_{k=1}^na_kb_k\right)^2\le\left(\sum_{k=1}^na_k^2\right)\left("\)
\(\verb"\sum_{k=1}^nb_k^2\right)."\)
\(\verb"\end{equation}"\)
显示
\begin{equation}\label{csineq}
\left(\sum_{k=1}^na_kb_k\right)^2\le\left(\sum_{k=1}^na_k^2\right)\left(\sum_{k=1}^nb_k^2\right).
\end{equation}
用 \(\verb"\eqref{csineq}"\) 来引用:式 \eqref{csineq} 称为 Cauchy-Schwarz 不等式(不知有没有拼错,我总是不记得这些极难记的英文名字)。
多行公式全部居中:gather 或 gather* 或 gathered
跟 align 基本类似,但是全部居中对齐,所以里面无需用 & 。
例:如下代码
\(\verb"\begin{gather}"\)
\(\verb"f(x) = ax^2+bx+c+00\\"\)
\(\verb"= a(x-x_1)(x-x_2)\\"\)
\(\verb"= \cdots"\)
\(\verb"\end{gather}"\)
将显示
\begin{gather}
f(x) = ax^2+bx+c+00\\
= a(x-x_1)(x-x_2)\\
= \cdots
\end{gather}
矩阵环境系列
matrix:
代码:
\(\verb"\begin{matrix}"\)
\(\verb"k & u \\"\)
\(\verb"i & n"\)
\(\verb"\end{matrix}"\)
显示:
\begin{matrix}
k & u \\
i & n
\end{matrix}
将 matrix 改成 bmatrix、pmatrix、vmatrix、Vmatrix 分别得不同的矩阵显示,如下表:
\begin{array}{|c|c|c|c|}
\hline
\text{bmatrix} & \text{pmatrix} & \text{vmatrix} & \text{Vmatrix}\\
\hline
\begin{bmatrix}
k & u \\
i & n
\end{bmatrix} & \begin{pmatrix}
k & u \\
i & n
\end{pmatrix} & \begin{vmatrix}
k & u \\
i & n
\end{vmatrix} & \begin{Vmatrix}
k & u \\
i & n
\end{Vmatrix} \\
\hline
\end{array}
咦?你可能会发现,这个表是怎么做出来的?这里我用的是 array 环境,这也是一个很常用的环境。
随便来个简单点的
\(\verb"\begin{array}{|l|c|r|r|}"\)
\(\verb"\hline"\)
\(\verb"kui & ng & oh & f... \\"\)
\(\verb"\hline"\)
\(\verb"asdfadsf & 1234 & 1234 & 45678 \\"\)
\(\verb"\hline"\)
\(\verb"\end{array}"\)
显示
\begin{array}{|l|c|r|r|}
\hline
kui & ng & oh & f... \\
\hline
asdfadsf & 1234 & 1234 & 45678 \\
\hline
\end{array}
关于 array 环境的更详细使用方法请参考任意一本 LaTeX 教程。
注:tabular 环境这里暂时用不了。
再来一个利用 array 输入的分块矩阵:
\(\verb"\[\left(\begin{array}{c|cc}"\)
\(\verb"1&2&3\\"\)
\(\verb"\hline"\)
\(\verb"4&5&6\\"\)
\(\verb"\end{array}\right)\]"\)
显示
\[\left(\begin{array}{c|cc}
1&2&3\\
\hline
4&5&6\\
\end{array}\right)\]
2023年12月11日 17:20
Thank you so much for the wisdom. If you want to know more about the net worth of any celebrity, idol net worth would be a good choice.
2024年9月24日 17:57
alary of a fashion largely depends on the nature of work. Opening a fashion outlet or a boutique gives a low start, but; ensures higher returns in the long term depending on the creativity and market sense of an individual
2024年9月24日 18:30
Wow that was odd. I just wrote an really long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say superb blog!
2024年9月24日 18:37
Fantastic beat ! I wish to apprentice at the same time as you amend your site, how can i subscribe for a blog website? The account helped me a appropriate deal. I were a little bit familiar of this your broadcast offered bright transparent concept
2024年9月24日 18:38
I appreciate you spreading the word about this excellent article, so keep it up. For further information, please visit my website at this link.
2024年9月24日 18:40
I got what you mean , appreciate it for posting.Woh I am pleased to find this website through google. “Wisdom doesn’t necessarily come with age. Sometimes age just shows up by itself.” by Woodrow Wilson.
2024年9月24日 18:43
Awesome site you have here but I was wondering if you knew of any discussion boards that cover the same topics discussed here? I’d really like to be a part of online community where I can get advice from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Thanks a lot!
2024年9月24日 18:55
It's a wonderful method to add taste, and the appearance is amazing. It's a "advanced" technique, and the weak guidelines make it difficult to construct. slope 2 unblocked
2024年9月24日 18:56
I’m really enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a designer to create your theme? Excellent work!
2024年9月24日 18:58
I am frequently to blogging and i genuinely appreciate your posts. This article has truly peaks my interest. I am about to bookmark your website and keep checking choosing details
2024年9月24日 19:01
If you set out to make me think today; mission accomplished! I really like your writing style and how you express your ideas. Thank you. not limited by any conditions
2024年9月24日 19:02
Sometimes it is what's more a reasonably fine text that him and i unquestionably liked investigating. Not always every day which will have fun with the probability to see a supplement
2024年9月24日 19:04
Sometimes it is what's more a reasonably fine text that him and i unquestionably liked investigating. Not always every day which will have fun with the probability to see a supplement
2024年9月24日 19:04
Magnificent site. Lots of useful info here. I’m sending it to some friends ans also sharing in delicious. And certainly, thanks for your effort!
2024年9月24日 19:10
Mrcab24 offers reliable and affordable airport transfer service in Frankfurt. Book a cab with us for a hassle-free and comfortable ride to and from Frankfurt airport. Our experienced drivers ensure a safe and timely arrival at your destination. Contact us now for a stress-free travel experience.
2024年9月24日 19:26
I am frequently to blogging and i genuinely appreciate your posts. This article has truly peaks my interest. I am about to bookmark your website and keep checking choosing details
2024年9月24日 19:40
It’s really a cool and useful piece of info. I’m glad that you shared this useful info with us. Please keep us informed like this. Thanks for sharing
2024年9月24日 19:46
Wow that was odd. I just wrote an really long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say superb blog!
2024年9月24日 19:48
Thank you for sharing important information.it’s very useful for us.you can visit on our website for more information.
2024年9月24日 19:49
Hurrah! After all I got a weblog from where I know how to really get helpful information regarding my study and knowledge.
2024年9月24日 19:53
If some one wants to be updated with hottest technologies then he must be pay a quick visit this website and be up to date every day.
2024年9月24日 19:58
It’s really a cool and useful piece of info. I’m glad that you shared this useful info with us. Please keep us informed like this. Thanks for sharing
2024年9月24日 20:08
I’m really enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a designer to create your theme? Excellent work!
2024年9月24日 20:26
It's a wonderful method to add taste, and the appearance is amazing. It's a "advanced" technique, and the weak guidelines make it difficult to construct. slope 2 unblocked
2024年9月24日 20:29
It’s really a cool and useful piece of info. I’m glad that you shared this useful info with us. Please keep us informed like this. Thanks for sharing