LaTeX
Thứ Tư, 23/03/2016, 00:03
Khung định lý, định nghĩa, bổ đề, chứng minh đẹp trong LaTeX

Khung định lý, định nghĩa, bổ đề, chứng minh đẹp trong LaTeX

Bài viết giới thiệu đến bạn một đoạn code cho phép tạo khung định lý, định nghĩa, bổ đề, chứng minh đẹp trong LaTeX. Bài viết tham khảo từ texblog nhưng chúng tôi không giải thích quá kỹ lưỡng như bài viết gốc mà chỉ chỉ cho bạn đọc cách làm nhanh nhất có thể. Nếu bạn đọc muốn biết nhiều hơn ý nghĩa của từng câu lệnh, các bạn có thể đọc bài viết gốc này (tiếng Anh). Dưới đây là đoạn code tổng thể cho văn bản của bạn
\documentclass[12pt]{article} \usepackage[framemethod=TikZ]{mdframed} \usepackage{amsthm} \usepackage[utf8]{vietnam} % ĐOẠN CODE TÙY CHỈNH cho từng định lý, định nghĩa, phụ đề, chứng minh \begin{document} \section{Tiêu đề mục} % ĐOẠN CODE CÁCH DÙNG \section{Tiêu đề mục} % ĐOẠN CODE CÁCH DÙNG \end{document}
Tùy vào mục đích sử dụng, nếu bạn cần khung *Định lý, Định nghĩa, Bổ đề *hay Chứng minh thì dùng ĐOẠN CODE TÙY CHỈNH tương ứng. Sau đó bạn đọc mục ĐOẠN CODE CÁCH DÙNG để sử dụng cho đúng.

Đoạn code tùy chỉnh

Khung Định lý

