Math Tools Help 1

  • Uploaded by: Nguyễn Hữu Điển
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Math Tools Help 1 as PDF for free.

More details

  • Words: 1,588
  • Pages: 10
mathtools.sty - công cụ tinh chỉnh công thức Nguyễn Hữu Điển Khoa Toán - Cơ - Tin học ĐHKHTN Hà Nội, ĐHQGHN

1

Giới thiệu gói lệnh

Gói lệnh mathtools.sty công cụ tinh chỉnh công thức dùng với amsmath.sty có tại địa chỉ

1. 2. 3. 4. 5.

http://tug.ctan.org/tex-archive/macros/latex/contrib/mh/ Trong bó lệnh ngoài mathtools.sty còn có các gói lệnh khác như breqn.sty Tự động ngắt dòng trong môi trường công thức equation. empheq.sty co dãn công thức (Đã có bài riêng về gói này) flexisym Thay đổi ký hiệu thích hợp với breqn.sty mathstyle Quản lý định dang ký tự công thức toán. xfrac.sty Chia các phân thức theo thứ bậc to nhỏ trong latex2e. Trong bài này chỉ giới thiệu mathtools.sty.

2

Sử dụng lệnh

1. Tùy chọn gói lệnh \usepackage[fleqn,tbtags]{mathtools} tương đương với \usepackage[fleqn,tbtags]{amsmath} \usepackage{mathtools} Ngoài ra còn tùy chọn fixamsmath sử lại một lỗi trong gói lệnh amsmath.sty donotfixamsmathbugs không sửa lại lỗi. allowspaces cho phép chữa lại khoảng trống quanh công thức disallowspaces không cho phép sửa công thức. 2. Nhiều khi trong gói lệnh amsmath.sty mất chữ khi dùng \[ \begin{gathered} [p] = 100 \\ [v] = 200 \end{gathered} \] = 100 [v] = 200 Nhưng với gói lệnh mathtools.sty thì [p] = 100 [v] = 200 1

http://nhdien.wordpress.com - Nguyễn Hữu Điển

2

3. Tinh chỉnh bằng lệnh trong mathtools.sty bằng \mathclap{} \begin{align*} X &= \sum_{1\le i\le j\le n} X_{ij} \\ X &= \sum_{\mathclap{1\le i\le j\le n}} X_{ij} \end{align*}

X=

X

Xij ←− amsmath.sty

1≤i≤j≤n

X=

X

Xij ←− mathtools.sty

1≤i≤j≤n

Tương tự cho dong công thức \begin{align*} a+b &= \sum_{i+j=10} f(i) g(j) \\ &= \sum_{k\geq0} h(k)\\ a+b &= \sum_{\mathclap{i+j=10}} f(i) g(j) \\ &= \sum_{\mathclap{k\geq0}} h(k) \end{align*}

a+b=

X

f (i)g(j)

i+j=10

=

X

h(k)

k≥0

a+b=

X

f (i)g(j)

i+j=10

=

X

h(k)

k≥0

4. Tinh chỉnh bằng lệnh \smashoperator{} mặc định căn vào giữa, với tùy chọn \smashoperator[r]{} căn bên phải, \smashoperator[l]{} căn trái \begin{align*} V &= \sum_{i\le j \le \le k \le \ell}^{\infty} V_{ijk\ell} \\ V &= \smashoperator{\sum_{i\le j \le \le k \le \ell}^{\infty}} V_{ijk\ell} \\ V &= \smashoperator[r]{\sum_{i\le j \le \le k \le \ell}^{\infty}} V_{ijk\ell} \\ V &= \smashoperator[l]{\sum_{i\le j \le \le k \le \ell}^{\infty}} V_{ijk\ell} \end{align*}

V = V =

∞ X

Vijk`

i≤j≤≤k≤` ∞ X

V =

V =

Vijk`

i≤j≤≤k≤` ∞ X

Vijk`

i≤j≤≤k≤` ∞ X

i≤j≤≤k≤`

Vijk`

http://nhdien.wordpress.com - Nguyễn Hữu Điển

3

