subcaption help

5
subcaption.sty mở rộng quản lý chú thích hình và bảng 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 subcaption.sty nằm trong gói lệnh caption.sty vẫn ở địa chỉ http://tug.ctan.org/tex-archive/macros/latex/contrib/caption/ Khi ta chạy caption.ins thì gói lệnh subcaption.sty được sinh ra và khi đó ta sẽ sử dụng được. Khi dùng ta thực hiện ngay \usepackage[<Tùy chọn>]{caption} \usepackage[<Tùy chọn>]{subcaption} Ta có thể sử dụng trực tiếp tùy chọn cho gói lệnh này như: \usepackage{subcaption} \captionsetup[sub]{<Tùy chọn>} Mặc định đặt trong subcaption.sty là: margin=0pt,font+=small,labelformat=parens,labelsep=space, skip=6pt,list=false,hypcap=false Tùy chọn chỉ ra trong \usepackage[. . . ]{subcaption} \captionsetup[sub]{. . .} sẽ được đè lên tùy chọn của \captionsetup{. . .} \captionsetup[figure]{. . .}, nhưng có thể ghi đè lại bằng \captionsetup[subfigure]{. . .} (tương tự cho ‘table’). Một số quy tắc chỉ ra thứ tự đặt tùy chọn: 1. Đặt tùy chọn cho toàn cục (\usepackage[. . . ]{caption} \captionsetup{. . . }) 2. Đặt môi trường (\captionsetup[figure -hoặc- table]{. . . }) 3. Đặt cho cục bộ (\captionsetup{. . .} trong môi trường figure hoặc ta- ble) 4. Mặc định đặt cho ‘sub’ (margin=0pt,font+=small,. . . , như ở trên) 1

Upload: mai-man-tiep

Post on 17-Aug-2015

20 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Subcaption help

subcaption.sty mở rộng quản lý chú thíchhình và bảng

Nguyễn Hữu ĐiểnKhoa Toán - Cơ - Tin học

ĐHKHTN Hà Nội, ĐHQGHN

1 Giới thiệu

Gói lệnh subcaption.sty nằm trong gói lệnh caption.sty vẫn ở địa chỉhttp://tug.ctan.org/tex-archive/macros/latex/contrib/caption/Khi ta chạy caption.ins thì gói lệnh subcaption.sty được sinh ra và khi đó ta

sẽ sử dụng được.Khi dùng ta thực hiện ngay

\usepackage[<Tùy chọn>]{caption}

\usepackage[<Tùy chọn>]{subcaption}

Ta có thể sử dụng trực tiếp tùy chọn cho gói lệnh này như:

\usepackage{subcaption}

\captionsetup[sub]{<Tùy chọn>}

Mặc định đặt trong subcaption.sty là:

margin=0pt,font+=small,labelformat=parens,labelsep=space,

skip=6pt,list=false,hypcap=false

Tùy chọn chỉ ra trong \usepackage[. . . ]{subcaption}

và \captionsetup[sub]{. . .} sẽ được đè lên tùy chọn của\captionsetup{. . .} và \captionsetup[figure]{. . .}, nhưng có thể ghiđè lại bằng \captionsetup[subfigure]{. . .} (tương tự cho ‘table’).

Một số quy tắc chỉ ra thứ tự đặt tùy chọn:

1. Đặt tùy chọn cho toàn cục (\usepackage[. . . ]{caption} và\captionsetup{. . . })

2. Đặt môi trường (\captionsetup[figure -hoặc- table]{. . . })

3. Đặt cho cục bộ (\captionsetup{. . .} trong môi trường figure hoặc ta-ble)

4. Mặc định đặt cho ‘sub’ (margin=0pt,font+=small,. . . , như ở trên)

1

Page 2: Subcaption help

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

5. Đặt lại cho ‘sub’ (\usepackage[. . . ]{subcaption} và\captionsetup[sub]{. . .})

6. Đặt cho môi trường ‘sub’ (\captionsetup[subfigure -hoặc- subtable]{. . . })

7. Đặt địa phương ‘sub’ (\captionsetup{. . . } trong subfigure hoặc sub-table)

Ví dụ

\usepackage[labelsep=quad,indention=10pt]{caption}

\usepackage[labelfont=bf,list=true]{subcaption}

\captionsetup[table]{textfont=it,position=top}