\newcounter{dinhly}[section] \setcounter{dinhly}{0} \renewcommand{\thedinhly}{\arabic{section}.\arabic{dinhly}} \newenvironment{dinhly}[2][]{% \refstepcounter{dinhly}% \ifstrempty{#1}% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=blue!20] {\strut Định lý~\thedinhly};}} }% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=blue!20] {\strut Định lý~\thedinhly~(#1)};}}% }% \mdfsetup{innertopmargin=10pt,linecolor=blue!20,% linewidth=2pt,topline=true,% frametitleaboveskip=\dimexpr-\ht\strutbox\relax } \begin{mdframed}[]\relax% \label{#2}}{\end{mdframed}}
Dưới đây là một số tùy chỉnh cho bạn từ đoạn code trên
  1. Thay dinhly bởi từ khóa nào mà bạn muốn (lưu ý phải ghi liền, không dấu) để sau này bạn dùng kiểu như begin{dinhly}.
  1. Thay thedinhly bởi the+từ nào mà ở trên bạn chọn, trong trường hợp này ở trên tôi dùng dinhly nên bước này tôi dùng thedinhly
  1. Thay Định lý bởi chữ gì mà bạn muốn.
  1. Màu nền cái chữ Định lý : thay blue!20 bởi màu mà bạn muốn, ở đây !20 có nghĩa là màu blue chỉ nhợt bằng 20% màu blue thông thường.
  1. Màu cái khung bao quanh: thay blue!20 bởi màu mà bạn muốn.
Đây là kết quả
notion image

Khung định nghĩa

Lấy ý tưởng từ việc thay các từ khóa có màu ở trên, bạn có thể làm khung định nghĩa y chang vậy bằng cách thay dinhly (bởi dinhnghia), thedinhly (bởi thedinhnghia), Định lý (bởi Định nghĩa). Còn màu thì tùy chọn. Dưới đây là một đoạn code mẫu
\newcounter{dinhnghia}[section] \setcounter{dinhnghia}{0} \renewcommand{\thedinhnghia}{\arabic{section}.\arabic{dinhnghia}} \newenvironment{dinhnghia}[2][]{% \refstepcounter{dinhnghia}% \ifstrempty{#1}% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=green!20] {\strut Định nghĩa~\thedinhnghia};}} }% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=green!20] {\strut Định nghĩa~\thedinhnghia~(#1)};}}% }% \mdfsetup{innertopmargin=10pt,linecolor=green!20,% linewidth=2pt,topline=true,% frametitleaboveskip=\dimexpr-\ht\strutbox\relax } \begin{mdframed}[]\relax% \label{#2}}{\end{mdframed}}
Đây là kết quả
notion image

Khung bổ đề

Lấy ý tưởng từ việc thay các từ khóa có màu ở mục Định lý, bạn có thể làm khung định nghĩa y chang vậy bằng cách thay dinhly (bởi bode), thedinhly (bởi thebode), Định lý (bởi Bổ đề). Còn màu thì tùy chọn. Dưới đây là một đoạn code mẫu
\newcounter{bode}[section] \setcounter{bode}{0} \renewcommand{\thebode}{\arabic{section}.\arabic{bode}} \newenvironment{bode}[2][]{% \refstepcounter{bode}% \ifstrempty{#1}% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=red!20] {\strut Bổ đề~\thebode};}} }% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=red!20] {\strut Bổ đề~\thebode~(#1)};}}% }% \mdfsetup{innertopmargin=10pt,linecolor=red!20,% linewidth=2pt,topline=true,% frametitleaboveskip=\dimexpr-\ht\strutbox\relax } \begin{mdframed}[]\relax% \label{#2}}{\end{mdframed}}
Đây là kết quả
notion image

Khung mệnh đề

Lấy ý tưởng từ việc thay các từ khóa có màu ở mục Định lý, bạn có thể làm khung định nghĩa y chang vậy bằng cách thay dinhly (bởi menhde), thedinhly (bởi themenhde), Định lý (bởi Mệnh đề). Còn màu thì tùy chọn. Dưới đây là một đoạn code mẫu
\newcounter{menhde}[section] \setcounter{menhde}{0} \renewcommand{\themenhde}{\arabic{section}.\arabic{menhde}} \newenvironment{menhde}[2][]{% \refstepcounter{menhde}% \ifstrempty{#1}% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=yellow!120] {\strut Mệnh đề~\themenhde};}} }% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=yellow!120] {\strut Mệnh đề~\themenhde~(#1)};}}% }% \mdfsetup{innertopmargin=10pt,linecolor=yellow!120,% linewidth=2pt,topline=true,% frametitleaboveskip=\dimexpr-\ht\strutbox\relax } \begin{mdframed}[]\relax% \label{#2}}{\end{mdframed}}
Đây là kết quả
notion image

Khung chứng minh

Cũng lấy ý tưởng từ việc thay thế các từ khóa như ở mục Định lý, ta có đoạn code mẫu cho khung chứng minh như sau
\newcounter{chungminh}[section]\setcounter{chungminh}{0} \renewcommand{\thechungminh}{\arabic{section}.\arabic{chungminh}} \newenvironment{chungminh}[2][]{% \refstepcounter{chungminh}% \ifstrempty{#1}% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=brown!20] {\strut Chứng minh~\thechungminh};}} }% {\mdfsetup{% frametitle={% \tikz[baseline=(current bounding box.east),outer sep=0pt] \node[anchor=east,rectangle,fill=brown!20] {\strut Chứng minh~\thechungminh:~#1};}}% }% \mdfsetup{innertopmargin=10pt,linecolor=brown!20,% linewidth=2pt,topline=true,% frametitleaboveskip=\dimexpr-\ht\strutbox\relax } \begin{mdframed}[]\relax% \label{#2}}{\qed\end{mdframed}}
Kết quả
notion image

Đoạn code cách dùng

Lưu ý, bạn có thể không cần điền tên của Định lý, Định nghĩa, Bổ đề hay Mệnh đề ở trong ngoặc vuông, khi ấy bạn xóa luôn cái ngoặc vuông đi. Còn cái trong ngoặc nhọn là để bạn dùng ref trỏ đến nó. + Khung định lý
\begin{dinhly}[Tên định lý]{dily:dinhly1} % Nội dung của định lý \end{dinhly}
+ Khung định nghĩa
\begin{dinhnghia}[Tên định nghĩa]{ding:dinhnghia1} % Nội dung của định lý \end{dinhnghia}
+ Khung bổ đề
\begin{bode}[Tên bổ đề]{bode:bode1} % Nội dung của định lý \end{bode}
+ Khung mệnh đề
\begin{menhde}[Tên mệnh đề]{mede:menhde1} % Nội dung của định lý \end{menhde}
+ Khung chứng minh
\begin{chungminh}{chm:chungminh1} % Nội dung của chứng minh \end{chungminh}
Cùng chủ đề