5. Dùng lệnh \adjustlimits để chỉnh dòng dưới ngang hàng nhau {\Huge \begin{alignat*}{2} & \lim_{n\to\infty} \max_{p\ge n}, & \adjustlimits\lim_{n\to\infty} \max_{p\ge n} \\ & \lim_{n\to\infty} \max_{p^2\ge n}, & \adjustlimits\lim_{n\to\infty} \max_{p^2\ge n} \\ & \lim_{n\to\infty} \sup_{p^2\ge nK}, & \adjustlimits\lim_{n\to\infty} \sup_{p^2\ge nK} \\ & \limsup_{n\to\infty} \max_{p\ge n}, & \adjustlimits\limsup_{n\to\infty} \max_{p\ge n} \end{alignat*}}

Bên trái là chưa tinh chỉnh, bên phải dùng lệnh tinh chỉnh rồi

lim max,

lim max

n→∞ p≥n

n→∞ p≥n

lim max ,

lim max

n→∞ p2≥n

lim

n→∞ p2≥n

sup , lim

sup

n→∞ 2 p ≥nK n→∞ p2≥nK

lim sup max, lim sup max n→∞ p≥n

n→∞ p≥n

6. Định dạng lại kiểu bao quanh đánh nhãn \newtagform{brackets2}[\textbf]{[}{]} \usetagform{brackets2} \begin{align} X &= \sum_{1\le i\le j\le n} X_{ij} \\ X &= \sum_{\mathclap{1\le i\le j\le n}} X_{ij} \end{align}

X=

X

Xij

[1]

1≤i≤j≤n

X=

X

Xij

1≤i≤j≤n

Trở lại mặc định dùng \usetagform{default}

[2]

http://nhdien.wordpress.com - Nguyễn Hữu Điển

4

\begin{align} X &= \sum_{1\le i\le j\le n} X_{ij} \\ X &= \sum_{\mathclap{1\le i\le j\le n}} X_{ij} \end{align}

X=

X

Xij

(3)

1≤i≤j≤n

X=

X

(4)

Xij

1≤i≤j≤n

7. Chỉ hiện ra các lệnh có tham chiếu \mathtoolsset{showonlyrefs=true} \begin{align} X &= \sum_{1\le i\le j\le n} X_{ij} \label{eq:eq01}\\ X &= \sum_{\mathclap{1\le i\le j\le n}} X_{ij} \label{eq:eq02} \end{align}

X=

X

Xij

(5)

1≤i≤j≤n

X=

X

Xij

1≤i≤j≤n

Lệnh nhãn \label{eq:eq01} tham chiếu \refeq{eq:eq01} sẽ có (5) còn \label{eq:eq02} không hiện ra cả trong công thức. Khi dùng trở lại \mathtoolsset{showonlyrefs=false} \begin{align} X &= \sum_{1\le i\le j\le n} X_{ij} \label{eq:eq03}\\ X &= \sum_{\mathclap{1\le i\le j\le n}} X_{ij} \label{eq:eq04} \end{align}

X=

X

Xij

(6)

1≤i≤j≤n

X=

X

Xij

(7)

1≤i≤j≤n

Lệnh nhãn \label{eq:eq03} tham chiếu \refeq{eq:eq03} sẽ có (6) còn \label{eq:eq04} vẫn hiện ra cả trong công thức.

http://nhdien.wordpress.com - Nguyễn Hữu Điển 8. Trong gói lệnh \begin{align*} &\begin{matrix} a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{matrix} \\ &\begin{pmatrix} a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{pmatrix}\\ &\begin{bmatrix} a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{bmatrix}\\ &\begin{Bmatrix} a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{Bmatrix}\\ &\begin{vmatrix} a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{vmatrix}\\ &\begin{Vmatrix} a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{Vmatrix} \end{align*}

\usepackage{amsmath}

5 có

các

môi

trường

ma

trận

a11 a12 a21 a22 + b12   a11 a12 a21 a22 + b12   a11 a12 a21 a22 + b12   a11 a12 a21 a22 + b12 a11 a12 a21 a22 + b12

a11 a12

a21 a22 + b12

