Chủ Nhật, 16 tháng 2, 2014

Mấy mẹo vặt với LaTeX

1. Khoanh tròn số và liệt kê bằng số khoanh tròn. 

Trong phần khai báo sử dụng gói: \usepackage{tikz} Tạo macro sau:

1
2
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
  \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}

Thử các số 1 2 3 \circled{1} \circled{2} \circled{3}


Để liệt kê enumerate với số khoanh tròn, ta sử dụng thêm gói \usepackage{enumitem} trong phần khai báo và sử dụng liệt kê như sau:

1
2
3
4
5
6
\begin{enumerate}[label=\protect\circled{\arabic*}]
  \item First item
  \item Second item
  \item Third item
  \item Fourth item
\end{enumerate}

  2. In file PDF sang dạng mirror để nhà in thực hiện việc in ấn.

 Ví dụ, file nguồn:

1
2
3
4
5
6
7
8
9
\documentclass[10pt,landscape]{book}
\usepackage[paperwidth=29.5cm, paperheight=20.5cm, left=.5cm,right=.5cm,top=0cm,bottom=0cm]{geometry}
\usepackage{pdfpages}
\begin{document}

 \hspace*{-1cm}\includegraphics{biatlhs2.pdf}
 \includegraphics{gay.pdf}
 \includegraphics{biatlhs1.pdf}
\end{document}
sẽ cho ra cái bìa (thuận) như sau:

 Bây giờ thêm gói crop.sty

1
2
3
4
5
6
7
8
9
10
\documentclass[10pt,landscape]{book}
\usepackage[paperwidth=29.5cm, paperheight=20.5cm, left=.5cm,right=.5cm,top=0cm,bottom=0cm]{geometry}
\usepackage[mirror]{crop}
\usepackage{pdfpages}
\begin{document}

 \hspace*{-1cm}\includegraphics{biatlhs2.pdf}
 \includegraphics{gay.pdf}
 \includegraphics{biatlhs1.pdf}
\end{document}


  3. Gói cancel.sty để đánh dấu bỏ (đơn giản phân số chẳng hạn) trong công thức.

 Khi bạn \usepackage{cancel} và ghi lệnh \cancel{bt} thì những gì trong biểu thức sẽ được gạch chéo.
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
\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[vietnam]{babel}
\usepackage[utopia]{mathdesign}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{cancel}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}

Giải phương trình: $ \sin 2x.\cos x + \sin x\cos x=\cos 2x+\sin x + \cos x\qquad  (1)$

$(1) \Longleftrightarrow 2\sin x.\cos^2x + \sin x\cos x=\cos 2x+\sin x + \cos x$

$\hphantom{(1)} \Longleftrightarrow \sin x(1+\cos 2x) + \sin x\cos x=\cos 2x+\sin x + \cos x$

$\hphantom{(1)} \Longleftrightarrow \sin x+ \sin x\cos 2x + \sin x\cos x=\cos 2x+\sin x + \cos x$

$\hphantom{(1)} \Longleftrightarrow  \cancel{\sin x}+ \sin x\cos 2x + \sin x\cos x=\cos 2x+\cancel{\sin x} + \cos x$

$\hphantom{(1)} \Longleftrightarrow  \sin x\cos 2x + \sin x\cos x=\cos 2x+ \cos x$

$\hphantom{(1)} \Longleftrightarrow  \cos 2x (\sin x-1)+\cos x(\sin x-1)= 0$

$\hphantom{(1)} \Longleftrightarrow  (\sin x-1)(2\cos^2x+\cos x-1)= 0$

$\hphantom{(1)} \Longleftrightarrow  \left[\begin{array}{ll}
x &=\dfrac{\pi}{2} +k2\pi\\
x &=\dfrac{\pi}{3} +\dfrac{k2\pi}{3}\\
\end{array}\right. (k\in \mathbb{Z})$
\end{document}
Trong đoạn code trên, chúng tôi sử dụng hai cái mẹo (tricks):
  1. \hphantom{(1)} dùng để tạo một khoảng trống bằng đúng chiều của đoạn văn bản nằm trong \hphantom
  2. \cancel{\sin x} để đánh dấu chéo (đơn giản) sinx ở hai vế.

Không có nhận xét nào:

Đăng nhận xét