\captionsetup[subtable]{textfont=sf}

Vậy tùy chon trong môi trường subtable đã có

indention=10pt,position=top,margin=0pt,font=small,

labelformat=parens,labelsep=space,skip=6pt,hypcap=false,

labelfont=bf,list=true,textfont=sf

2 Sử dụng

1. Lệnh \subcaption giống như \caption và kết hợp với nhau như

\begin{figure}[!htp]

\begin{minipage}[b]{.5\linewidth}

\centering\large A

\subcaption{A subfigure}\label{fig:1a}

\end{minipage}%

\begin{minipage}[b]{.5\linewidth}

\centering\large B

\subcaption{Another subfigure}\label{fig:1b}

\end{minipage}

\caption{A figure}\label{fig:1}

\end{figure}

A(a) A subfigure

B(b) Another subfigure

Hình 1 – A figure

2. Môi trường subfigure và subtable

\begin{figure}[!htp]

\begin{subfigure}[b]{.5\linewidth}

\centering

\includegraphics[height=2cm,width=3cm]{cat.eps}

Page 3: Subcaption help

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

\caption{A subfigure}\label{fig:1a}

\end{subfigure}%

\begin{subfigure}[b]{.5\linewidth}

\centering

\includegraphics[height=2cm,width=3cm]{cat.eps}

\caption{Another subfigure}\label{fig:1b}

\end{subfigure}

\caption{A figure}\label{fig:1}

\end{figure}

(a) A subfigure (b) Another subfigure

Hình 2 – A figure

\begin{table}[!htp]

\begin{subtable}[b]{.5\linewidth}

\centering

\begin{tabular}{| l | l |}

\hline

A&B\\

\hline

C&D\\

\hline

\end{tabular}

\caption{A subfigure}\label{fig:1a}

\end{subtable}%

\begin{subtable}[b]{.5\linewidth}

\centering

\begin{tabular}{| l | l |}

\hline

1&2\\

\hline

3&4\\

\hline

\end{tabular}

\caption{Another subfigure}\label{fig:1b}

\end{subtable}

\caption{A figure}\label{fig:1}

\end{table}

Page 4: Subcaption help

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

A BC D

1.1: A subtable

1 23 4

1.2: Another subtable

Bảng 1 – A figure

2. Dùng lệnh \subcaptionbox để định dạng chú thíchCó thể đặt tùy chọn

\subcaptionbox[<list entry>]{<heading>}[<width>][<inner-pos>]{<nội dung>}

\subcaptionbox*{<heading>}[<width>][<inner-pos>]{<contents>}

\begin{figure}[!htp]

\centering

\subcaptionbox{A cat\label{cat}}

{\includegraphics[height=1.3cm,width=2cm]{cat}}

\subcaptionbox{An elephant\label{elephant}}

{\includegraphics[height=5cm,width=5cm]{elephant}}

\caption{Two animals}\label{animals}

\end{figure}

(a) A cat (b) An elephant

Hình 3 – Two animals

\begin{figure}[!htp]

\centering

\subcaptionbox{A cat\label{cat}}[.4\linewidth]

{\includegraphics[height=1.3cm,width=2cm]{cat}}

\subcaptionbox{An elephant\label{elephant}}[.4\linewidth]

{\includegraphics[height=5cm,width=5cm]{elephant}}

\caption{Hai con thú cách ra}\label{animals}

\end{figure}

Page 5: Subcaption help

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

(a) A cat (b) An elephant

Hình 4 – Hai con thú cách ra

3. Dùng lệnh \subref trích dẫn chỉ sốTa thấy (\ref{cat}) là (4a) và (\subref{cat}) là (a)

4. Dùng lệnh \DeclareCaptionSubType

\DeclareCaptionSubType*[arabic]{table}

\captionsetup[subtable]{labelformat=simple,labelsep=colon}

\noindent\begin{minipage}{\linewidth}

\captionsetup{type=table}

\centering

\caption{Two tables}

\subcaptionbox{Table one}[3cm][c]{

\begin{tabular}{cc}

A & B\\

C & D\\

\end{tabular}}

\subcaptionbox{Table two}[3cm][c]{

\begin{tabular}{cc}

E & F\\

G & H\\

\end{tabular}}

\end{minipage}

Bảng 2 – Two tables

2.1: Table one

A BC D

2.2: Table two

E FG H