Trong \usepackage{mathtools} môi trường có \begin{matrix*}[r] và căn các phần tử \begin{align*} &\begin{matrix*}[r] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{matrix*} \\ &\begin{pmatrix*}[r] a_{11} &a_{12} \\ a11 a12 a_{21} &a_{22}+b_{12} a a + b12 21 22 \end{pmatrix*}\\   a11 a12 &\begin{bmatrix*}[r] a21 a22 + b12 a_{11} &a_{12} \\   a_{21} &a_{22}+b_{12} a11 a12 \end{bmatrix*}\\ a21 a22 + b12   &\begin{Bmatrix*}[r] a11 a12 a_{11} &a_{12} \\ a21 a22 + b12 a_{21} &a_{22}+b_{12} a12 \end{Bmatrix*}\\ a11 a21 a22 + b12 &\begin{vmatrix*}[r]

a_{11} &a_{12} \\

a11 a12

a_{21} &a_{22}+b_{12}

a21 a22 + b12 \end{vmatrix*}\\ &\begin{Vmatrix*}[r] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{Vmatrix*} \end{align*}

http://nhdien.wordpress.com - Nguyễn Hữu Điển

6

\usepackage{mathtools} \begin{matrix*}[l] \begin{align*} &\begin{matrix*}[l] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{matrix*} \\ &\begin{pmatrix*}[l] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{pmatrix*}\\ &\begin{bmatrix*}[l] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{bmatrix*}\\ &\begin{Bmatrix*}[l] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{Bmatrix*}\\ &\begin{vmatrix*}[l] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{vmatrix*}\\ &\begin{Vmatrix*}[l] a_{11} &a_{12} \\ a_{21} &a_{22}+b_{12} \end{Vmatrix*} \end{align*}

a11 a12 a21 a22 + b12   a11 a12 a21 a22 + b12   a11 a12 a21 a22 + b12   a11 a12 a21 a22 + b12 a11 a12 a21 a22 + b12



a11 a12

a21 a22 + b12

9. Thêm môi trường dcases và dcases* để tinh chỉnh, ta so sánh \[ a=\begin{cases} E = m c^2 & \text{Nothing to see here} \\ \int x-3\, dx & \text{Integral is text style} \end{cases} \]

a=

