BẢNG VÀ GÓI LỆNH LIÊN QUAN
Nguyễn Hữu ĐiểnKhoa Toán - Cơ - Tin học Đại học khoa học tự nhiên, ĐHQG HN
1 Một số loại bảng
- Bảng với chú thích ở dưới bảng \begin{table}[htbp] \caption{Chú thích} \begin{center} \begin{minipage}{4cm} \renewcommand{\thempfootnote}{\fnsymbol{mpfootnote}} \begin{center} \begin{tabular}{|c|r|r|} \hline\multicolumn{1}{|c|}{A} & \multicolumn{1}{c|}{BB} & \multicolumn{1}{c|}{CCC} \\ \hline
DDD & E & FF\footnote{Ba} \\ \hline GG & HHH\footnote{Bốn} & I \\ \hline \end{tabular} \end{center} \end{minipage} \end{center} \end{table} Bảng 1: Chú thích A BB CCC DDD E FF∗ GG HHH† I ∗Ba †Bốn - Bảng có viền bên ngoài
\begin{tabular}{|c|c|c|c|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{a} &
\multicolumn{1}{c}{b} & \multicolumn{1}{c}{c} \\ \cline{2-4} \multicolumn{1}{c|}{x} & & 2 & \\ \cline{2-4}
\multicolumn{1}{c|}{y} & 3 & 2 & \\ \cline{2-4} \end{tabular}
a b c x 2 y 3 2
- Bảng kẻ khung
\newcolumntype{I}{!{\vrule width 2pt}} % creates a vertical thick bar \newlength\savedwidth \newcommand{\wcline}[1]{\noalign{\global\savedwidth\arrayrulewidth\global \arrayrulewidth 2pt}% \cline{#1} \noalign{\global\arrayrulewidth\savedwidth}} \renewcommand{\arraystretch}{1.5} \begin{tabular}{|ccc|} \hline a & b & c \\ \wcline{2-2}
\multicolumn{1}{|cI}{c} & \multicolumn{1}{cI}{e} & f \\ \wcline{2-2} g & h & i \\ \hline \end{tabular} a b c c e f g h i \begin{tabular}{|c|c|c|c|c|c|c|} \hline
\multicolumn{1}{|c}{} & \multicolumn{1}{c|}{$Y$}&
\multicolumn{5}{c|}{Hàng\hspace{1cm}ngang} \\ \cline{3-7} \multicolumn{1}{|c}{$X$} & \multicolumn{1}{c|}{}&
\multicolumn{1}{c|}{1} & 2 & 3 & 4 &
\multicolumn{1}{c|}{5} \\ \hline\wcline{3-7}
& 5 &\multicolumn{1}{Ic|}{1} & 3 & 1 & 0 &\multicolumn{1}{cI}{1} \\ \cline{2-7}
Nhất& 4 &\multicolumn{1}{Ic|}{1} & 0 & 7 & 5 &\multicolumn{1}{cI}{1} \\ \cline{2-7}
& 3 &\multicolumn{1}{Ic|}{2} & 1 & 0 & 9 &\multicolumn{1}{cI}{3} \\ \cline{2-7}
Nhị& 2 &\multicolumn{1}{Ic|}{1} &$b$& 6 & 0 &\multicolumn{1}{cI}{$a$} \\ \cline{2-7}
& 1 &\multicolumn{1}{Ic|}{0} & 0 & 1 & 1 &\multicolumn{1}{cI}{3} \\ \hline\wcline{3-7} \end{tabular} Y Hàng ngang X 1 2 3 4 5 5 1 3 1 0 1 Nhất 4 1 0 7 5 1 3 2 1 0 9 3 Nhị 2 1 b 6 0 a 1 0 0 1 1 3
- Dóng hai bảng bằng 3 môi trường minipage \begin{center} \begin{table}[!h] \begin{minipage}{.4\textwidth} \centering \caption{Chú thích trên} \begin{tabular}{|c|c|}\hline Một&Hai\\ \hline Ba &Bốn\\ \hline \end{tabular} \end{minipage} \begin{minipage}{.1\textwidth} \hfill \end{minipage} \begin{minipage}{.4\textwidth} \centering \begin{tabular}{|c|c|} \hline một&Hai\\ \hline
$\frac 34$ & $\frac 43$ \\ \hline \end{tabular}
\end{minipage} \end{table} \end{center} Bảng 2: Chú thích trên Một Hai Ba Bốn một Hai 3 4 4 3 Bảng 3: Chú thích dưới
2 Gói lệnh listliketab.sty
Gói lệnh có tại địa chỉ
http://www.ctan.org/tex-archive/macros/latex/contrib/listliketab/
mục đích là dóng nhiều cột của danh sách trong một hàng như môi trường itemize hoặc enumerate.
ví dụ như dùng môi trường listliketab với các đánh số \nextnum, các dấu chấm \textbullet, ... nhưng trước môi trường này phải lưu lại môi trường ví dụ như \storestyleof{enumerate}, \storestyleof{itemize}, xem ví dụ dưới đây \storestyleof{enumerate}
\begin{listliketab}
\newcounter{lltenum}\setcounter{lltenum}{0}
\newcommand{\nextnum}{\addtocounter{lltenum}{1}\thelltenum.} \begin{tabularx}{\linewidth}{LX@{\qquad}lR}
& & \multicolumn{1}{c}{Due date} \\ \cline{3-3} \nextnum & Clean desk. & 2005/01/10 \\
\nextnum & Sort ‘‘in’’ pile. & 2005/01/11 \\
\nextnum & Discard random applications from ‘‘in’’ pile. & 2005/01/11 \\ \nextnum & Move applications from ‘‘in’’ pile to ‘‘out’’ pile, stamping each one with a different official-looking stamp.
& 2005/01/15 \\
\nextnum & Write and mail meaningless memos. & 2005/01/16 \\ \nextnum & Update r\’esum\’e. & 2005/01/20 \\
\end{tabularx} \end{listliketab}
Due date 1. Clean desk. 2005/01/10 2. Sort “in” pile. 2005/01/11 3. Discard random applications from “in” pile. 2005/01/11 4. Move applications from “in” pile to “out” pile, stamping each
one with a different official-looking stamp.
2005/01/15 5. Write and mail meaningless memos. 2005/01/16 6. Update résumé. 2005/01/20 - Ta có thể dóng theo các cột và đánh số \storestyleof{enumerate} \begin{listliketab} \newcounter{tabenum}\setcounter{tabenum}{0} \newcommand{\nextnum}{\addtocounter{tabenum}{1}\thetabenum.} \begin{tabular}{L>{\bf}l@{~or~}>{\bf}l@{~or~}>{\bf}l}
\nextnum & Red & green & blue \\ \nextnum & Short & stout & tall \\ \nextnum & Happy & sad & confused \\ \end{tabular}
\end{listliketab}
1. Red or green or blue 2. Short or stout or tall 3. Happy or sad or confused
- Kết hợp với gói lệnh tabularx lập danh sách sau: \storestyleof{itemize}
\begin{listliketab}
\begin{tabularx}{0.5\linewidth}{%
LX@{\raisebox{-2pt}{\framebox(12,12){}}}R} \textbullet & Milk \\
\textbullet & Flour \\ \textbullet & Sugar \\ \textbullet & Butter \\ \textbullet & Eggs \\ \end{tabularx}
\end{listliketab} • Milk • Flour • Sugar • Butter • Eggs - Danh sách đánh số theo bảng \newcolumntype{A}{>{\columncolor[rgb]{0.8,0.8,0.8}}c} \storestyleof{enumerate} \begin{listliketab} \newcommand{\nextnum}{\addtocounter{tabenum}{1}\thetabenum } \begin{tabular}{|A|p{70mm}|p{60mm}|} \multicolumn{3}{c}{\textbf{Danh sách trong bảng}}\\ \hline
\nextnum & Metaphors from the real world &A\\ \nextnum & Direct manipulation &B\\
\nextnum & See-and-point (instead of remember-and-type)&C\\ \nextnum & Consistency &D\\
\nextnum & WYSIWYG (What You See Is What You Get) &X\\ \nextnum & User Control &E\\
\nextnum & Feedback and Dialog&F \\ \nextnum & Forgiveness&G\\
\nextnum & Perceived Stablity &H \\ \nextnum & Aesthetic Integrity&I\\
\hline
\end{tabular} \end{listliketab}
Danh sách trong bảng 1 Metaphors from the real world A 2 Direct manipulation B 3 See-and-point (instead of
remember-and-type)
C 4 Consistency D 5 WYSIWYG (What You See Is What You
Get)
X 6 User Control E 7 Feedback and Dialog F 8 Forgiveness G 9 Perceived Stablity H 10 Aesthetic Integrity I
- Danh sách theo kiểu kết hợp với bảng dài longtable.sty \begin{listliketab} %\newcounter{tabenum} \setcounter{tabenum}{0} \newcommand{\nextnum}{\addtocounter{tabenum}{1}\fbox{\Large\thetabenum}} {\renewcommand\arraystretch{2} \begin{longtable}[c]{cp{0.5\textwidth}p{0.26\textwidth}} \nextnum & \iroh & \KOTAE \\
\nextnum & \juge & \KOTAE \\ \nextnum & \iroh & \KOTAE \\ \nextnum & \juge & \KOTAE \\ \nextnum & \iroh & \KOTAE \\ \nextnum & \juge & \KOTAE \\ \nextnum & \iroh & \KOTAE \\ \end{longtable}
}
1
Phần chữ không nhiều lắm ở đây còn gì nữaVí dụ:
2
Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Ví dụ:
3
Phần chữ không nhiều lắm ở đây còn gì nữaVí dụ:
4
Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Ví dụ:
5
Phần chữ không nhiều lắm ở đây còn gì nữaVí dụ:
6
Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Phần này chữ hơi dài một chút,...Ví dụ:
7
Phần chữ không nhiều lắm ở đây còn gì nữaVí dụ:
- Ví dụ cột thứ hai theo danh sách \storestyleof{itemize}
\begin{tabular}{|p{0.2\columnwidth}|p{0.75\columnwidth}|} \hline
\multicolumn{1}{|c}{\em Col1} & \multicolumn{1}{|c|}{\em Col2}\\ \hline
\hline
Something & \textbullet \ Item 1\\ & \textbullet \ Item 2\\ & \textbullet \ Item 2\\ \hline
Something & \textbullet \ Item 1\\ & \textbullet \ Item 2\\ & \textbullet \ Item 2\\ \hline \end{tabular} \end{table} Col1 Col2 Something • Item 1 • Item 2 • Item 2 Something • Item 1 • Item 2 • Item 2 - Danh sách có hình \storestyleof{enumerate} \begin{listliketab} \setcounter{tabenum}{0} \newcommand{\nextnum}{\addtocounter{tabenum}{1}\thetabenum)} \begin{longtable}[c]{rcp{0.6\textwidth}} \hline
\nextnum & \fbox{\includegraphics[width=15mm]{tiger.eps}} & \rule{0cm}{2cm}\parbox[b]{0.6\textwidth}{\iroh} \\ \hline \nextnum & \fbox{\includegraphics[width=15mm]{tiger.eps}}
& \rule{0cm}{2cm}\parbox[b]{0.6\textwidth}{\iroh\iroha} \\ \hline \nextnum & \fbox{\includegraphics[width=15mm]{tiger.eps}}
& \rule{0cm}{2cm}\parbox[b]{0.6\textwidth}{\iroh\iroha\iroh\iroha} \\ \hline
& \rule{0cm}{2cm}\parbox[b]{0.6\textwidth}{\iroh} \\ \hline \nextnum & \fbox{\includegraphics[width=15mm]{tiger.eps}}
& \rule{0cm}{25mm}\parbox[b]{0.6\textwidth}{\iroh\iroha\iroh\iroha\iroh} \\ \hline
\nextnum & \fbox{\includegraphics[width=15mm]{tiger.eps}}
& \rule{0cm}{30mm}\parbox[b]{0.6\textwidth}{\iroh\iroha\iroh\iroha\iroh} \\ \hline \end{longtable} \end{listliketab} 1) Phần nhỏ 2) Phần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn 3) Phần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớnPhần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn 4) Phần nhỏ 5) Phần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớnPhần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớnPhần nhỏ 6) Phần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớnPhần nhỏPhần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớn, Phần lớnPhần nhỏ