(

E = mc2 Nothing to see here R x − 3 dx Integral is text style

\[ a=\begin{dcases} E = m c^2 & \text{Nothing to see here} \\ \int x-3\, dx & \text{Integral is text style} \end{dcases} \]

\[

 2 Nothing to see here E = mc Z a=  x − 3 dx Integral is text style

http://nhdien.wordpress.com - Nguyễn Hữu Điển

7

a=\begin{dcases*} E = m c^2 & Nothing to see here \\ \int x-3\, dx & Integral is text style \end{dcases*} \]  2 Nothing to see here E = mc Z a=  x − 3 dx Integral is text style

10. Khoảng trống trong công thức được chỉnh lại \usepackage{amsmath} Trước công thức a=b

(8)

c=d

(9)

a=b

(10)

c=d

(11)

Bên trong công thức

Sau công thức \usepackage{mathtools} Trước công thức

Bên trong công thức

Sau công thức 11. dùng lệnh tinh chỉnh chỉ số \prescript \[ {}^{4}_{12}\mathbf{C}^{5+}_{2} \quad \prescript{14}{2}{\mathbf{C}}^{5+}_{2} \quad \prescript{4}{12}{\mathbf{C}}^{5+}_{2} \quad \prescript{14}{}{\mathbf{C}}^{5+}_{2} \quad \prescript{}{2}{\mathbf{C}}^{5+}_{2} \]

5+ 4 12 C2

\newcommand*\myisotope[3]{% \begingroup \mathtoolsset{ prescript-sup-format=\mathit, prescript-sub-format=\mathbf, prescript-arg-format=\mathrm, }% \prescript{#1}{#2}{#3}% \endgroup }

14 5+ 2 C2

4 5+ 12 C2

14

C5+ 2

5+ 2 C2

http://nhdien.wordpress.com - Nguyễn Hữu Điển

8

\[ \myisotope{A}{Z}{X}\to \myisotope{A-4}{Z-2}{Y}+ \myisotope{4}{2}{\alpha} \] 4 → A−4 Z−2 Y + 2 α

A ZX

12. Mũi tên có chú thích trên và dưới \xleftrightarrow[Chữ ở dưới]{chữ ở trên} \xRightarrow[Chữ ở dưới]{chữ ở trên} \xLeftarrow[Chữ ở dưới]{chữ ở trên} \xLeftrightarrow[Chữ ở dưới]{chữ ở trên} \xhookleftarrow[Chữ ở dưới]{chữ ở trên} \xhookrightarrow[Chữ ở dưới]{chữ ở trên} \xmapsto[Chữ ở dưới]{chữ ở trên} Đặc biệt hay dùng \xrightarrow[Chữ ở dưới]{chữ ở trên} \xleftarrow[Chữ ở dưới]{chữ ở trên} Ví dụ \[ A \xLeftarrow[under]{over} B \] over

A ⇐=== B under

Tương tự có \xrightharpoondown[Chữ ở dưới]{chữ ở trên} \xrightharpoonup[Chữ ở dưới]{chữ ở trên} \xleftharpoondown[Chữ ở dưới]{chữ ở trên} \xleftharpoonup[Chữ ở dưới]{chữ ở trên} \xrightleftharpoons[Chữ ở dưới]{chữ ở trên} \xleftrightharpoons[Chữ ở dưới]{chữ ở trên} 13. Ngoặc ở trên và ở dưới \underbracket[hrule thicknessi] [hbracket heighti]{hargi} \overbracket[hrule thicknessi] [hbracket heighti]{hargi} $\underbracket {foo\ bar}_{baz}$

f oo bar baz baz

$\overbracket {foo\ bar}^{baz}$

f oo bar

\[ \underbracket[3pt]{xxx\ yyy}_{zzz} \quad \text{and} \quad \underbracket[1pt][7pt]{xxx\ yyy}_{zzz} \]

http://nhdien.wordpress.com - Nguyễn Hữu Điển

xxx yyy

and

zzz

9

xxx yyy zzz

14. Ngắt tử số hoặc mẫu số trong phân số \[ a=\frac{ \splitfrac{xy + xy + xy + xy + xy} {+ xy + xy + xy + xy} } {z} =\frac{ \splitdfrac{xy + xy + xy + xy + xy} {+ xy + xy + xy + xy} } {z} \] xy + xy + xy + xy + xy xy + xy + xy + xy + xy + xy + xy + xy + xy + xy + xy + xy + xy a= = z z 15. Môi trường gathered được cải tiến nhiều \begin{lgathered}[hposi] hcontentsi \end{lgathered} \begin{rgathered}[hposi] hcontentsi \end{rgathered} \newgathered{hnamei}{hpre_linei}{hpost_linei}{hafteri} \renewgathered{hnamei}{hpre_linei}{hpost_linei}{hafteri} Ví dụ \begin{equation} \begin{lgathered} x=1,\quad x+1=2 \\ y=2 \end{lgathered} \end{equation} x = 1, y=2

x+1=2

Cải tiến môi trường này \newcounter{steplinecnt} \newcommand\stepline{\stepcounter{steplinecnt}\thesteplinecnt} \newgathered{stargathered} {\llap{\stepline}$*$\quad\hfil}% \hfil for centering {\hfil}% \hfil for centering {\setcounter{steplinecnt}{0}}% reset counter Áp dụng

(12)

http://nhdien.wordpress.com - Nguyễn Hữu Điển

10

\begin{gather} \begin{stargathered} x=1,\quad x+1=2 \\ y=2 \end{stargathered} \end{gather}

1∗ x = 1, 2∗

x+1=2 y=2

(13)

16. Chủ động cách dòng công thức \begin{spreadlines}{hdimeni} hcontentsi \end{spreadlines} \begin{spreadlines}{20pt} Cách ra 20pt \begin{gather} a=b\\ c=d \end{gather} \end{spreadlines} Cách ra 20pt a=b

(14)

c=d

(15)

a=b

(16)

c=d

(17)

Không cách ra. \begin{gather} a=b\\ c=d \end{gather} Không cách ra.

Related Documents

Math Tools Help 1
May 2020 7
Math Comp Help
May 2020 4
Tools And Math For Money
November 2019 9
Help 1
November 2019 7
Tools Tools
June 2020 35

More Documents from ""