├── .gitignore
├── README.md
├── contents
├── chapter01.tex
├── chapter02.tex
├── chapter03.tex
├── chapter04.tex
├── chapter05.tex
├── chapter06.tex
├── chapter07.tex
├── chapter08.tex
├── chapter09.tex
├── chapter10.tex
├── chapter11.tex
├── chapter12.tex
├── chapter13.tex
├── license.tex
└── references.tex
├── docsetup.tex
├── figures
├── chapter03
│ ├── baseline.mp
│ ├── baseline.pdf
│ ├── latex-flow.pdf
│ └── latex-flow.tex
├── chapter04
│ ├── fntsize.pdf
│ └── fntsize.tex
├── chapter05
│ ├── layout-r.pdf
│ └── layout-r.tex
├── chapter10
│ ├── cmath01.pdf
│ ├── cmath01.tex
│ ├── cmath02.pdf
│ └── cmath02.tex
├── cover.mp
└── cover.pdf
├── fonts
└── chinese
│ ├── HanWangMingHeavy.ttf
│ ├── HanWangMingMedium.ttf
│ └── HanWangYanKai.ttf
├── latex123.cls
├── main.pdf
└── main.tex
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.toptal.com/developers/gitignore/api/latex
3 | # Edit at https://www.toptal.com/developers/gitignore?templates=latex
4 |
5 | ### LaTeX ###
6 | ## Core latex/pdflatex auxiliary files:
7 | *.aux
8 | *.lof
9 | *.log
10 | *.lot
11 | *.fls
12 | *.out
13 | *.toc
14 | *.fmt
15 | *.fot
16 | *.cb
17 | *.cb2
18 | .*.lb
19 |
20 | ## Intermediate documents:
21 | *.dvi
22 | *.xdv
23 | *-converted-to.*
24 | # these rules might exclude image files for figures etc.
25 | # *.ps
26 | # *.eps
27 | # *.pdf
28 |
29 | ## Generated if empty string is given at "Please type another file name for output:"
30 | # .pdf
31 |
32 | ## Bibliography auxiliary files (bibtex/biblatex/biber):
33 | *.bbl
34 | *.bcf
35 | *.blg
36 | *-blx.aux
37 | *-blx.bib
38 | *.run.xml
39 |
40 | ## Build tool auxiliary files:
41 | *.fdb_latexmk
42 | *.synctex
43 | *.synctex(busy)
44 | *.synctex.gz
45 | *.synctex.gz(busy)
46 | *.pdfsync
47 |
48 | ## Build tool directories for auxiliary files
49 | # latexrun
50 | latex.out/
51 |
52 | ## Auxiliary and intermediate files from other packages:
53 | # algorithms
54 | *.alg
55 | *.loa
56 |
57 | # achemso
58 | acs-*.bib
59 |
60 | # amsthm
61 | *.thm
62 |
63 | # beamer
64 | *.nav
65 | *.pre
66 | *.snm
67 | *.vrb
68 |
69 | # changes
70 | *.soc
71 |
72 | # comment
73 | *.cut
74 |
75 | # cprotect
76 | *.cpt
77 |
78 | # elsarticle (documentclass of Elsevier journals)
79 | *.spl
80 |
81 | # endnotes
82 | *.ent
83 |
84 | # fixme
85 | *.lox
86 |
87 | # feynmf/feynmp
88 | *.mf
89 | *.mp
90 | *.t[1-9]
91 | *.t[1-9][0-9]
92 | *.tfm
93 |
94 | #(r)(e)ledmac/(r)(e)ledpar
95 | *.end
96 | *.?end
97 | *.[1-9]
98 | *.[1-9][0-9]
99 | *.[1-9][0-9][0-9]
100 | *.[1-9]R
101 | *.[1-9][0-9]R
102 | *.[1-9][0-9][0-9]R
103 | *.eledsec[1-9]
104 | *.eledsec[1-9]R
105 | *.eledsec[1-9][0-9]
106 | *.eledsec[1-9][0-9]R
107 | *.eledsec[1-9][0-9][0-9]
108 | *.eledsec[1-9][0-9][0-9]R
109 |
110 | # glossaries
111 | *.acn
112 | *.acr
113 | *.glg
114 | *.glo
115 | *.gls
116 | *.glsdefs
117 | *.lzo
118 | *.lzs
119 |
120 | # uncomment this for glossaries-extra (will ignore makeindex's style files!)
121 | # *.ist
122 |
123 | # gnuplottex
124 | *-gnuplottex-*
125 |
126 | # gregoriotex
127 | *.gaux
128 | *.gtex
129 |
130 | # htlatex
131 | *.4ct
132 | *.4tc
133 | *.idv
134 | *.lg
135 | *.trc
136 | *.xref
137 |
138 | # hyperref
139 | *.brf
140 |
141 | # knitr
142 | *-concordance.tex
143 | # TODO Comment the next line if you want to keep your tikz graphics files
144 | *.tikz
145 | *-tikzDictionary
146 |
147 | # listings
148 | *.lol
149 |
150 | # luatexja-ruby
151 | *.ltjruby
152 |
153 | # makeidx
154 | *.idx
155 | *.ilg
156 | *.ind
157 |
158 | # minitoc
159 | *.maf
160 | *.mlf
161 | *.mlt
162 | *.mtc
163 | *.mtc[0-9]*
164 | *.slf[0-9]*
165 | *.slt[0-9]*
166 | *.stc[0-9]*
167 |
168 | # minted
169 | _minted*
170 | *.pyg
171 |
172 | # morewrites
173 | *.mw
174 |
175 | # nomencl
176 | *.nlg
177 | *.nlo
178 | *.nls
179 |
180 | # pax
181 | *.pax
182 |
183 | # pdfpcnotes
184 | *.pdfpc
185 |
186 | # sagetex
187 | *.sagetex.sage
188 | *.sagetex.py
189 | *.sagetex.scmd
190 |
191 | # scrwfile
192 | *.wrt
193 |
194 | # sympy
195 | *.sout
196 | *.sympy
197 | sympy-plots-for-*.tex/
198 |
199 | # pdfcomment
200 | *.upa
201 | *.upb
202 |
203 | # pythontex
204 | *.pytxcode
205 | pythontex-files-*/
206 |
207 | # tcolorbox
208 | *.listing
209 |
210 | # thmtools
211 | *.loe
212 |
213 | # TikZ & PGF
214 | *.dpth
215 | *.md5
216 | *.auxlock
217 |
218 | # todonotes
219 | *.tdo
220 |
221 | # vhistory
222 | *.hst
223 | *.ver
224 |
225 | # easy-todo
226 | *.lod
227 |
228 | # xcolor
229 | *.xcp
230 |
231 | # xmpincl
232 | *.xmpi
233 |
234 | # xindy
235 | *.xdy
236 |
237 | # xypic precompiled matrices and outlines
238 | *.xyc
239 | *.xyd
240 |
241 | # endfloat
242 | *.ttt
243 | *.fff
244 |
245 | # Latexian
246 | TSWLatexianTemp*
247 |
248 | ## Editors:
249 | # WinEdt
250 | *.bak
251 | *.sav
252 |
253 | # Texpad
254 | .texpadtmp
255 |
256 | # LyX
257 | *.lyx~
258 |
259 | # Kile
260 | *.backup
261 |
262 | # gummi
263 | .*.swp
264 |
265 | # KBibTeX
266 | *~[0-9]*
267 |
268 | # TeXnicCenter
269 | *.tps
270 |
271 | # auto folder when using emacs and auctex
272 | ./auto/*
273 | *.el
274 |
275 | # expex forward references with \gathertags
276 | *-tags.tex
277 |
278 | # standalone packages
279 | *.sta
280 |
281 | # Makeindex log files
282 | *.lpz
283 |
284 | # REVTeX puts footnotes in the bibliography by default, unless the nofootinbib
285 | # option is specified. Footnotes are the stored in a file with suffix Notes.bib.
286 | # Uncomment the next line to have this generated file ignored.
287 | #*Notes.bib
288 |
289 | ### LaTeX Patch ###
290 | # LIPIcs / OASIcs
291 | *.vtc
292 |
293 | # glossaries
294 | *.glstex
295 |
296 | # End of https://www.toptal.com/developers/gitignore/api/latex
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | [](./LICENSE)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | # 大家來學 LaTeX
19 |
20 | 📖 _The classic and complete guide written in Traditional Chinese to help you get started on your journey with LaTeX_
21 |
22 |
23 |
24 | ## 簡介
25 |
26 | 此倉庫託管著李果正(Edward G.J. Lee)先生於 2004 年接受中華民國行政院研考會委辦的「政府機關資料文件交換之電子檔案格式應用研究」計畫補助所撰寫的《大家來學 LaTeX》原始程式代碼。
27 |
28 | 絕大多數使用 LaTeX 進行專業文章排版的中文使用者必定曾經耳聞或閱讀過此書,但 LaTeX 歷經多年的發展,書中已有部分內容在今時今日已然不適用,本專案將根據原書的章節順序與原稿進行適當編修。
29 |
30 | ## 編譯說明
31 |
32 | ### 圖片處理
33 |
34 | 使用 MetaPost 繪製的 `*.mp` 檔案需要使用 [`mptopdf`](https://linux.die.net/man/1/mptopdf) 轉換為 `*.pdf` 才能插入至文件中:
35 |
36 | ```bash
37 | $ sudo apt install mptopdf texlive-metapost
38 | $ mptopdf <*.mp>
39 | ```
40 |
41 | 使用 LaTeX 繪製的 `*.pdf` 檔案根據設置的文件格式不同可能存在白邊,此處使用 [`pdfCropMargins`](https://pypi.org/project/pdfCropMargins/) 去除:
42 |
43 | ```bash
44 | $ pip install pdfCropMargins --upgrade
45 | $ pdf-crop-margins -v -p 0 -a -6 <*.pdf>
46 | ```
47 |
48 | ### 文件編譯
49 |
50 | 於 `main` 分支中版本須使用 `xelatex` 進行編譯:
51 |
52 | ## 增修內容
53 |
54 | ### 修改
55 |
56 | - 編碼轉換:將原始檔案由 `BIG5` 編碼轉換為 `utf8` 編碼。
57 | - 目錄結構:重新整理檔案與資料夾結構,並將封面設計、頁眉設計、顏色設定…等整併為 `latex123.cls` 主題文件。
58 | - 編譯引擎:中文排版方案改為使用 `xelatex` 搭配 `xeCJK` 與 `fontspec` 套件進行編譯。
59 |
60 | ### 🚧 新增
61 |
62 | - [ ] 章節內容編修
63 |
64 | ## 原始檔案
65 |
66 | 本書的原始檔案曾經託管於淡江大學數學系的伺服器上,但連結已不復存在。倉庫中的原始代碼來源自靜宜大學資訊學院所保留之 v1.0 的原始檔案:
67 |
68 | - [《大家來學 LaTeX》線上文件](https://www.cs.pu.edu.tw/~wckuo/doc/latex123/)
69 | - [《大家來學 LaTeX》編譯文件](https://www.cs.pu.edu.tw/~wckuo/doc/latex123/latex123.pdf)
70 | - [《大家來學 LaTeX》原始代碼](https://www.cs.pu.edu.tw/~wckuo/doc/latex123/latex123-v1.0-src.tar.gz)
71 |
72 | 原始檔案提交於 [`legacy`](./tree/legacy) 分支中,或可以在 [Release v1.0](https://github.com/Hsins/LaTeX123/releases/tag/v1.0) 中找到。
73 |
74 | ## 授權許可
75 |
76 | Licensed under the GNU Free Documentation License, Copyright © 2004-present Edward G.J. Lee.
77 |
--------------------------------------------------------------------------------
/contents/chapter01.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{先來說一些故事}
4 |
5 | \TeX{} 是 Donald~E.~Knuth\footnote{\url{http://www-cs-faculty.stanford.edu/~knuth/}}\index{Donald~E.~Knuth} 教授的精心傑作,它是個功能非常強大的幕後排版系統,含有彈性很大,而且很低階的排版語言。當初,是因為 Knuth 教授在寫他的大著 TAOCP(\textit{The Art of Computer Programming})\index{TAOCP} 時,發覺書商把他書中的數學式子排得太難看了,於是決定自行開發一個非常適合排數學式子的排版語言,這就是 \TeX{} 系統的來由。
6 |
7 | 不僅僅是談到 \TeX{} 一定會提到 Knuth教授,只要提到排版,沒有人可以忽略他的 \TeX{} 所帶來的變革、影響,甚至 \TeX{} 已經 20 幾歲了,仍然深深影響著排版界及排版軟體,可見這個排版軟體真的是非同小可。
8 |
9 | \section{Knuth 教授的生平簡介}
10 |
11 | \begin{quote}
12 | \begin{tabular}{lp{.78\textwidth}}
13 | 1938.01.10 & 誕生。Milwaukee, Wisconsin; U.S. citizen。\\
14 | 1956 & 進入凱思工學院(Case Institute of Technology)學習物理。\\
15 | 1960 & 畢業後進入加州理工學院(California Institute of Technology)研究所,此時轉向數學領域的研究方向。\\
16 | 1961.06.24 & 和 Nancy Jill Carter 結婚。他的中文名字是高德納\index{高德納},他老婆名叫高精蘭\index{高精蘭},老婆小他一歲。兩個小孩,一男一女。中文名字是 1977 去中國大陸時取的。\\
17 | 1963 & 拿到 Ph.D.,並留校任教。\\
18 | 1968 & 開始任教於 Stanford 大學,資訊科學系(Computer Science)。同年開始撰寫名聞遐邇的 TAOCP({\em The Art of Computer Programming})。有人曾說,看了這部書,往後對寫程式的話題都會變得謙虛。:)\\
19 | 1977 & 不滿意書商所印出的 TAOCP,因此,自行開發 \TeX{} 排版系統,這可就影響了往後的排版、出版界,至今不墜。但也因此拖延了 TAOCP 第四冊的完成時間。\\
20 | 1986 & 榮獲 ACM 軟體系統獎。
21 | \end{tabular}
22 | \end{quote}
23 |
24 | 他可說是著作等身,書籍、論文都有,他的任何著作有個奇怪的『副作用』,那就是任何人發現書上的錯誤,都可以向他舉發,並領取 \$2.56(美金)!想試試看「手氣」嗎?台灣就有人領過。:-) 為什麼是 \$2.56?Knuth 教授的答案是:
25 |
26 | \begin{quote}
27 | \itshape
28 | ``256 pennies is one hexadecimal dollar.''
29 | \end{quote}
30 |
31 | 發現 \TeX{} 系統的臭蟲也是一樣,這個獎金每年倍數增加,直至 \$655.36($2^{16}$ pennies) 為止。
32 |
33 | 他也很推崇自由軟體基金會 (Free Software Foundation)%
34 | \footnote{\url{http://www.fsf.org}}\index{自由軟體基金會}\index{Free Software Foundation}
35 | 及 GNU/Linux\index{GNU/Linux},把一些希望都寄託於 GNU/Linux,尤其是 Unicode 環境,他希望 GNU/Linux 很快就能在網頁上顯示他的中文名字,而不必使用圖檔。其實是可以做到了,只是 Unicode 環境還不算普及罷了。他曾在 1996 年接受 Dr.~Dobb's~Journal 訪問時英雄惜英雄的公開表示,創導自由軟體 (Free Software)%
36 | \footnote{\url{http://www.gnu.org/philosophy/free-sw.html}}\index{自由軟體}\index{Free Software}
37 | 的 Richard~M.~Stallman\index{Richard~M.~Stallman} 是他心目中的英雄之一,他認為自由軟體基金會這些人所做的貢獻很不錯,雖然和他的方式不一定一樣,但許多貢獻是互有認同的。
38 |
39 | 在發展 \TeX{} 時就同時思考 WEB(這個詞比目前使用的 WWW Web 還早使用)\index{WEB},那是一種 literate programming\index{literate programming} 的程式方法。他認為目前已成熟的可以提出含有文件的程式方法,使寫程式就像寫文學作品(小說?)一般的藝術表現。後來也把他由 C 改寫(和 Silvio~Levy\index{Silvio~Levy} 合作),名為 CWEB\index{CWEB}\index{CWEB}%
40 | \footnote{\url{http://www-cs-faculty.stanford.edu/~knuth/cweb.html}}。\TeX{} 就是由 WEB 寫成的,WEB 可視為 Pascal 語言的一個子集。
41 |
42 | 一個 literate 程式師可被視為文學作家、評論寫作者、隨筆作者\chdots{},程式的表現不僅僅是搬弄符號,而是展現自己的風格,當然也是指達成目的的風格、甚至程式中變數運用的風格。
43 |
44 | 這樣一來就可以展現讓人類較能理解的程式碼。使用形式及非形式的融合,而且兩者間相輔相成,目的達成了,也讓閱讀的人就好像讀文學作品般的去抓住作者的心,使程式創作提升至更高的(文學)藝術境界,而不再是死板板的 code 了。
45 |
46 | Knuth 大師已於 1992 年自大學退休,但仍在 Stanford/Oxford 等大學有授課。目前正處於隱居的生活,他這麼早退休的原因,就是因為 TAOCP 這部書,他估計大約要花 20 年來完成,因此目前的重點工作是完成他的 TAOCP(分成好幾冊,目前真正出版的只有三大冊)。他認為
47 | email\footnote{\url{http://www-cs-faculty.stanford.edu/~knuth/email.html}}
48 | 會影響他的思路,因此,寧願留住址,要和他聯絡就只好寫信,傳真。給他的秘書的 email,是最後有時間才會去看,他曾公開的表明,這部書是他這一生中最重要的工作。
49 |
50 | 雖然 Knuth 教授寫了許多嚴肅艱深的書籍、論文,但是他也是有風趣的一面,在 1996 年,\textit{Mathematisch Centrum }(MC, 為慶祝五十周年慶改稱為 \textit{Centrum voor Wiskunde en Informatica}, CWI) 曾邀請他演講,並知會荷蘭的 \TeX{} User Group(NTG)%
51 | \footnote{\url{http://www.ntg.nl},荷蘭的 \TeX{} User Group 算是相當活躍的。},NTG 見機會難得,就邀請 Knuth 教授另開個 \TeX{} 及 \MF\ 討論會,並接受大家的提問,他說:『不對,我也是可以問你們問題的!』。而且,他還說:『這種問答的內容,很可能在不同場合重複過,所以,如果我對同一個問題,曾有過兩種答案的話,你們必需取其平均值。』他的妙語如珠,在許多類似的場合常常引起哄堂大笑,但實際的內容卻絕非泛泛之言。:-)
52 |
53 | \subsection{TAOCP(\textit{The Art of Computer Programming})\index{TAOCP}\index{The Art of Computer Programming@\textit{The Art of Computer Programming}}}
54 |
55 | 這可是演算法的大著,請別折騰我,我只是心嚮往之,這部書我沒有一本是看得懂的。:-)
56 |
57 | \begin{quote}
58 | \begin{enumerate}
59 | \item 第一冊,{\em Fundamental Algorithms},1968 第一版,ISBN 0-201-89683-4。
60 | \item 第二冊,{\em Seminumerical Algorithms},1969 第一版,ISBN 0-201-89684-2。
61 | \item 第三冊,{\em Sorting and Searching},1973 第一版,ISBN 0-201-89685-0。
62 | \item 第四冊,{\em Combinatorial Algorithms},尚未完成,可能會先出分冊。
63 | \begin{enumerate}
64 | \item 分冊 4A, {\em Enumeration and Backtracking}
65 | \item 分冊 4B, {\em Graph and Network Algorithms}
66 | \item 分冊 4C, {\em Optimization and Recursion}
67 | \end{enumerate}
68 | \item 第五冊,{\em Syntactic Algorithms},計劃 2010 年完成。
69 | \item 第六冊,the theory of context-free languages,書名可能會變更,尚未開始。
70 | \item 第七冊,Compiler techniques,書名可能會變更,尚未開始。
71 | \end{enumerate}
72 | \end{quote}
73 |
74 | 詳細的目錄大綱及修訂版的資訊,請參考網頁上的資料:
75 |
76 | \begin{quote}
77 | \url{http://www-cs-staff.stanford.edu/~knuth/taocp.html}
78 | \end{quote}
79 |
80 | \section{那麼,\LaTeX{} 又是什麼呢?}
81 |
82 | \TeX{} 是個很低階的排版語言,如果排版時都要從這種低階語言來控制版面的話,那將會非常的煩複,所以,一些經常要用到的功能,都會先去定義好(稱為巨集,macro\index{macro}\index{巨集}),這樣排版時才會方便、快速,直接引用已定義好的巨集裡頭的指令就可以了。
83 |
84 | 原始的 \TeX{} 已經有了一組 macro,是 Knuth 教授所寫的,那就是著名的 Plain \TeX{}\index{Plain \TeX{}},但仍然不夠方便、直觀,於是
85 | Leslie~Lamport\index{Leslie~Lamport}\footnote{Leslie~Lamport 於 1985 在
86 | \htmladdnormallink{CSL}{http://www.csl.sri.com/}
87 | 任職時寫了 \LaTeX{}。目前任職於
88 | \htmladdnormallink{DEC Systems Research Center}{http://www.research.digital.com/SRC/home.html}
89 | 但已幾乎沒有參與 \LaTeX{} 的後續發展了。}
90 | 又寫了另一組的 macro,稱為 \LaTeX{},主要是把版面配置和文章內容,適度的分開處理,只要使用者選定了一種類別,整本書或整篇文章的結構就是按照這個類別來安排版面,這樣寫文件的人只要專注於文章內容就可以了,版面配置就完全交給 \TeX{}/\LaTeX{} 去處理。
91 |
92 | 既然 \LaTeX{} 只不過是 \TeX{} 的一大組巨集,那,當然原來的 \TeX{} 的指令,大部份也是可以用在 \LaTeX{} 文稿當中的。而且,\LaTeX{} 並不是目前唯一的 \TeX{} macro,其他如 eplain \TeX{}, Con\TeX{}t, \TeX{}info 等都是 \TeX{} macro,也都有他們自成一套的語法。目前的 \LaTeX{} 由
93 | \LaTeX{} 3 Project\footnote{\url{http://www.latex-project.org/latex3.html}}
94 | 所維護及發展。
95 |
96 | 如果談到這裡,你還是霧煞煞的話,類比成 HTML markup 標記語言就能大概知道一些概念了,當然,這和 HTML 標記語言是可相提而無法並論的。如果連 HTML 也不熟悉,那也沒關係啦!這章本來就是在說故事嘛!:-) 只要繼續看後面的內容就行了。
97 |
98 | \section{一般人對 \LaTeX{} 的迷思}
99 |
100 | 這裡引用 Peter Flynn\index{Peter Flynn} 在他的
101 | \textit{A beginner's introduction to typesetting with \LaTeX{}}\footnote{\url{ftp://ftp.dante.de/tex-archive/info/beginlatex/beginlatex.pdf}}
102 | 一文中所提出來的六大迷思,並添加個人的一些看法:
103 |
104 | \begin{itemize}
105 |
106 | \item \LaTeX{} 只能使用一種字型? \newline
107 | 當然不是,雖然 \TeX{} 系統預設是使用當初 Knuth 教授所設計的 \MF{},但目前 OpenType, TrueType, Adobe Type1 字型都可以用在 \LaTeX{} 當中,只不過,安裝字型的部份不是那麼的直觀就是了,但比起其他的排版系統,\TeX{}/\LaTeX{} 所能利用的字型種類,可以說是最多的。
108 |
109 | \item \LaTeX{} 只能用於 Unix-like 的作業系統? \newline
110 | Knuth 教授慷慨的把 \TeX{} 的原始程式碼開放出來\footnote{雖然有一些版權的規定,但是 Knuth 教授的本意,這些原始碼是屬於 Public Domain,只是,如果經過修改,不能再以 \TeX{} 為名,要另外改一個名稱,以免和原來的 \TeX{} 搞混。\TeX{} 這個商標的所有人是美國數學協會(American Mathematical Society, AMS\index{AMS}\index{American Mathematical Society})。},所以,只要是有人在使用的作業系統都可以移植過去,不必擔心版權的問題。像 MS DOS, OS/2, MS Windows, Mac OS, Unix-like 系統都有 \TeX{} 的移植版本,甚至是 PDA(e.g.~the Sharp \textsl{Zaurus})都有 \TeX{}/\LaTeX{} 的縱跡。可以說是走到哪兒,就可以用到哪兒,而且,文稿都是互通的,列印結果也相同。
111 |
112 | \item \LaTeX{} 已經過時了? \newline
113 | 剛好相反,\LaTeX{} Project\footnote{\url{http://www.latex-project.org/}}及其他相關 packages 正穩定的研發當中,尤其和目前新一代的 SGML/XML/HTML 及資料庫系統,都積極的想辦法銜接起來。對於數學式子的排版,至今無人能出其右。有興趣的話,可以參考 \url{news://comp.text.tex} 的流量,及其中 \textsc{CTAN}\footnote{\url{http://tug.ctan.org/}}\index{CTAN} 對於巨集更新、上傳的消息發布。
114 |
115 | \item \LaTeX{} 沒有所見即所得(WYSIWYG\index{WYSIWYG})? \newline
116 | 某種層面上而言,是的。因為他本質上是幕後排版系統\index{幕後排版系統}。但是,所產生的 dvi/ps/pdf 檔,可以很精準的顯示你所想要表達的內容,不曉得這算不算是「所見即所得」?另外,一些相關 GUI 配合的軟體,也會打破幕後排版的定義,例如 LyX\footnote{\url{http://www.lyx.org/}}\index{LyX}, \TeX{}macs\footnote{\url{http://www.texmacs.org/}}\index{TeXmacs@\TeX{}macs} 等等。
117 |
118 | \item \LaTeX{} 很難學? \newline
119 | 這個嘛!我只能說,有什麼東西是很好學的?如果只是一般使用,而不是當個排版專家,甚至 \TeX{}/\LaTeX{} programmer,那麼,幾十分鐘的說明,就可以「上工」了!剩下的只是一些細部調整的問題(不去調整,也絕對不會離譜)。相對於一般圖形化 Office 類軟體,要真正把他的內容熟悉,恐怕也是不簡單的。另外的問題,大概是幕前、幕後系統操作習慣的問題,甚至是一種第一印象了,就好像說到電腦,有不少人的腦子裡就會浮現 MS Windows 的圖象一樣。:-)
120 |
121 | \item \LaTeX{} 是專為科學家或數學家而寫的? \newline
122 | 的確,當初 Knuth 教授是為了表達精確、品質優美的數學式子而開發 \TeX{} 的,但由於 \TeX{} 的彈性,使得在其他的領域的使用者也爭相使用,已經不是局限在學術界在使用了。尤其 XML\index{XML} 的興起,需要一個適合的格式化工具(formatter\index{formatter})的配合,\TeX/\LaTeX{} 就剛好稱職的做他排版專業的工作。
123 |
124 | \end{itemize}
125 |
126 | \section{本文的重點方向}
127 |
128 | \TeX{}/\LaTeX{} 的相關議題:版面的配置、排版規範、字型技術、\TeX{} the program 的改進、繪圖技術、\TeX{} macro 的撰寫、pre/post 處理程式的撰寫、出版流程 \chdots{} 等等,浩瀚無涯,可以說窮一輩子也可能研究不完,所以,各位在「陷入」這個領域之前,建議最好有個適當的範圍,以免「愈陷愈深」終至無法自拔。
129 |
130 | 所以,本文的重點是放在「標準」 \LaTeX{} 本身,其他相關的 package/macro 除非必要,盡量不提及。但是 \LaTeX{} 本身也不是十全十美的,所以,有需要的地方也需要一並提及外來的 macro,無論如何,重點是放在標準 \LaTeX{} 本身,請閱讀本文的朋友注意一下這個方向。\LaTeX{} 本身就能解決的,就不假外求了,雖然會失去了一些彈性,但為免造成 package/macro 滿天飛,打亂學習陣腳,剛開始也只好如此了!
131 |
132 | 而且,可能的情形下,會往一般用途的方向去介紹,而不僅僅專注在數理排版。數學式子雖是 \TeX{}/\LaTeX{} 的拿手把戲,但不代表一般用途就不適合,相反的,現在有許多商業公司正把 \TeX{}/\LaTeX{} 用於一般商業出版上。
133 |
--------------------------------------------------------------------------------
/contents/chapter02.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{行前準備}
4 |
5 | 使用 \TeX{}/\LaTeX{} 系統,剛開始,比較麻煩的是安裝問題。不過,以現在的作業系統而言,幾乎較流行的作業系統都有現成包好的 \TeX{} 系統套件可以安裝,例如 Un*x 系統的 te\TeX{}\index{teTeX@te\TeX{}}、Windows 系統的 MiK\TeX{}\index{MiKTeX@MiK\TeX{}} 及 fp\TeX{}\index{fpTeX@fp\TeX{}}。另外,也有
6 | \TeX{} Live CD\footnote{\url{http://tug.org/texlive/}}\index{TeX Live CD@\TeX{} Live CD}
7 | 可以供下載、購買,這是
8 | TUG(\TeX{} User Group)\footnote{\url{http://www.tug.org/}。加入會員的話,只要些許會費,則可以獲得 \TeX{} Live CD 及年報資訊的寄發。}
9 | 製作的各種作業系統的可執行檔,使用上相當方便。
10 |
11 | 目前所謂的 \TeX{} 套件,是把原來的 \TeX{} 排版引擎本身,加上 \LaTeX{} 及其他相關的巨集,再加上字型軟體(\MF{})、繪圖程式(\MP{})、字型檔 \chdots{} 等等,所組合成的一整個可實際運作的排版系統。因此,什麼是 \TeX{}?會因使用的場合不同而有不同的意義,一般純指指令本身的時候,就單純寫成小寫的 {\ttfamily tex},此時所用的巨集,預設就是 Knuth 教授所寫的 plain \TeX{}。寫成 \TeX{} 時,一般是指整個系統而言。這在 \LaTeX{} 巨集亦同,{\ttfamily latex} 指的是指令,\LaTeX{} 指的是整個巨集系統。
12 |
13 | \section{Unix-like 系統}
14 |
15 | 一般 Unix-like 系統都是安裝 te\TeX{} 套件,凡是和 {\ttfamily tetex} 字樣相關的 packages 都安裝起來,目前 GNU/Linux\index{GNU/Linux} 各種 distribution 及 FreeBSD\index{FreeBSD} 都有現成的 packages 供安裝使用。如果是沒有提供這個套件的作業系統,可能得自行編譯了,原始碼在:
16 |
17 | \begin{quote}
18 | \url{http://www.tug.org/teTeX} \\
19 | \url{ftp://cam.ctan.org/tex-archive/systems/unix/teTeX} \\
20 | \url{ftp://tug.ctan.org/tex-archive/systems/unix/teTeX} \\
21 | \url{ftp://dante.ctan.org/tex-archive/systems/unix/teTeX}
22 | \end{quote}
23 |
24 |
25 | \section{MS Windows 系統}
26 |
27 | 最常使用的 free 版本,大概就是 MiK\TeX{} 及 fp\TeX{},其中,後者等於是 Un*x 中的 te\TeX{} 的 Windows 移植版本。
28 |
29 | \begin{quote}
30 | \url{http://www.miktex.org/} \\
31 | \url{http://www.fptex.org/}
32 | \end{quote}
33 |
34 | 安裝的話都自動化了,應該可以很方便的安裝起來。
35 |
36 | \subsection{cygwin 環境}
37 |
38 | 這是 Windows 系統下的一個 Un*x 環境(正確的說,是 Linux-like),有了這個環境就可以使用 Unix-like 的界面,也可以編譯 Unix-like 中的程式,當然也就可以安裝 Unix-like 系統的 te\TeX{} 套件了,有人習慣了 Unix-like 的操作環境,但又常需要在 Windows 平台下作業,這是個不錯的選擇。
39 |
40 | \begin{quote}
41 | \url{http://sources.redhat.com/cygwin} \\
42 | \url{http://sources.redhat.com/cygwin/setup.exe}
43 | \end{quote}
44 |
45 | 只要先下載 {\ttfamily setup.exe} 這個可執行檔,然後執行後按著指示就可以完成安裝,當然,網路要連線。至於 te\TeX{} 相關的套件,安裝好 cygwin\index{cygwin} 就會安裝,至於中文 \textsf{CJK}\index{CJK@\textsf{CJK}} 套件,感謝 seventeen\index{seventeen} 的製作,請參考:
46 |
47 | \begin{quote}
48 | \url{http://seventeen.mit.edu/blog/17/archives/000141.html}
49 | \end{quote}
50 |
51 |
52 | \section{Mac OS X 系統}
53 |
54 | 個人對 Mac OS X\index{Mac OS X} 並不熟悉,所以僅提供個人知道的 distribution。但 Mac OS X 亦可以安裝 Un*x 系統上的 te\TeX{} 系統,也可以在其上自行編譯。
55 |
56 | \begin{quote}
57 | 參考文件:\\
58 | \htmladdnormallink{[文件]MacOS 10.2.4安裝teTeX}{http://groups.google.com/groups?q=macos+group:tw.bbs.comp.tex&hl=zh-TW&lr=&ie=UTF-8&inlang=zh-TW&group=tw.bbs.comp.tex&selm=468AAJ\%24sn4\%40bbs.sayya.org&rnum=1}\\
59 | \url{http://www.rna.nl/tex.html}\\
60 | \url{http://www.cs.wright.edu/~jslater/mac-tex/mac-tex-intro/mac-tex-intro.pdf}\\
61 | \TeX{}Shop\\
62 | \url{http://www.uoregon.edu/~koch/texshop/texshop.html}\\
63 | i\TeX{}Mac\\
64 | \url{http://itexmac.sourceforge.net/}
65 | \end{quote}
66 |
67 | \section{商業維護的 \TeX{}/\LaTeX{} 系統}
68 |
69 | 上面所提到的都是 free 的版本,縱使是 \TeX{} Live CD,雖也可以讓非 TUG\index{TUG} 會員訂購,但他們的 iso 是可以自由下載,不一定要花錢買。當然,這裡是鼓勵大家加入會員或花點小錢購買,也算是贊助他們繼續維護好品質的 \TeX{} 系統。另外,亦有商業維護的 \TeX{}/\LaTeX{} 系統,雖然要花錢,但功能上可能會比較符合特別的需要,而且有比較完整的售後服務方案:
70 |
71 | \begin{quote}
72 | \begin{tabular}{lll}
73 | True\TeX & \url{http://www.truetex.com/} & Windows \\
74 | Turbo\TeX & \url{http://www.truetex.com/} & Un*x, DOS, Windows \\
75 | Y\&Y \TeX & \url{http://www.YandY.com/} & Windows \\
76 | pc\TeX & \url{http://www.pctex.com/} & Windows \\
77 | V\TeX & \url{http://www.micropress-inc.com/} & Windows, Linux, OS/2 \\
78 | Scientific Word & \url{http://www.sciword.demon.co.uk} & Windows \\
79 | Textures & \url{http://www.bluesky.com/} & Macintosh \\
80 | Oz\TeX & \url{http://www.trevorrow.com/oztex/} & Mac OS X \\
81 | Scientific Assistant & \url{http://www.advanced-science.com/} & Mac OS X
82 | \end{tabular}
83 | \end{quote}
84 |
85 | \section{選個順手的編輯器}
86 |
87 | \TeX{}/\LaTeX{} 本身並不內附編輯器 \index{編輯器},這和許多排版軟體不一樣,他只專注在排版的過程,原始文稿是如何產生的並不插手干涉,這樣子的自由度很大,每個人都可以選用適合他自己的編輯器,但和目前一般的幕前排版系統比較的話,會讓初接觸的朋友不知所措,因為他不曉得要如何使用 \TeX{}/\LaTeX{} 來「編輯」原始文稿!
88 |
89 | 當然,有些 \TeX{}/\LaTeX{} 的發行版本,乾脆就弄了個編輯器,把編輯器和排版系統本身連接起來,這樣是很方便,但有很大的可能又得花時間學習另一種不熟悉的編輯器操作。本文的說明,不準備被編輯器給綁住,你愛用什麼編輯器就用什麼編輯器,讓我們專心在排版過程本身吧!
90 |
91 | 以下僅簡單介紹和中文相容的編輯器。當然,只要使用順手的編輯器都可以拿來用。原則上,剛開始接觸 \LaTeX{},個人是建議從命令列開始瞭解起,等整個流程有個概念後再來使用一些方便的編輯器上的巨集及按鈕設定,不然,有時編輯器上的設定有問題時,會不知道從何改起。至於編輯器的操作,請自行參考各編輯器的說明文件或網路上的教學文件,這裡就不多談了。
92 |
93 | \subsection{{\sl V}{\it im}}
94 | \index{Vim@{\sl V}{\it im}}
95 | 這有各種平台的版本可以下載:
96 |
97 | \begin{quote}
98 | \url{http://www.vim.org/}
99 | \end{quote}
100 |
101 | 可以配合 vim-latex suite\index{vim-latex suite} 來使用:
102 |
103 | \begin{quote}
104 | \url{http://vim-latex.sourceforge.net/}
105 | \end{quote}
106 |
107 | \subsection{GNU Emacs/XEmacs}
108 | \index{GNU Emacs}\index{XEmacs}
109 |
110 | 這也是有各種平台的版本,也可以配合
111 | AUC\TeX{}footnote{\url{http://www.gnu.org/software/auctex/}}
112 | 來使用,相當方便,這也是 Knuth 教授本身所愛用的編輯器:
113 |
114 | \begin{quote}
115 | \url{http://www.gnu.org/software/emacs/emacs.html} \\
116 | \url{http://www.xemacs.org}
117 | \end{quote}
118 |
119 | \subsection{NEdit}
120 | \index{NEdit}
121 |
122 | 這也可以配合 AUC\TeX{}index{AUCTeX@AUC\TeX} 來使用,但只有 Un*x 系統的版本:
123 |
124 | \begin{quote}
125 | \url{http://nedit.org}
126 | \end{quote}
127 |
128 | \subsection{WinEdt}
129 | \index{WinEdt}
130 |
131 | 這是 shareware,只有 Windows 版本:
132 |
133 | \begin{quote}
134 | \url{http://home.istar.ca/~winedt}
135 | \end{quote}
136 |
137 | \subsection{UltraEdit}
138 | \index{UltraEdit}
139 |
140 | 這也是 shareware,也是只有 Windows 版本。
141 |
142 | \begin{quote}
143 | \url{http://www.ultraedit.com}
144 | \end{quote}
145 |
146 | \subsection{Kile}
147 | \index{kile}
148 |
149 | 這是很方便的 \LaTeX{} 圖形界面整合環境,還可叫出繪圖軟體來繪圖,如果其他作業系統也有安裝 Qt/KDE\index{Qt/KDE} 的話,也是可以編譯安裝使用:
150 |
151 | \begin{quote}
152 | \url{http://kile.sourceforge.net/}
153 | \end{quote}
154 |
155 |
--------------------------------------------------------------------------------
/contents/chapter03.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{\TeX{}/\LaTeX{} 語法概說}
4 | \label{ch:syntax}
5 |
6 | 這一章要談的是,和一般的純文字文稿及其他 markup\index{markup} 式文件系統在語言上的一般差異性。為了讓觀念上能夠更清楚,以下所述主要是要在命令列執行的,致於編輯器上方便的按鍵及巨集,這裡就不多談,一方面是每個人使用的編輯器不一樣,二方面是要先把黑盒子拿掉,整個處理流程才會有概念。
7 |
8 | 當然,由於完全還沒有開始實際寫文稿來測試,所以,這章是紙上談兵,不必動手,用看的就好。但,別急,我們會在第 \ref{ch:start} 章開始實際玩看看,請別忘了,到時要再回頭來複習一下這些資料。
9 |
10 | 而且,前面已經說過,這篇文章主要是著眼於 \LaTeX{} 所附上的巨集,一些其他方便的套件引用,將會在最後或另文再來談。其實,不引用任何外來特殊套件,讓 \LaTeX{} 本身去處理,最起碼也就不會太離譜,要講求美觀、微調,個人是認為先把基礎弄起來再說,有些套件的複雜程度,會令人頭疼,你是不是真有這個需要,值得考慮。而且,很多時候自認為不錯的「微調」,其實常常會不合排版的慣例。\TeX{}/\LaTeX{} 的語法,可以是很簡單明白,也可以是相當的複雜,這是 \TeX{} 系統本身的彈性所導致。
11 |
12 | \section{\LaTeX{} 文稿的處理流程}
13 |
14 | 最簡單的一句話,就是把編輯器\index{編輯器}編輯好的文稿(通常結尾是~{\ttfamily .tex}),利用~{\ttfamily latex}~這個指令去編譯文稿就對了!
15 |
16 | \begin{quote}
17 | \begin{verbatim}
18 | latex your.tex
19 | \end{verbatim}
20 | \end{quote}
21 |
22 | 需要注意的是,如果有索引\index{索引},還要用 {\ttfamily makeindex}\index{makeindex@\texttt{makeindex}} 執行一次,有參考文獻\index{參考文獻},還需要 {\ttfamily bibtex}\index{bibtex@\texttt{bibtex}} 處理一次,最後再使用 {\ttfamily latex} 再處理一至二次,也就是說視文稿的複雜程度,{\ttfamily latex} 可能需要執行好幾次,這在往後碰到時會再提出來。另外,處理中文的話,需要其他前置處理,這裡暫時先以英文文稿來說明,中文的部份,只要加入中文環境及(或)改用能處理中文的前置處理器就可以了。
23 |
24 | 這樣經過 {\ttfamily latex} 處理後,會產生一個 {\ttfamily your.dvi} 檔,然後可以使用 {\ttfamily dvips} 來產生 {\sc PostScript}\index{PostScript@\textsc{PostScript}} 格式的檔案。也可以使用 {\ttfamily dvipdfm[x]}\index{dvipdfmx@\texttt{dvipdfm[x]}} 來產生 PDF 的格式,當然,也可以使用 {\ttfamily ps2pdf}\index{ps2pdf@\texttt{ps2pdf}} 經由 {\sc PostScript} 格式轉換成 PDF 格式。另外,也可由 {\ttfamily pdflatex}\index{pdflatex@\texttt{pdflatex}} 由 {\ttfamily your.tex} 直接編譯成 PDF 格式的輸出。
25 |
26 | \subsection{總結一下處理流程}
27 |
28 | \begin{center}
29 | \includegraphics{latex-flow}
30 | \end{center}
31 |
32 | \section{\LaTeX{} 的特殊專用符號}
33 |
34 | 在 \TeX{}/\LaTeX{} 的世界,原始文稿都是純文字檔,任何一種編輯器都可以打開來編輯、觀看。而排版指令通常是由反斜線(\textbackslash, backslash)\index{反斜線}\index{backslash}所開頭來引導。註解\index{註解}則是由百分號(\texttt{\%})來引導。例如,以編輯器編輯下列文字:
35 |
36 | \begin{quote}
37 | \begin{verbatim}
38 | This is my first \LaTeX{} typesetting example.
39 | \end{verbatim}
40 | \end{quote}
41 |
42 | 編譯後會變成以下的結果:
43 |
44 | \begin{quote}
45 | This is my first \LaTeX{} typesetting example.
46 | \end{quote}
47 |
48 | 其中的 \verb|\LaTeX| 就是 \LaTeX{} 的一個指令,會顯示 \LaTeX{} 這個特殊的圖示。
49 |
50 | 由於,西方國家的語系,通常字母、符號的最大容量只有 256 個($2^8$),因此,許多現有的符號必須拿來當做控制指令,才能符合排版的多樣化需求。以下的符號,接觸 \TeX{}/\LaTeX{} 的朋友,可能都得時時留意,不要未經處理就直接寫進文稿裡頭去了。
51 |
52 | 通常,編輯器的語法顏色\index{語法顏色}會幫助判斷語法是否正確,但不是都能完美無缺,有時還是會漏掉,這時別忘了查看一下 {\ttfamily *.log} 檔案,例如:編譯 {\ttfamily your.tex} 檔的話,他的 log 檔就是 {\ttfamily your.log}。
53 |
54 | \begin{quote}
55 | \begin{tabular}{llll}
56 | 符號 & 作用 & 文稿上使用 & \LaTeX{} 的替代指令 \\
57 | \hline
58 | \textbackslash & 下排版命令 & \verb|$\backslash$| & \verb|\textbackslash| \\
59 | \% & 註解 & \verb|\%| & NA \\
60 | \# & 定義巨集 & \verb|\#| & NA \\
61 | \~{} & 產生一個空白 & \verb|\~{}| & \verb|\textasciitilde| \\
62 | \$ & 進入(離開)數學模式 & \verb|\$| & \verb|\textdollar| \\
63 | \_{} & 數學模式中產生下標字 & \verb|\_{}| & \verb|\textunderscore| \\
64 | \^{} & 數學模式中產生上標字 & \verb|\^{}| & \verb|\textasciicircum| \\
65 | \{ & 標示命令的作用範圍 & \verb|\{| & \verb|\textbraceleft| \\
66 | \} & 標示命令的作用範圍 & \verb|\}| & \verb|\textbraceright| \\
67 | \textless & 數學模式中的小於符號 & \verb|$<$| & \verb|\textless| \\
68 | \textgreater & 數學模式中的大於符號 & \verb|$>$| & \verb|\textgreater| \\
69 | \textbar & OT1 編碼,數學模式中才能正確顯示 & \verb+$|$+ & \verb|\textbar| \\
70 | \& & 表格中的分隔符號 & \verb|\&| & NA
71 | \end{tabular}
72 | \end{quote}
73 |
74 | \section{\LaTeX{} 排版上的一些規範或慣例}
75 | \label{sec:convention}\index{規範}\index{慣例}
76 |
77 | 除了上面所談到的特殊符號外,也有一些規範或慣例要遵守,有些是比較硬性的規定,有些則只是慣例,可能不同的國家、語言會有不同的慣例,暫時先把他當成是 \LaTeX{} 的遊戲規則\index{遊戲規則}就成了。
78 |
79 | \subsection{字型的相關術語}
80 | \label{subsec:baseline}
81 |
82 | 要談排版上的規範、慣例前,我們得先認識一下字型的一些術語,以便往後文章中提到時有個概念。通常我們每個字都是置放於一個假想的方框中,稱為 em-square\index{em-square},同一個字型的同一個點數,每一個 em-square 大小都是相同的,實際上的字(glyph\index{glyph})要置放在這個 em-square 的什麼位置,這是字型設計者的觀點,所以,同樣點數的不同字型,他的字的大小不一定會一樣,因為我們是使用 em-square 的大小在比較的,而非實際的 glyph。
83 |
84 | 在文章中排列的時候,則是將 glyph 置於一個以假想參考點(reference point)\index{假想參考點}\index{reference point}為基準的一個假想線上,稱為基線(baseline\index{基線}\index{baseline}),大寫字母除了 Q 以外,他們的底部都是置於基線上的。但小寫字母則不一定剛好座落在基線上,有些字的筆畫可能超出基線以下,例如 y、j 等字母。關於字型在文章中的置放位置,我們來看看一個模擬圖:\footnote{實際字型設計上的各部份專有名詞及結構,當然不會是這麼簡略,這裡的模擬圖,只是暫時讓字的一般置放有個粗略的概念。}
85 |
86 | % looks ugly, but l2h cannot handle this MP file be transparent png.
87 | \begin{center}
88 | \includegraphics{baseline}
89 | \end{center}
90 |
91 | 這個超出基線以下的長度,我們稱之為深度(depth\index{深度}\index{depth}),以上的就稱為字高(height\index{字高}\index{height}),當然大小寫的不同又分為大寫字母的字高(cap height\index{cap height})及小寫字母 x 的字高(x-height\index{x-height}),由於這個例子裡是調合字\index{調合字},所以每個字的寬度(width\index{寬度}\index{width})不一定會一樣,像打字機字族的則是等寬的字型。字高加上深度,我們就稱之為 totalheight\index{totalheight},大部份的情況,僅僅說 height 時是不包括 depth 的,而且通常指的是 cap height。
92 |
93 | mean line\index{mean line} 在一般比較少用到,通常是字型設計\index{字型設計}時才會用到,他是指小寫字母去除上面突出的部份所連成的一個基準線,這個 mean line 到 baseline 的距離,一般就稱為 x-height,當然就是小寫字母 x 的高度,因此我們會有一個長度單位,稱為 ex,指的就是這個 x-height。
94 |
95 | 中文字的話比較特殊,他是以 em-square 的中心點來置放 glyph 的,在中英文混合時,中文字並不是剛好座落於基線上的,會超出基線下一點點,至於會超出多少,則和字型的設計有關,每種字型都有可能會不同。這也是為求排版上的一致性,字型可能都需要盡量使用同一套的各種字型的原因,否則就得經過微調,才能使整個字型表現上取得協調一致。
96 |
97 | 這些專門術語,往後提到一些指令的參數的描述時都會使用到,因此先熟悉一下,例如:字型旋轉時\index{字型旋轉},跟據的就是以參考點(reference point)為準,沿延伸出的軸心來旋轉的,而一般所說的行距\index{行距},指的是上下兩 baseline 的距離。
98 |
99 | \subsection{一般性的遊戲規則}
100 | \label{gen:gamerules}\index{遊戲規則}
101 |
102 | \begin{enumerate}
103 |
104 | \item \LaTeX{} 的指令都是大小寫有別的,由 \verb|\| 開頭,後接由字母組成的字串或單一的非字母字元。其中由 \verb|[ ]| 中括號括住的是選擇性參數\index{選擇性參數},可以省略,由 \verb|{ }| 大括號括住的是不能省略的參數,當然,\LaTeX{} 的指令不一定會有參數,但絕大部份都會有參數,只不過把他給省略使用預設值罷了。
105 |
106 | \item \LaTeX{} 文稿中,空一個英文空白和空多個英文空白的作用是一樣,\LaTeX{} 會認作一個英文空白。
107 |
108 | \item 平常我們編輯純文字檔,按個 \textsf{Enter} 鍵,就代表換行,但實際排版出來,一行的寬度是按照排版版面的設定,也就是說,你在文稿中按 \textsf{Enter},不代表排版後就是從這裡斷行\index{斷行},\LaTeX{} 會依一行應有的寬度經過整體計算後自動補成一整行後再來斷行,而且會在中間自動補足一個空白。這在英文很自然,稱為字(word)間空白\index{字間空白},但中文則不一樣,在編輯器中編輯中文,隨意按 \textsf{Enter} 的結果,會造成文章中的中文間出現空白。這會在本文中適當的時機,提出解決的方法。
109 |
110 | \item 編輯器中,多按幾次 \textsf{Enter} 就多空出幾行,但在 \LaTeX{} 文稿裡,多個空白行\index{空白行},和一個空白行是一樣的作用,\LaTeX{} 會把他認作是一個空白行。而這個空白行,\LaTeX{} 同時也會認作是新段落的開始,所以 \LaTeX{} 是以空白行來分隔各個段落。
111 |
112 | \item \LaTeX{} 預設每個章節的第一個段落的第一行是不內縮(noindent\index{不內縮}\index{noindent}),從第二個段落開始才會內縮(indent\index{內縮}\index{indent})。當然,這是可以更改的,往後會再提及。
113 |
114 | \item \LaTeX{} 的指令,是從反斜線\index{反斜線}後第一個字母開始,到第一個非字母符號為止(包括空白、標點符號及數字)。因此:
115 |
116 | \begin{quote}
117 | \begin{verbatim}
118 | This is my first \LaTeX typesetting example.
119 | \end{verbatim}
120 | \end{quote}
121 |
122 | 這樣的話,實際結果,因為 \verb|\LaTeX| 後的空白是屬於指令的一部份,空白將不會被解釋,這樣會印成:
123 |
124 | \begin{quote}
125 | This is my first \LaTeX typesetting example.
126 | \end{quote}
127 |
128 | 這種結果,\LaTeX{} 和 typesetting 連在一起了。要避免的話,就要指定指令的作用範圍,例如以下的大括號。或就真的加個空白,例如 \verb|\ |,\LaTeX{} 碰到 \verb|\| 就會形成完整的指令,其後的空白就會被真正解釋為空白了:
129 |
130 | \begin{quote}
131 | \begin{verbatim}
132 | This is my first {\LaTeX} typesetting example.
133 | This is my first \LaTeX{} typesetting example.
134 | This is my first \LaTeX{} typesetting example.
135 | \end{verbatim}
136 | \end{quote}
137 |
138 | 所以,正常印出來應該是:
139 |
140 | \begin{quote}
141 | This is my first \LaTeX{} typesetting example.
142 | \end{quote}
143 |
144 | % \index{\%@\verb=%=}
145 | \item 註解符號({\ttfamily \%})\index{註解符號}\index{%@\verb=%=},可以放在一行的任何地方,{\ttfamily \%} 後的文字會被 \LaTeX{} 忽略。所以,如果是放在一行的最尾端,那麼 \LaTeX{} 會自動插入的字間空白也將會被忽略。例如:
146 |
147 | \begin{quote}
148 | \begin{verbatim}
149 | This is my fisrt \LaTeX{} document. Give \LaTeX{} a%
150 | try.
151 | \end{verbatim}
152 | \end{quote}
153 |
154 | 這樣一來,排版出來會變成:
155 |
156 | \begin{quote}
157 | This is my fisrt \LaTeX{} document. Give \LaTeX{} a%
158 | try.
159 | \end{quote}
160 |
161 | a 和 try 連在一起了!正常應該是:
162 |
163 | \begin{quote}
164 | This is my fisrt \LaTeX{} document. Give \LaTeX{} a try.
165 | \end{quote}
166 |
167 | 基於這個特性,我們可以應用在中文,也就是說在編輯器\index{編輯器}中,中文文章按 \textsf{Enter} 鍵換行時,尾端加個 {\ttfamily \%},這樣一來 \LaTeX{} 就不會插入英文字間空白,中文字就可以連成中間沒有空白的一整行了,否則 \LaTeX{} 在整篇文稿斷句\index{斷句}時,會自動在原換行處填入一個英文空白,因為,原始的 \TeX{}/\LaTeX{} 是認不得中文的。
168 |
169 | \item 中英文混合的時候,通常,英文字前後都會留個空白,以便和中文區隔開來,只是這個空白要多大,這就沒有固定的慣例,通常留個英文空白也是可以,要講究的話,等談到中文排版相關議題時再來討論,目前就養成習慣,英文單字前後留個英文空白。
170 |
171 | \end{enumerate}
172 |
173 | \subsection{針對標點符號的遊戲規則}
174 |
175 | \begin{enumerate}
176 |
177 | \item 中英文的引號\index{引號}不一樣,這裡請特別注意,許多人常常搞錯。中、英文引號不管單雙都要分左右。英文的話,左邊的引號是 grave accent,是鍵盤左上方 {\sffamily Esc} 或 {\sffamily F1} 下方有波形號的那一個鍵;右邊的是 apostrophe\index{apostrophe},也就是鍵盤左邊 {\sffamily Enter} 鍵隔壁的那個鍵。雙引號的情形是鍵入兩次的左單引號\index{左單引號}及兩次的右單引號\index{右單引號},而不是用 \verb|"| 這個一次完成兩個點的 ditto marks\index{ditto marks}。所以,實際上在鍵入文稿時是:
178 |
179 | \begin{quote}
180 | \begin{verbatim}
181 | Please press an `Esc' key.
182 | Please press an 'Esc' key. 這是錯誤示範!
183 | ``This sentence.''
184 | "This sentence." 這是錯誤示範!
185 | \end{verbatim}
186 | \end{quote}
187 |
188 | 排版出來的情形是:
189 |
190 | \begin{quote}
191 | Please press an `Esc' key.\\
192 | Please press an 'Esc' key. 這是錯誤示範!\\
193 | ``This sentence.''\\
194 | "This sentence." 這是錯誤示範!
195 | \end{quote}
196 |
197 | 中文的話,我們是使用中文全形的「、」及『、』,在中國大陸則已改用和英文相同形狀的全形符號,但這在中文直排時會出問題,因此,中文的單、雙引號還是得維持我們目前使用的。
198 |
199 | \item \LaTeX{} 會在英文文章的一個句子結束和另一個句子開始的中間,自動調整成較大一點的空白,這可以增加文章的易讀性。所謂一個句子結束,例如:句點(.)、問號(?)、驚嘆號(!)及冒號(:),這當然是指英文的半形標點符號,不是中文的全形標點符號。你可以注意一下上面所舉的例子,在 document.\ 和 Give 之間的空白會稍微大於其他英文單字間的空白。
200 |
201 | 現在的問題是,如果這些標點符號後面不是另一個句子的開始的時候,\LaTeX{} 無法去判斷這種情形,這時得由我們自己自行判斷、處理了。例如英文縮寫字:
202 |
203 | \begin{quote}
204 | \begin{verbatim}
205 | I am Mr. Edward G.J. Lee, G.J. is a abbreviation of my name.
206 | I am Mr.~Edward G.J. Lee, G.J. is a abbreviation of my name.
207 | I am Mr.\ Edward G.J. Lee, G.J. is a abbreviation of my name.
208 | \end{verbatim}
209 | \end{quote}
210 |
211 | 其中 \verb|Mr.\ Edward| 的寫法,和 \verb|Mr.~Edward| 幾乎是一樣的,都是強迫插入一個比較小的正常單字間空白\index{單字間空白},差別在於後者也另外表示不可以從這裡換行,通常用在人名的時候,讓他們不致中斷,一般在人名的排版,包括他的頭銜、職稱,是不中斷成兩行而分開的。而且整個文句較長的話,以後者較恰當,才不會因為斷行被分成兩半,這個 {\ttfamily ~} 符號也因此在 \TeX{} 的專有名詞,就稱為 tie\index{tie},把他們綁住的意思。排版出來的時候會變成:
212 |
213 | \begin{quote}
214 | I am Mr. Edward G.J. Lee, G.J. is an abbreviation of my name.\\
215 | I am Mr.\ Edward G.J. Lee, G.J. is an abbreviation of my name.
216 | \end{quote}
217 |
218 | 請放大去仔細比較一下結果就知道了。第二行的才是正確的,Mr.\ 和 Edward 之間的空白是正常單字間空白,比第一行的句子結束空白要小一點點。其他有使用到縮寫字的場合,例如:`Dr.'、`etc.'、`e.g.'、`i.e.'、`vs.'、`Fig.'、`cf.'、`Mrs.',這些都不是代表句子結束,所以,要插入一個正常空白。
219 |
220 | 那 G.J. 後面為什麼沒有插入正常空白?那是因為,J 是大寫的,這時 \LaTeX{} 不會去誤認為是句子結束,通常句子結束時的句點前的那個字母是小寫的。Well,有沒有覺得有點道理?:-)
221 |
222 | 等等,事情還沒有結束!Knuth 教授出了一道考題,如果句子的結束是 `Please see Appendix A.' 後面又還接有另一個句子。這時怎麼辦?由於,不會認為是句子結束,因此會插入正常空白,但這正是句子結束呀!請暫時先記得,使用 \verb|...Appendix A\null.|,或 \verb|...Appendix A\@.|。這個說來有點話長,有機會再來探討,請記得 `\verb|\null|' 和句點間是沒有空白的。例如:
223 |
224 | \begin{quote}
225 | \begin{verbatim}
226 | Please see Appendix A. We will be there soon.
227 | Please see Appendix A\null. We will be there soon.
228 | \end{verbatim}
229 | \end{quote}
230 |
231 | 排版出來的結果將會是(差異不明顯,請小心比較):
232 |
233 | \begin{quote}
234 | Please see Appendix A. We will be there soon.\\
235 | Please see Appendix A\null. We will be there soon.
236 | \end{quote}
237 |
238 | 如果,你現在閱讀的是 HTML\index{HTML} 格式文件,有些例子如果無法明顯顯示出來,請改閱覽 PDF 版本。而且,如果你製作 PDF 格式時,字型沒有內嵌(本文的英數字是嵌入 Computer Modern Type1 字型),差異可能將會更不明顯。可試著使用 {\sffamily gv/gsview}\index{gv@\textsf{gs}}\index{gview@\textsf{gview}} 去閱覽,然後調整成 Landscape\index{Landscape},把句子尾部拉到邊緣的地方去就看得出來了。這在句子多的時候,這個空白也並非固定大小的,\LaTeX{} 會視文章結構的需要做細微的調整。
239 |
240 | \item 刪節號\index{刪節號}中文英也是不同,英文是三點,如果碰到句點的話,則是四點。中文的話是六點,碰到中文句點很容易就分得清楚。但是英文這個三點,不是就打個三個句點了事,這樣的點太密集,可以使用 \verb|\ldots| 或 \verb|\dots| 指令,例如:
241 |
242 | \begin{quote}
243 | \begin{verbatim}
244 | I'm not a good man ..., but a good husband .... 錯誤示範!
245 | I'm not a good \ldots\ man \ldots, but a good husband \ldots.
246 | I'm not a good \dots\ man \dots, but a good husband \dots.
247 | \end{verbatim}
248 | \end{quote}
249 |
250 | 排版出的來結果是:
251 |
252 | \begin{quote}
253 | I'm not a good ... man ..., but a good husband .... 錯誤示範!\\
254 | I'm not a good \ldots\ man \ldots, but a good husband \ldots.\\
255 | I'm not a good \dots\ man \dots, but a good husband \ldots.
256 | \end{quote}
257 |
258 | 中文的刪節號是由兩個全形的三點所組成六點的,即:\chdots{},就是我們 Big-5 碼的 {\ttfamily 0xa14b}({\ttfamily U+2026}),但由於 Unicode\index{Unicode} 尚有一個 MIDLINE HORIZONTAL ELLIPSIS({\ttfamily U+22EF}),因此,有些軟體在解讀上有可能會不一樣,因為我們的字型,大部分在製作標點符號時是置在中央的地方,不像中國大陸是置放在基線的地方,而 Unicode 官方採用的樣本字型,剛好是中國大陸的廠商所提供,這樣一來有些軟體工作者就認為我們的刪節號應該是 {\ttfamily U+22EF} 了,很不幸的,我們的 Big-5\index{Big-5} 碼並沒有相對應的字碼。
259 |
260 | \item 破折號\index{破折號}。在英文,相當於破折號的可能有三種:
261 | \begin{itemize}
262 | \item hyphen\index{hyphen} \newline
263 | 這是最短的 dash\index{dash},通常就是鍵入 \verb|-| 就行了,例如 \verb|father-in-low|,這樣會表現成 fater-in-low。
264 |
265 | \item en-dash\index{en-dash} \newline
266 | 這是最常用的破折號,是鍵入兩個 hyphen。例如 \verb|1991--2003 年|,這會表現成 1991--2003 年。
267 |
268 | \item em-dash\index{em-dash} \newline
269 | 這是最長的 dash,由三個連續的 hyphen 組成,應該是最相近於我們中文所說的破折號。例如 \verb|I am---a good man.| 會表現成 I am---a good man.。至於這個三個連續的 hyphen 前後是否要留空白,都有人使用,並沒有硬性的慣例,但為了和中文的破折號配合(中文破折號前後,通常不留空白),個人通常是不留空白的。
270 |
271 | \item 真正的減號 \newline
272 | 這應不能算是破折號,而是實際的減號或負號,這要進入數學模式,例如:負五,要寫成 \verb|$-5$|,然後表現出來是 $-5$。這也常常會有人搞錯,不能直接鍵入一般的負號那個鍵來充數,這是因為 \TeX{}/\LaTeX{} 的數學式子的用字和間隔處理,和一般內文不同的關係。
273 |
274 | \item 中文的破折號 \newline
275 | 中文的破折號是佔兩個中文字位置的的一橫線,長度和刪節號相同。在中線位置的,定義上是有兩種,en-dash 是 {\ttfamily Big-5 0xa156},em-dash 是 {\ttfamily Big-5 0xa158}。但由於中文字間距的問題,有可能打出來的破折號中間會有一點空白\footnote{這是可以調整的,也就是去除兩個橫線之間的字間距,這樣就不會產生小空白了,中文刪節號也有同樣的情形,我們會在微調的部份再來討論。},例如——中文的 em-dash,這是––中文的 en-dash。在論文中,破折號通常可以使用小括號或冒號代替。
276 |
277 | \item 中文的私名號及書名號 \newline
278 | 中文的私名號\index{私名號},可以標明人名、地名,如\underline{孫逸仙};書名號\index{書名號}(私名號的底線換成波紋形狀),可以用在書名,這些符號常造成排版上的困擾,常使用 《 》來取代書名號,私名號則無其他取代方法。在一般的自然及應用科學論文上通常不使用這種舊式的私名號及書名號。
279 | \end{itemize}
280 |
281 | \item 避頭點\index{避頭點} \newline
282 | 這可是排版的重要功能。英文的通常沒有問題,\LaTeX{} 會自動避開處理,中文就不一定了,\LaTeX{} 可不認識中文,但通常中文相關程式及套件,多多少少都會處理,只不過,有時候偶爾可能會誤判。那麼,到底什麼是避頭點?底下列個表,大家就明白了,我列中文的,英文的就不列出來了,因為 \LaTeX{} 會自動處理,不必我們擔心。
283 |
284 | \begin{quote}
285 | \begin{tabular}{ll}
286 | 標點符號 & 置放處 \\
287 | \hline
288 | ,。;、:」)》!? & 不能置於行首 \\
289 | 「(《 & 不能置於行尾 \\
290 | 破折號及刪節號 & 置於首尾皆可 \\
291 | \end{tabular}
292 | \end{quote}
293 |
294 | 簡單的說,除了破折號及刪節號,沒有開口的,不能置於最開頭,開口向右的,不能置於最右,開口向左的,不能置於最左。通常都會處理好,但校稿的時候要注意一下誤判的地方。
295 |
296 | \end{enumerate}
297 |
298 | \section{\LaTeX{} 的文稿結構}
299 | \label{sec:struct}\index{文稿結構}
300 |
301 | \subsection{環境(environment)\index{環境}\index{environment}}
302 |
303 | 上一節所談的都是指令,雖然也可以由大括號\index{大括號}來定作用範圍,但如果是一整段,甚至是一整篇文章都要作用時,那指令可能就不很適合了,因此,\LaTeX{} 也有一種巨集結構,稱為環境(environment),主要是讓作用範圍能擴大至較大的範圍。
304 |
305 | 所有的環境,都是起於 \verb|\begin{環境名稱}|,止於 \verb|\end{環境名稱}|,這兩個指令之間的文稿都會被作用,而且,環境之內還可以套用其他不同的環境。
306 |
307 | \LaTeX{} 文稿的內文,其實就是包在一個 \verb|\begin{document}| 和 \verb|\end{document}| 這個 document 環境當中。
308 |
309 | \subsection{最簡單的 \LaTeX{} 的文稿結構}
310 |
311 | 以下就是所有 \LaTeX{} 必需具備的文稿大結構:
312 |
313 | \begin{quote}
314 | \begin{verbatim}
315 | \documentclass{article}
316 |
317 | 這裡是 preamble 區
318 |
319 | \begin{document}
320 |
321 | 這裡是本文區
322 |
323 | \end{document}
324 | \end{verbatim}
325 | \end{quote}
326 |
327 | \verb|\documentclass{article}|,這是在告訴 \LaTeX{} 使用哪一種類別,我們目前使用的是 {\ttfamily article} 類別\index{類別}\index{article},關於類別會在第 \ref{ch:class} 章討論。preamble\index{preamble} 區,則是下一些會影響整個文稿的指令,及引用巨集套件的地方,當然,完全不引用巨集,也不使用影響全文的指令的話,preamble 區就是空白,不寫任何東西。本文區,就是我們實際上寫文章的地方。
328 |
329 | 現在也可以把前面所舉的例子,放入本文區裡頭,preamble 區空白沒關係,然後存檔,試著編譯看看:
330 |
331 | \begin{quote}
332 | \begin{verbatim}
333 | latex example.tex
334 | dvips example.dvi => 產生 ps 格式 example.ps
335 | dvipdfm[x] example.dvi => 產生 pdf 格式
336 | pdflatex example.tex => 直接由 .tex 產生 .pdf
337 | \end{verbatim}
338 | \end{quote}
339 |
340 | 真正的實例解說,會在下一章來進行,所以,這裡暫時不會介紹有什麼環境可以使用,先玩看看沒有關係。由於還沒談到中文的問題,因此如果你想試試看,那暫時先使用英文,道理都是相通的。
341 |
342 | \subsection{preamble 區可以放些什麼?}
343 | \label{subsec:preamble}
344 |
345 | 這裡可以引用巨集,而且會影響整篇文稿的指令,例如一些事先定義好的指令,想在整篇文稿中使用,就可以置放在 preamble 區。
346 |
347 | \subsubsection{巨集的引用}
348 | \label{subsubsec:package}
349 |
350 | 本文主要是標準 \LaTeX{},但前面已提到,會有些巨集套件不得不要引用,底下就來說明如格引用套件。這些套件都是一般 \TeX{} 系統都會附上的。
351 |
352 | 指令及環境要如何開頭都介紹過了,現在來看看引用巨集要怎麼開頭。
353 |
354 | \begin{quote}
355 | \begin{verbatim}
356 | \documentclass{article}
357 | \usepackage{color}
358 | \begin{document}
359 | \textcolor{blue}{This is blue color.}
360 | \end{document}
361 | \end{verbatim}
362 | \end{quote}
363 |
364 | 編譯一下,看看結果是什麼?這裡使用的就是 \textsf{color} package\index{color@\textsf{color}},裡頭是由 \TeX{}/\LaTeX{} macro 所寫成一個巨集套件。一般簡單的我們就稱為巨集(macro)\index{巨集}\index{macro},複雜一點的就稱為巨集套件(package)\index{巨集套件}\index{package},其實,裡頭都是一樣的,只不過大小及有沒有整理成一個系統的差別。
365 |
366 | \LaTeX{} 裡頭有什麼現成的套件可以使用,每個散佈的 \TeX{} 系統所收集的可能都會有所不同。大概沒有人可以精通所有現存的 \LaTeX{} 巨集套件,因為實在是太多了,不過,本文大概都會提到常用的巨集套件。詳細的巨集套件的種種,會在第 \ref{ch:package} 章來說明。
367 |
368 | \subsubsection{影響整篇文稿的指令}
369 |
370 | 會影響整篇文稿的指令,通常也是放在 preamble 區,例如:
371 |
372 | \begin{quote}
373 | \begin{verbatim}
374 | \linespread{1.36}
375 | \parindent=0pt
376 | \end{verbatim}
377 | \end{quote}
378 |
379 | \verb|\linespread| 是在控制上下行的行距,這裡就是將行距變成原來的 1.36 倍。至於什麼是行距呢?就是這一行的基線(baseline)到下一行的基線的距離,通常英文文章不必去調整他的行距,但中文得適當加大行距以利閱讀。
380 |
381 | \verb|\parindent| 是調整段落內縮的程度,這裡調整成 0,也就是說各段落都不內縮的意思,也可以調整成其他的值,\LaTeX{} 就會依這個值去內縮。當然,不去設定的話,\LaTeX{} 就會依他的預設值去內縮。
382 |
383 | \subsection{章節結構\index{章節結構}}
384 | \label{subsec:chapstruc}
385 |
386 | 本文區當然是我們寫文章的主要地方,及一些微調\index{微調}。在 \LaTeX{} 的文稿裡頭,章節標題的形成都是由同樣的指令來控制的,這樣有一個好處,臨時插入章節標題及其內文時,我們不必去理會標題編號及目錄的問題,也不必去理會要用什麼字型、及字型大小要多大,\LaTeX{} 會自動計算處理,字型大小也會和內文使用的字型大小互相配合調整,使用者就專心在內文構思、寫作即可。以下由列表來瞭解整個章節結構:
387 |
388 | \begin{quote}
389 | \begin{tabular}{lll}
390 | 深度標號 & 指令 & 作用及注意事項 \\
391 | \hline
392 | $-1$ & \verb|\part{}| & 這是最大的結構,我們中文通常稱為「部」。 \\
393 | 0 & \verb|\chapter{}| & 章。在 article 類別裡頭沒有章。 \\
394 | 1 & \verb|\section{}| & 節。 \\
395 | 2 & \verb|\subsection{}| & 小節。 \\
396 | 3 & \verb|\subsubsection{}| & 次小節。 \\
397 | 4 & \verb|\paragraph{}| & 段落。 \\
398 | 5 & \verb|\subparagraph{}| & 小段落。 \\
399 | \end{tabular}
400 | \end{quote}
401 |
402 | 章節標題\index{章節標題}的內容就是直接寫入指令的大括號裡頭就可以了,\LaTeX{} 在排版時會自動使用粗體、加入章節編號\index{章節編號}及納入目錄\index{目錄}裡頭。
403 |
404 | 至於第一欄的深度標號(secnumdepth)\index{深度標號}\index{secnumdepth},{\ttfamily book/report}\index{book@\texttt{book}}\index{report@\texttt{report}} 類別的深度標號是 2,{\ttfamily article} 的是 3。這是什麼意思呢?就是說 {\ttfamily book/report} 類別的文稿,在 \verb|\subsection{}| 以後({\ttfamily subsection} 本身仍會編號),章節就不再編號了;同樣的,在 {\ttfamily article} 類別的文稿,在 \verb|\subsubsection{}| 以後就不編號了。但仍然會獨立出一單獨行來表示這個是標題。不編號了的章節內容,當然也就不納入目錄裡頭了。這當然是可以更改的,只要更改 \LaTeX{} 的 {\ttfamily secnumdepth} 這個變數的值就可以了,這個往後會提及如何更改 \LaTeX{} 的預設值。像這篇文章,在 preamble 區就有一個設定:
405 |
406 | \begin{quote}
407 | \begin{verbatim}
408 | % let the depth of report to subsubsection
409 | \setcounter{secnumdepth}{3}
410 | \end{verbatim}
411 | \end{quote}
412 |
413 | 所以,這篇文章雖然使用的是 {\ttfamily report} 類別,但是章節的深度標號是標在 3,也就是說會編號到 {\ttfamily subsubsection} 為止,但這仍然是沒有編入目錄中的。
414 |
415 | 下一章就讓我們開始實際動手吧!但 \chdots{},怎麼到現在都沒有完整介紹指令呢?那我怎麼會知道有什麼指令可以使用?這是因為 \LaTeX{} 的指令很多,直接介紹的話,一方面記不住,二方面也不容易瞭解他的實際作用,所以,我們將會在下章舉例時穿插在裡頭說明,等這份文件接近尾聲時,再來整理個指令速查表,這樣以後查指令就很方便了,不必去死記,只要知道有個這樣功能的指令就夠了。
416 |
417 |
--------------------------------------------------------------------------------
/contents/chapter04.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{實際上排版玩看看}
4 | \label{ch:start}
5 |
6 | 好了,現在正式來玩看看吧!本章主要是簡單的實例說明,先進入狀況再談其他。實際應用比高談闊論有用多了。
7 |
8 | 先來個「最高指導原則」:\textcolor{red}{\bfseries 學會控制空間,你就學會排版了}!剛學排版的朋友,往往會把所學到的東西去想法子佈滿你所有的空間(就是一個頁面),但實際上,你要調整的,其實是各個部份的空間配置,抽象一點說,也就是一整個頁面當中,沒有文字、圖表的部份才是排版真正的重點。你先聽聽就好,過一段時間的熟悉後,再來回頭思考這個「玩弄」空間的原則。:-)
9 |
10 | 由於本文有 HTML 版本,為了轉換上不造成失真,實例的部份,文稿上只寫程式碼,結果的部份都是編譯好的 PDF 格式檔案,置放於網站上,可線上閱覽或下載,簡單的例子則不另製作獨立的 PDF 檔,請參閱本文的 PDF 格式檔案內容。
11 |
12 | \section{簡單的實例}
13 |
14 | 這裡就把前一章所談到的一些內容整理成一個文稿,先來試試看,這裡先使用 {\ttfamily report}\index{report@\texttt{report}} 類別文稿,因為 {\ttfamily article}\index{article@\texttt{article}} 類別文稿是沒有 {\ttfamily chapter} 的:
15 |
16 | \begin{quote}
17 | \begin{verbatim}
18 | % example1.tex
19 | \documentclass{report}
20 | \begin{document}
21 | This is my first {\LaTeX} typesetting example.\\
22 | This is my first \LaTeX{} typesetting example.\\
23 | This is my first \LaTeX{} typesetting example.\\
24 | I am Mr. Edward G.J. Lee, G.J. is a abbreviation of my name.\\
25 | I am Mr.\ Edward G.J. Lee, G.J. is a abbreviation of my name.\\
26 | Please see Appendix A. We will be there soon.\\
27 | Please see Appendix A\null. We will be there soon.
28 | \end{document}
29 | \end{verbatim}
30 | \end{quote}
31 |
32 | 使用編輯器編輯,然後存檔成 {\ttfamily exmaple1.tex},這樣就可以編譯了:
33 |
34 | \begin{quote}
35 | \begin{verbatim}
36 | latex example1.tex => 產生 example1.dvi
37 | dvips -Ppdf example1.dvi => 產生 example1.ps
38 | ps2pdf example1.ps => 產生 example1.pdf 或
39 | dvipdfm[x] example1.dvi => 由 example1.dvi 直接產生 example1.pdf 或
40 | pdflatex example1.tex => 由 example1.tex 直接產生 example1.pdf
41 | \end{verbatim}
42 | \end{quote}
43 |
44 | 編譯好的 PDF 檔可在此下載或閱覽:
45 |
46 | \begin{quote}
47 | \url{http://edt1023.sayya.org/tex/latex123/example1.tex} \\
48 | \url{http://edt1023.sayya.org/tex/latex123/example1.pdf}
49 | \end{quote}
50 |
51 | \subsection{關於換行}
52 |
53 | 每行最後加了個 \verb|\\|\index{\\@\verb=\\=},這表示強迫換行的意思,否則 \LaTeX{} 會依版面預設的寬度來換行,就不會是一個句子一行了,大家可以把這個 \verb|\\| 拿掉,再來編譯試看看結果,就會知道怎麼一回事了。也可以使用 \verb|\newline|\index{newline@\verb=\newline=} 這個指令,當然,我們都會聰明的選用較短的指令。而且 \verb|\\| 可以控制換行時的間隔,這在 \verb|\newline| 則不行。例如:
54 |
55 | \begin{quote}
56 | \begin{verbatim}
57 | Please see Appendix A. We will be there soon.\\[1cm]
58 | Please see Appendix A\null. We will be there soon.
59 | \end{verbatim}
60 | \end{quote}
61 |
62 | 這樣的話,兩行之間的行距\index{行距}就是原來的行距再加上 {\ttfamily 1cm}。甚至,也可以是負數的參數,這樣行距就會變成原來的行距減去 {\ttfamily 1cm},當然,如果設過頭了的話,兩行可能會重疊在一起。既然,這裡使用的是方括號,表示這些參數是可以省略的。
63 |
64 | 另外,\verb|\linebreak[n]|\index{linebreak@\verb+\linebreak+} 也可以強迫換行\index{強迫換行},{\ttfamily n} 代表由 1--4 的建議值,數值愈大表示愈是強烈建議,不設定的話,就是換或不換兩種選擇,沒有中間地帶。和前面所說的不同處是,這種換行會把原來那一行句子的長度平均布滿版面上行寬的長度。例如:
65 |
66 | \begin{quote}
67 | \begin{verbatim}
68 | Please see Appendix A. We will be there soon.\linebreak
69 | Please see Appendix A\null. We will be there soon.
70 | \end{verbatim}
71 | \end{quote}
72 |
73 | 排版後會表現成:
74 |
75 | \begin{quote}
76 | Please see Appendix A. We will be there soon.\linebreak
77 | Please see Appendix A\null. We will be there soon.
78 | \end{quote}
79 |
80 | \subsection{關於縮排\index{縮排}}
81 |
82 | 第一行縮排了!這是因為我們完全沒有分章節,所以,\LaTeX{} 就把這些內容當做是引言的部份,依 \LaTeX{} 的安排,引言開頭是會縮排的。要解決這個問題,可有兩種方法:
83 |
84 | \begin{enumerate}
85 | \item 在第一行之前加入 \verb|\noindent|\index{noindent@\verb+\noindent+} 來指示 \LaTeX{} 不要去縮排。但是這只作用在下指令的地方,其他該縮排的地方還是會縮排。
86 | \item 在 preamble 區加入 \verb|\parindent=0pt|\index{parindent@\verb+\parindent+},這表示讓全文的縮排為 {\ttfamily 0pt},當然,這就表示全文都不要縮排了。
87 | \end{enumerate}
88 |
89 | \section{加入章節標題\index{章節標題}}
90 |
91 | 在 \LaTeX{} 裡頭,要加入章節標題實在是太容易了,也不必去管字體的大小及置放的位置,盡管加上去就對了!\LaTeX{} 會替我們安排一切。我們這裡仍然以 {\ttfamily report} 類別來說明,因為 {\ttfamily article} 類別裡頭,沒有章,只能適用於較簡單的短文。
92 |
93 | \begin{quote}
94 | \begin{verbatim}
95 | % example2.tex
96 | \documentclass{report}
97 | \begin{document}
98 | This is the first experience of \LaTeX.
99 | \chapter{Aesop Fables}
100 | \section{The Ant and the Dove}
101 | An ant went to the bank of a river to quench its thirst, and
102 | being carried away by the rush of the stream, was on the
103 | point of drowning.
104 | A Dove sitting on a tree overhanging the water plucked a
105 | leaf and let it fall into the stream close to her. The Ant
106 | climbed onto it and floated in safety to the bank.
107 | \section{The Dog in the Manger}
108 | A dog lay in a manger, and by his growling and snapping
109 | prevented the oxen from eating the hay which had been
110 | placed for them.
111 | ``What a selfish Dog!'' said one of them to his companions;
112 | ``he cannot eat the hay himself, and yet refuses to allow
113 | those to eat who can.''
114 | \chapter{The Eagle and the Arrow}
115 | An eagle sat on a lofty rock, watching the movements of a
116 | Hare whom he sought to make his prey.
117 | An archer, who saw the Eagle from a place of concealment,
118 | took an accurate aim and wounded him mortally.
119 | \end{document}
120 | \end{verbatim}
121 | \end{quote}
122 |
123 | 編譯出來的結果:
124 |
125 | \begin{quote}
126 | \url{http://edt1023.sayya.org/tex/latex123/example2.tex}\\
127 | \url{http://edt1023.sayya.org/tex/latex123/example2.pdf}
128 | \end{quote}
129 |
130 | 請注意他什麼時候會縮排,什麼時候會換頁。{\ttfamily report} 類別,新的一章會換頁,如果想節省一點空間,可以換用 {\ttfamily article} 類別,\verb|\chapter{}| 改用 \verb|\section{}|,原來 \verb|\section{}| 就改用 \verb|\subsection{}|,這樣就不會換頁,內容就會連續下去了。大家可以試著把 {\ttfamily report} 改成 {\ttfamily article} 及 {\ttfamily book} 再重新編譯一次,試試看結果有何不同。
131 |
132 | \section{加入 title page 資訊}
133 | \label{sec:titlepage}\index{title page}
134 |
135 | 這是指內頁的第一頁,我也不知道這個中文專有名詞是什麼,在 \LaTeX{} 裡頭,我們就稱為 title page。在 \LaTeX{} 的標準格式裡,他包括了標題(title)、作者名字(author)、日期(date\index{date})及感謝詞(thanks\index{thanks})。要注意的是,在 {\ttfamily report/book} 類別,title page 是自成一單獨頁的,但在 {\ttfamily article} 類別裡,他是和本文連起來的。我們就以上面的伊索寓言的文章為例,要修改的地方是 preamble\index{preamble} 區及本文區的 \verb|\maketitle|\index{\verb=\maketitle=}:
136 |
137 | \begin{quote}
138 | \begin{verbatim}
139 | % example3.tex
140 | \documentclass{report}
141 | \title{Aesop Fables}
142 | \author{Aesop\thanks{Thanks to the reader.}
143 | \and Nobody\thanks{Thanks to nobody.}}
144 | \date{\today}
145 | \begin{document}
146 | \maketitle
147 | This is the first experience of \LaTeX.
148 | \chapter{Aesop Fables}
149 | \section{The Ant and the Dove}
150 | ...
151 | \end{verbatim}
152 | \end{quote}
153 |
154 | 排版出來的結果如下:
155 |
156 | \begin{quote}
157 | \url{http://edt1023.sayya.org/tex/latex123/example3.tex}\\
158 | \url{http://edt1023.sayya.org/tex/latex123/example3.pdf}
159 | \end{quote}
160 |
161 | 我們可以發現,這一頁是不編頁碼的,從下一頁開始才是第一頁。作者可以有多個,使用 \verb|\and| 指令來連接。日期不一定要有,如果沒有 \verb|\date{\today}| 這個指令,那還是有日期,但只能固定在今天。如果內容過長,他會自動折行,但也可以手動加 \verb|\\| 來強迫換行,不管如何換行,整個句子是居中排列的。\verb|\maketitle| 是下在本文區的開頭,如果不下這個指令,那編譯時不會有什麼錯誤,只是就沒有 title page 了。
162 |
163 | \section{加入目錄(Table of Contents)}
164 | \label{sec;toc}
165 |
166 | 加入目錄(Table of Contents\index{Table of Contents})對 \LaTeX{} 而言,更是輕而易舉的事情,只要在本文開頭加個
167 | \verb=\tableofcontents=\index{tableofcontents@\verb=\tableofcontents=}
168 | 指令就成了!依上面的例子,修改成:
169 |
170 | \begin{quote}
171 | \begin{verbatim}
172 | % example4.tex
173 | \documentclass{report}
174 | \title{Aesop Fables}
175 | \author{Aesop\thanks{Thanks to the reader.}
176 | \and Nobody\thanks{Thanks to nobody}}
177 | \date{\today}
178 | \begin{document}
179 | \maketitle
180 | \tableofcontents
181 | This is the first experience of \LaTeX.
182 | \chapter{Aesop Fables}
183 | \section{The Ant and the Dove}
184 | ...
185 | \end{verbatim}
186 | \end{quote}
187 |
188 | 排版出來的結果如下:
189 |
190 | \begin{quote}
191 | \url{http://edt1023.sayya.org/tex/latex123/example4.tex}\\
192 | \url{http://edt1023.sayya.org/tex/latex123/example4.pdf}
193 | \end{quote}
194 |
195 | 這裡千萬要注意的是,\verb|\tableofcontents| 要加在 \verb|\maketitle| 的後面,否則目錄會印在 title page 之前。而且要\textcolor{red}{\bf 編譯兩次}。第一次產生 {\ttfamily example4.toc},然後第二次編譯再跟據這個 {\ttfamily toc} 檔,真正編入目錄。
196 |
197 | 目錄是包括圖表目錄的(List of Figures, List of Tables),但我們目前還沒有談到圖表的排版,因此暫時略過,等談到時再來看要如何加入圖表目錄。
198 |
199 | \section{加入摘要(abstract)}
200 | \label{sec:abstract}\index{abstract}
201 |
202 | 這不一定會有,如果要加入的話,可使用 {\ttfamily abstract} 環境,在這個環境中的文章,左右會縮排。要注意的是,只有 {\ttfamily article/report} 類別才有 abstract,{\ttfamily book} 類別不能使用這個環境。
203 |
204 | \begin{quote}
205 | \begin{verbatim}
206 | % example5.tex
207 | \documentclass{report}
208 | \title{Aesop Fables}
209 | \author{Aesop\thanks{Thanks to the reader.}
210 | \and Nobody\thanks{Thanks to nobody}}
211 | \date{\today}
212 | \begin{document}
213 | \maketitle
214 | \begin{abstract}
215 | The tale, the Parable, and the Fable are all common and popular
216 | modes of conveying instruction. Each is distinguished by its own
217 | special characteristics.
218 | \end{abstract}
219 | \tableofcontents
220 | \chapter{Aesop Fables}
221 | \section{The Ant and the Dove}
222 | ...
223 | \end{verbatim}
224 | \end{quote}
225 |
226 | 排版出來的結果如下:
227 |
228 | \begin{quote}
229 | \url{http://edt1023.sayya.org/tex/latex123/example5.tex}\\
230 | \url{http://edt1023.sayya.org/tex/latex123/example5.pdf}
231 | \end{quote}
232 |
233 | {\ttfamily report}\index{\texttt{report}} 類別的摘要自成一頁,不編頁碼,且不會編入目錄中,這和一般的論文格式可能會不一樣,使用時請注意。{\ttfamily artcile}\index{\texttt{artcile}} 的類別則仍然是和本文相連的,會出現在文章標題之後。
234 |
235 | {\ttfamily abstract} 和 summary\index{summary} 在較正式的論文是有區分的,通常 abstract 在文前;summary 則在文後。但目前一般性的文章則沒有這樣區別,通通當成「摘要」。通常,摘要裡頭是不用註解、無交互參照也不使用公式圖表的。
236 |
237 |
238 | \section{加入註解}
239 | \label{sec:footnote}\index{註解}
240 |
241 | 在 \LaTeX{} 裡頭,註解可有兩種方式,一種是腳註(footnote)\index{footnote}\index{腳註},一種是邊註(marginal note)\index{marginal note}\index{邊註}。通常 \LaTeX{} 的腳註預設是由阿拉伯數字在編號,置於頁底部。在沒有部(part)的情形下,\texttt{report/book} 類別,編號每章會從頭起算,\texttt{article} 類別則會連續,而且,會使用 \texttt{footnotesize}\index{footnotesize@\texttt{footnotesize}} 的字體印出。邊註則不編號,字體是正常大小。
242 |
243 | \subsection{腳註(Footnote)}
244 |
245 | 在所要加註的那個字後,使用 \verb|\footnote{}| 指令即可,解說的文字就寫入大括號之內,一般 \LaTeX{} 的指令在此都仍然有有作用,會印在此頁的底部,以小一點的字來印出,並加上編號。以下我們就試試看在 Dove 這個字來做腳註。請注意,Dove 這個字和 \verb|\footnote{}| 之間是沒有空白的。
246 |
247 | \begin{quote}
248 | \begin{verbatim}
249 | % example6.tex
250 | \documentclass{report}
251 | \title{Aesop Fables}
252 | \author{Aesop\thanks{Thanks to the reader.}
253 | \and Nobody\thanks{Thanks to nobody}}
254 | \date{\today}
255 | \begin{document}
256 | \maketitle
257 | \tableofcontents
258 | This is the first experience of \LaTeX.
259 | \chapter{Aesop Fables}
260 | \section{The Ant and the Dove}
261 | An ant went to the bank of a river to quench its thirst, and
262 | being carried away by the rush of the stream, was on the
263 | point of drowning.
264 | A Dove\footnote{Pigeon, an emblem of peace.}
265 | sitting on a tree overhanging the water plucked a
266 | leaf and let it fall into the stream close to her. The Ant
267 | climbed onto it and floated in safety to the bank.
268 | ...
269 | \end{verbatim}
270 | \end{quote}
271 |
272 | 排版出來的結果如下:
273 |
274 | \begin{quote}
275 | \url{http://edt1023.sayya.org/tex/latex123/example6.tex}\\
276 | \url{http://edt1023.sayya.org/tex/latex123/example6.pdf}
277 | \end{quote}
278 |
279 | \subsection{邊註(Marginal note)}
280 |
281 | 邊註只是把 \verb|\footnote{}| 換成 \verb|\marginpar{}|\index{marginpar@\verb=\marginpar=} 而已,內容仍然寫入大括號內。但和腳註不一樣的是,他沒有編號(因為就在旁邊,無此必要),他的字體也不會小一號,和內文的字體大小是一樣的,這在後面討論到字型的時候會談到如何改變字體的大小。
282 |
283 | \begin{quote}
284 | \begin{verbatim}
285 | % example7.tex
286 | \documentclass{report}
287 | \title{Aesop Fables}
288 | \author{Aesop\thanks{Thanks to the reader.}
289 | \and Nobody\thanks{Thanks to nobody}}
290 | \date{\today}
291 | \begin{document}
292 | \maketitle
293 | \tableofcontents
294 | This is the first experience of \LaTeX.
295 | \chapter{Aesop Fables}
296 | \section{The Ant and the Dove}
297 | An ant went to the bank of a river to quench its thirst, and
298 | being carried away by the rush of the stream, was on the
299 | point of drowning.
300 | A Dove\marginpar{Pigeon, an emblem of peace.}
301 | sitting on a tree overhanging the water plucked a
302 | leaf and let it fall into the stream close to her. The Ant
303 | climbed onto it and floated in safety to the bank.
304 | ...
305 | \end{verbatim}
306 | \end{quote}
307 |
308 | 排版出來的結果如下:
309 |
310 | \begin{quote}
311 | \url{http://edt1023.sayya.org/tex/latex123/example7.tex}\\
312 | \url{http://edt1023.sayya.org/tex/latex123/example7.pdf}
313 | \end{quote}
314 |
315 | \section{字型的相關調整}
316 | \index{字型!相關調整}
317 |
318 | \TeX/\LaTeX{} 的字型系統算是相當複雜的,這裡不多談其中原理,站在使用者的角度,我們只要知道怎麼使用就行了。在這裡,我們說字型(font)\index{font}\index{字型},指的是字型本身的一個總稱,或稱為字體\index{字體},在字的形狀的時候,我們就稱為字形(font shape)\index{font shape}\index{字形}。
319 |
320 | \LaTeX{} 使用的字型選字機制,以目前新版本的 \LaTeX{} 而言,是使用 1993 年發行的 NFSS(New Font Selection Scheme) 第二版為標準。當然,仍然是建立在 \TeX\ 字型機制的基礎上的,這已超出這篇文章的範圍。
321 |
322 | \subsection{\LaTeX{} 對字型的屬性描述}
323 | \label{subsec:font-attr}\index{字型!屬性描述}
324 |
325 | 在 \LaTeX{} 裡,對於字型的描述,使用了五種屬性來說明,這五種屬性,也是 \LaTeX{} 巨集中常要使用到的參數,甚至是錯誤訊息標示字型來源的時候,會把字型的這些屬性給顯示出來。
326 |
327 | \begin{enumerate}
328 | \item 字型編碼(font encoding)\index{font encoding}\index{字型!字型編碼}\\
329 | 這裡所謂的字型編碼,指的是各個個別的字在一個字型裡頭的排列順序及安排方式。原始的 \TeX\ 字型編碼我們就稱為 OT1(Old \TeX\ text encoding)\index{OT1},這是預設的,如果都不指定字型編碼,那所使用的就是 OT1 編碼。在目前新一代的字型編碼裡頭,字的安排方式及內容和 OT1 不一樣,例如
330 | T1\footnote{正式名稱是 Cork's \TeX\ extended text encoding 又稱為 Text Companion encoding。這裡的 T1 和 Type 1 字型規格\index{字型!字型規格}無關,他是字型編碼方式,他把字型裡頭有關一些重音符號字母單獨視為一個單獨的字,而非如 OT1 是由一般字母和重音符號組合而成。}\index{T1},這在往後提到改變字型編碼時會再談到,我們目前就不去調整字型編碼,使用預設的 OT1,其他的編碼這裡就不多談了。
331 |
332 | \item 字族(font family)\index{font family}\index{字族}\\
333 | 指同一設計類型的字型集合的名稱,例如羅馬字族(roman)\index{roman}\index{羅馬字族}、打字機字族(typewriter)\index{typewriter}\index{打字機字族}等等,通常前面會冠上製作商或製作人的名稱,例如 Knuth\index{Knuth} 教授設計的,稱為 `Computer Modern Roman'\index{Computer Modern Roman},Adobe 公司製作的羅馬字族稱為 `Adobe Times'\index{Adobe Times}。我們預設使用的,當然就是 Knuth 教授所設計的 Computer Modern fonts。以下為一些例子:
334 |
335 | \begin{quote}
336 | \begin{tabular}{>{\ttfamily}ll}
337 | 簡稱 & 代表意義 \\
338 | \hline
339 | cmr & Computer Modern Roman \\
340 | cmss & Computer Modern Sans Serif \\
341 | cmtt & Computer Modern Typewriter
342 | \end{tabular}
343 | \end{quote}
344 |
345 | \item 字型系列(font series)\index{font series}\index{字型!字型系列}\\
346 | 這是指字型的 weight(胖瘦)及 width(長扁)來區分的。例如粗、細字體,一般我們正常用的是 medium,粗體則是 bold。以下是一些例子:
347 |
348 | \begin{quote}
349 | \begin{tabular}{>{\ttfamily}ll}
350 | 簡稱 & 代表意義 \\
351 | \hline
352 | m & medium \\
353 | b & bold \\
354 | bx & Bold extended \\
355 | sb & Semi-bold \\
356 | c & Condensed
357 | \end{tabular}
358 | \end{quote}
359 |
360 | \item 字形(font shape)\index{font shape}\index{字形}\\
361 | 這個望文生義,就是字的形狀。例如意大利斜體(italic)\index{italic}\index{意大利斜體}、斜體(slant)\index{slant}\index{斜體}、small caps\index{small caps} 等等。以下是幾個例子:
362 |
363 | \begin{quote}
364 | \begin{tabular}{>{\ttfamily}ll}
365 | 簡稱 & 代表意義 \\
366 | \hline
367 | n & 正常字(normal),指 upright 或 roman \\
368 | it & Italic \\
369 | sl & Slanted \\
370 | sc & Small Caps \\
371 | \end{tabular}
372 | \end{quote}
373 |
374 | \item 字型大小(font size)\index{font size}\index{字型!字型大小}\\
375 | 預設的字型大小是 10pt(10 point),十點字。不加單位的話,預設的就是 pt。請注意,非標準 \LaTeX{} 類別的預設字型大小可能會不一樣。
376 | \end{enumerate}
377 |
378 | 我們對字型要調整改變的,就是這些字型屬性的設定值。\LaTeX{} 已設定好方便的指令給我們使用。
379 |
380 | \subsection{調整字族、字型系列、字形的指令}
381 | \label{subsec:font-command}
382 |
383 | \linespread{1.0}
384 | \small
385 | \begin{tabular}[\textwidth]{lllll}
386 | & 字型 & 標準指令 & 宣告式指令(環境) & 舊用法 \\
387 | \hline
388 | 字 & \textup{textup} & \verb|\textup{textup}| & \verb|{\upshape textup}| & \\
389 | 形 & \textit{italic} & \verb|\textit{italic}| & \verb|{\itshape italic}| & \verb|{\it italic}| \\
390 | & \textsl{slant} & \verb|\textsl{slant}| & \verb|{\slshape slant}| & \verb|{\sl slant}| \\
391 | & \textsc{small caps} & \verb|\textsc{small caps}| & \verb|{\slshape small caps}| & \verb|{\sc small caps}| \\
392 | \hline
393 | 系 & \textmd{medium} & \verb|\textmd{medium}| & \verb|{\mdseries medium}| & \\
394 | 列 & \textbf{boldface} & \verb|\textbf{boldface}| & \verb|{\bfseries boldface}| & \verb|{\bf boldface}| \\
395 | \hline
396 | 字 & \textrm{roman} & \verb|\textrm{roman}| & \verb|{\rmfamily roman}| & \verb|{\rm roman}| \\
397 | 族 & \textsf{sans serif} & \verb|\textsf{sans serif}| & \verb|{\sffamily sans serif}| & \verb|{\sffamily sans serif}| \\
398 | & \texttt{typewriter} & \verb|\texttt{typewriter}| & \verb|{\ttfamilyfamily typewriter}| & \verb|{\ttfamily typewriter}| \\
399 | \end{tabular}
400 | \linespread{1.36}
401 | \normalsize
402 |
403 | 先別嚇了一跳,這是有跡可循的。其中 upright, medium, roman 都是一樣的,這是一般的正常字,就不必麻煩去設定他了,除非是要在特定字型範圍裡頭,重新改變成正常字體。從前面所說的簡稱的字串,再和 text, family, series, shape 去配對來使用,這樣只要記得簡稱就行了,例如:italic 的就是 \verb|\textit{}|。不然也可以使用「偷吃步」的舊用法,其實這也不是什麼偷吃步,他是原始 Plain \TeX\index{Plain \TeX} 所定義的,在舊版的 \LaTeX{} 2.09 也相容他而沿用,並加以擴充。但如果使用舊用法,那有時組合式的表示時可能會無效,例如粗斜體這種粗體和斜體設定混合時,就無法產生粗斜體了,這時還是得乖乖使用正統標準 \LaTeX{} 的表示法。
404 |
405 | 要注意的是,大括號的位置,宣告式的指令,整個作用範圍是連指令一起包住的,他可以當成環境來使用,例如 \verb|\begin{itsahpe}|, \verb|\end{itshape}|,這樣在這個環境內的文字就通通會使用 italic 斜體,也可以不加參數使用,例如 \verb|\itshape|,這樣以下的文字通通會使用 italic 斜體,直至另一個改變字型的指令出現為止。標準指令的作用範圍則是當做指令的一個參數,這些參數是出現在指令後的大括號內的。現在就來實際編譯個例子試看看:
406 |
407 | \begin{quote}
408 | \begin{verbatim}
409 | % example8.tex
410 | \documentclass{report}
411 | \title{\bfseries Aesop Fables}
412 | \author{Aesop\thanks{Thanks to the reader.}
413 | \and Nobody\thanks{Thanks to nobody}}
414 | \date{\today}
415 | \begin{document}
416 | \maketitle
417 | \tableofcontents
418 | \chapter{Aesop Fables}
419 | \section{The \textsl{Ant} and the \textsl{Dove}}
420 | \itshape
421 | An antwent to the bank of a river to quench its thirst, and
422 | being carried away by the rush of the stream, was on the
423 | point of drowning.
424 | \upshape
425 | A \textsl{Dove} sitting on a tree overhanging the water plucked a
426 | leaf and let it fall into the stream close to her. The \textbf{\textsl{Ant}}
427 | climbed onto it and floated in safety to the bank.
428 | \section{The {\it Dog}\/ in the Manger}
429 | A \textbf{\textit{dog}} lay in a manger, and by his growling and snapping
430 | prevented the oxen from eating the hay which had been
431 | placed for them.
432 | ``What a selfish Dog!'' said one of them to his companions;
433 | ``he cannot eat the hay himself, and yet refuses to allow
434 | those to eat who can.''
435 | \chapter{The \textsc{Eagle} and the Arrow}
436 | An \textsc{eagle} sat on a lofty rock, watching the movements of a
437 | Hare whom he sought to make his prey.
438 | An archer, who saw the \textsc{Eagle} from a place of concealment,
439 | took an accurate aim and wounded him mortally.
440 | \end{document}
441 | \end{verbatim}
442 | \end{quote}
443 |
444 | 我們把 title page\index{title page} 的標題改成粗體(請注意,宣告式或舊用法,大括號是把指令和文字整個括住的),把 Dove 改成 slant 斜體,把 dog 改成 italic 粗斜體\footnote{請注意,這兩種斜體是不一樣的,slant 是一般正常的字,只是把他傾斜個角度而已,但 italic 則是另一種獨特的字型設計。},把 ant 改成 slant 粗斜體,把 eagle 改成 small caps。由於章節標題原本就會轉換成粗體,所以章節標題的部份,粗體就不必重複設了。
445 |
446 | 但這裡發現例子裡第二章標題中的 Eagle 並沒有改變字體,而且以 {\ttfamily latex} 編譯時會產生以下的錯誤(這些訊息也會在 {\ttfamily example8.log} 中找到):
447 |
448 | \begin{quote}
449 | \begin{verbatim}
450 | ...
451 | LaTeX Font Warning: Font shape `OT1/cmr/bx/sc' undefined
452 | (Font) using `OT1/cmr/bx/n' instead on input line 4.
453 | ...
454 | LaTeX Font Warning: Some font shapes were not available, defaults substituted.
455 | ...
456 | \end{verbatim}
457 | \end{quote}
458 |
459 | 現在我們看到了前面所談的屬性簡稱,這在 \LaTeX{} 就會使用這種屬性來表示而發出訊息,這裡 \verb|OT1/cmr/bx/sc| 就表示了 OT1 編碼,Computer Modern Roman 字族,Bold extended 系列,而且是 small caps 形狀的字型,錯誤訊息顯示,他並沒有定義,因此,這個字型將會使用預設的字型來代替,這裡就是以 n 正常形狀的 bx 系列字型來替代。所以,字型指令並不是都可以隨意組合的,有些是根本就沒有這種字型,有些則是沒有用巨集去定義好,這樣 \LaTeX{} 就取不到字了,但別擔心,頂多就是使用預設的字型罷了!
460 |
461 | 另一個很奇怪的地方,就是第一章、第二節的標題,為什麼是 \verb|{\it Dog}\/ in the...}|?這個插入的 \verb|\/| 是什麼東西?這是 \TeX\ 系統調整斜體字(包括 iatlic 及 slanted)和正常字之間的空白的一個指令,稱為 italic correction\index{italic correction}。這樣,在斜體字和正常字之間的空白才會正常。那為什麼其他的斜體指令沒有加這個調整呢?這是因為 \LaTeX{} 巨集在設計時就有考慮到這個問題,所以 \verb|\textit{}| 這類標準指令都會自動調整 italic correction,不必由我們手動調整。
462 |
463 | 另外,章節標題本就會自動轉換成粗體,標題上的 dog 為什麼沒有變粗體?這在前面有提到過,這種舊用法有時是無法複合使用的,粗體又斜體的指令會用不上來。因此,建議盡量使用 \LaTeX{} 的第一種標準指令來改變字型。使用 \verb|{\it ...}| 或 \verb|{\itshape ...}|\footnote{宣告式指令可以複合使用,但仍然會需要手動做 italic correction。} 這種指令的話,就得時時注意 italic correction 的問題,也得注意是否可以複合使用指令的問題,所以,還是不要偷懶的好。:-)
464 |
465 | 後下是排版出來的結果:
466 |
467 | \begin{quote}
468 | \url{http://edt1023.sayya.org/tex/latex123/example8.tex} \\
469 | \url{http://edt1023.sayya.org/tex/latex123/example8.pdf}
470 | \end{quote}
471 |
472 | \subsection{相對字型大小的調整}
473 |
474 | 接下來談最後一個字型大小屬性的調整,這在使用上比較單純,只要知道指令就可以馬上拿來使用。但是 \TeX{}/\LaTeX{} 系統中,談到字型,裡頭一堆地雷,例如前面談到正常的內文字型大小是 10pt,現在如果想製作海報,需要 64pt 的字的時候就會發現,設不出來了!正常 \LaTeX{} 的定義,字型的大小範圍是在 5--24.88pt 之間,超出這個範圍的字需要其他的 package 的幫忙。\footnote{這是 \LaTeX{} 本身巨集定義的問題,因為他主要是針對一般性文件及書籍,\TeX{} 本身的能力,可以讓字型放大到 2047pt。}
475 |
476 | 這裡我們先來看看內文 10pt 時各種字型大小指令、實際例子及其大小(這是相對大小,會隨內文預設字型大小而自動調整):\footnote{請注意,本文 pdf 格式內文使用 12pt 字型大小,列表及其中的例子,是由另外 10pt 預設字型大小所製作的 eps 圖檔引入,以免失真。}
477 |
478 | \begin{quote}
479 | \centering
480 | \includegraphics{fntsize}
481 | \end{quote}
482 |
483 | 這些字型大小指令也可以當成環境來使用,例如:
484 |
485 | \begin{quote}
486 | \begin{verbatim}
487 | \begin{small}
488 | 本文內容
489 | \end{small}
490 | \end{verbatim}
491 | \end{quote}
492 |
493 | 這樣用也是可以的。
494 |
495 | \subsection{絕對字型大小的調整}
496 |
497 | 通常字型的大小\index{字型!字型大小},使用上一節所說的相對字型大小來調整會比較方便,而且對於整個版面的配合也會比較恰當,例如行距也會跟著做適當的調整,如果自行用絕對字型大小的方法來調整字型大小的話,常常會造成行距不一致的情形,因此,如非必要,應盡量避免。
498 |
499 | 但有時候就是需要做這樣的調整,例如本文封面的字型大小,縱使是 \LaTeX{} 預設的最大字型也覺得稍小了點,這就要另外引入 package 調整了。
500 |
501 | 這裡我們使用 \textsf{type1cm}\index{type1cm@\textsf{type1cm}} package 來調整。當然,得使用 Type 1 字型,才可以達到無段放大、縮小的目的%
502 | \footnote{\LaTeX{} 系統中的字型放大,在 10pt 以上,是以 1.2 的倍數為次方來放大的,因此,正文 10pt 的字型大小的話,不會有 13pt 這種大小的字型,\LaTeX{} 會選用最相近大小的字型來替代。}%
503 | ,而這個 package 也是配合 Type 1 字型使用的。個別放大的 pk 點陣字,這裡就不討論了,目前絕大部份的 Computer Modern 字型都已有 Type 1 的 free 版本,而且各個 \TeX\ distribution 都會附上,使用上會較方便。以下是 \textsf{type1cm} 的使用方法:
504 |
505 | \begin{quote}
506 | \begin{verbatim}
507 | ...
508 | \usepackage{type1cm}
509 | ...
510 | \fontsize{字型大小}{行距大小}\seclectfont
511 | ...
512 | \end{verbatim}
513 | \end{quote}
514 |
515 | 還記得如何引用巨集套件\index{巨集套件}嗎?請參考第 \ref{ch:syntax} 章、第 \ref{sec:struct} 節,第 \ref{subsec:preamble} 小節的說明。
516 |
517 | 其中的「字型大小」就是所要指定的大小,通常以 pt 為單位,當然,要使用其他單位也是可以。「行距大小」也是要一併指定,不可省略。最後的 \verb|\seclectfont| 是讓他發生作用的意思,\LaTeX{} 有些關於字型的較低階指令,要下 \verb|\seclectfont| 後才會作用,\verb|\fontsize{}{}|\index{fontsize@\verb=\fontsize=} 正是其中之一。
518 |
519 | \section{原文照列}
520 |
521 | 什麼是原文照列\index{原文照列}?一般 \LaTeX{} 遇到倒斜線\index{倒斜線}會認為是一個指令的開始,如果連整個指令都要印出的時候呢?這時就要用到原文照列的指令及環境了。
522 |
523 | \subsection{原文照列指令}
524 |
525 | 如果只是一小段的文字要原文照列,那使用指令會比較方便,這個指令就是 \verb+\verb|文字內容|+\index{verb@\verb=\verb=},其中的 \verb+|+ 這個符號可以使用其他非字母的符號代替,只要前後相同就行了,例如:\verb|\verb+文字內容+| 這樣也是可以的。
526 |
527 | \subsection{原文照列環境}
528 |
529 | 如果是一整段的內容要原文照列的話,使用環境會比較方便,那便是 {\ttfamily verbatim} 環境。不管是哪一種原文照列的情形,預設是使用打字機字族的字型來顯示的。底下是一個簡單的例子,說明原文照列指令及環境的使用:
530 |
531 | % \begin{quote}
532 | % \begin{Verbatim}[commandchars=+\[\]]
533 |
534 | % \documentclass{article}
535 | % \begin{document}
536 | % The example of \verb|\verb{}| command and \texttt{verbatim} environment.
537 | % \section{\textbackslash{}\texttt{verb} command}
538 | % When you want to express you home directory, you can \verb|echo $HOME|
539 | % varient to display your home directory in your sh script.
540 | % \noindent
541 | % \verb*|This is 4 space here.|
542 | % \section{\texttt{verbatim} environment}
543 | % Here is a sh script to determine if on GNU/Linux system.
544 | % \begin{verbatim}
545 | % #!/bin/sh
546 | % Date=`date '+%y%m%d'`
547 | % if [ `uname` = Linux ]
548 | % then
549 | % Mail=/var/spool/mail/edt1023
550 | % Target=/mnt/hd
551 | % else
552 | % Mail=/var/mail/edt1023
553 | % Target=/mnt/pub
554 | % fi
555 | % \end{verbatim}
556 | % \end{document}
557 | % \end{Verbatim}
558 | % \end{quote}
559 |
560 | 這裡會發現一些奇怪現象,例如
561 | \texttt{\textbackslash{}verb*}
562 | 那個星號是什麼意思呢?就是讓空白以 \verb*| | 的方式表示出來的意思,{\ttfamily verbatim} 環境也是可以這樣使用。例如 {\ttfamily example9} 中的:
563 |
564 | \begin{quote}
565 | \begin{verbatim}
566 | \verb*|This is 4 space here.|
567 | \end{verbatim}
568 | \end{quote}
569 |
570 | 也可以寫成:
571 |
572 | % \begin{quote}
573 | % \begin{Verbatim}[commandchars=+\[\]]
574 | % \begin{verbatim*}
575 | % This is 4 space here.
576 | % \end{verbatim*}
577 | % \end{Verbatim}
578 | % \end{quote}
579 |
580 | 差別在於,環境的上下行會多空出個空白行出來。
581 |
582 | 另外,標題為什麼不使用 \verb+\verb|\verb|+ 就好了呢?原因是原文照列的指令和環境都不能當做其他指令的參數,標題本身就是一個指令,所以 \verb+\verb+ 不能在裡頭。
583 |
584 | 使用 \verb|\textbackslash|\index{textbackslash@\verb=\textbackslash=} 這麼長的敘述,而不用 \verb|$\backslash$| 這個簡單的方式,原因是這個文稿有使用 \LaTeX{}2{\ttfamily HTML} 來轉成 HTML 格式,使用 \LaTeX{} 的替代表示法會轉成一般的符號,但使用後者的方式則會轉成圖檔,所以這裡就使用 \LaTeX{} 的替代表示法了。
585 |
586 | 底下是排版出來的結果:
587 |
588 | \begin{quote}
589 | \url{http://edt1023.sayya.org/tex/latex123/example9.tex} \\
590 | \url{http://edt1023.sayya.org/tex/latex123/example9.pdf}
591 | \end{quote}
592 |
593 | \section{加入中文}
594 |
595 | 這裡只說明如何使用 \textsf{CJK}\index{CJK@\textsf{CJK}} package 的情形,原因是一般 \TeX{} distribution 會附上(有些發行套件並沒有附上,這時只好自行安裝了)。\textsf{CJK} package 是把中文的部份包在一個環境裡頭,在這個環境內就可以使用中文,離開這個環境就又回復到原本的英文環境,底下由例子來說明。
596 |
597 | \begin{quote}
598 | \begin{verbatim}
599 | \documentclass{article}
600 | \usepackage{CJK} % 使用 CJK 巨集套件
601 | \begin{document}
602 | % 進入 CJK 環境,並使用 Big-5 碼及 hwmm 這個字型
603 | \begin{CJK}{Bg5}{hwmm}
604 | \section{CJK 巨集套件}
605 | 這是一個測試,關於 CJK package 的測試。
606 | \section{桃花源記節錄}
607 | 初狹,纔通人;復行數十步,豁然開朗。土地平曠,屋舍儼然。有良田、美池、%
608 | 桑、竹之屬,阡陌交通,雞犬相聞。其中往來種作,男女衣著,悉如外人;黃髮、%
609 | 垂髫, 並怡然自樂。見漁人,乃大驚,問所從來;具答之,便要還家,設酒、殺雞、%
610 | 作食。村中聞有此人,咸來問訊。自云:「先世避秦時亂,率妻子邑人來此絕境,%
611 | 不復出焉;遂與外人閒隔。」問今是何世;乃不知有漢,無論魏、晉。此人一一%
612 | 為具言所聞,皆歎惋。餘人各復延至其家,皆出酒食。停數日,辭去。此中人語%
613 | 云:「不足為外人道也。」
614 | \end{CJK}
615 | \end{document}
616 | \end{verbatim}
617 | \end{quote}
618 |
619 | 就這麼簡單。只是編譯要改由 {\ttfamily bg5latex}\index{bg5latex@\texttt{bg5latex}} 而不是原來的 {\ttfamily latex} 指令,這是為了避開我們 Big-5 碼的一些特殊碼的關係,還記得為何每行最後要加個百分號 \verb|%|\index{%@\verb=%=} 嗎?這樣才不會插入英文的字間空白。編譯好的例子如下:
620 |
621 | \begin{quote}
622 | \url{http://edt1023.sayya.org/tex/latex123/example10.tex} \\
623 | \url{http://edt1023.sayya.org/tex/latex123/example10.pdf}
624 | \end{quote}
625 |
626 | 詳細的 \textsf{CJK} package 的使用中文說明,請參考 \textsf{CJK} package 所附的文件及〈我的 CJK〉一文:
627 |
628 | \begin{quote}
629 | \url{http://edt1023.sayya.org/tex/mycjk/mycjk.html} \\
630 | \url{http://edt1023.sayya.org/tex/mycjk/mycjk.pdf}
631 | \end{quote}
--------------------------------------------------------------------------------
/contents/chapter05.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{空間與位置}
4 | \label{ch:space}
5 |
6 | 前一章曾提到過,學會控制空間就學會排版了!Knuth\index{Knuth} 教授在他的 \textit{The \TeX{}book}\index{The TeXbook@\textit{The \TeX{}book}} 一書中也曾形容使用 \TeX{} 排版的情形:一個版面就像一個含有膠水(glue\index{glue})的頁面,然後每一個要排版的內容就是各種不同的 box\index{box},在這些 box 還沒有固定正確位置時,都是可以移動的(膠水還沒有乾),一旦排版完成,膠水就乾了,於是每個 box 的位置就固定無法再移動了,除非又從頭再來。
7 |
8 | 一個字母、一個單字、一個句子、一個段落、一個符號、一個圖形、一個表格都可能構成一個 \TeX{} 的 box,甚至 box 中還有 box 的情形。這章想討論的,就是這個 box 如何安置他們到正確的位置,讓每個 box 之間的空間都能達到恰到好處,所以,到底是在控制 boxes 的屬性、位置,還是調整 glue 的空間,就看各位怎麼去看待了(請注意,box 不一定是可見的!在 \TeX{} 裡頭,glue 是可以調整的。)。
9 |
10 | 我們前面所討論到的英文句點後空白的調整、italic correction\index{italic correction}、\verb|\linespread|\index{linespread@\verb=\linespread=} 及 \verb|\parindent|\index{parindent@\verb=parindent=} 這些都是在調整 glue。通常,在 \LaTeX{} 系統裡頭,指定單位常常不會是絕對固定的,會視情形做小限度的自動微調,這是版面空間配置上的需要。
11 |
12 | \section{\LaTeX{} 中使用的度量單位}
13 | \label{sec:units}
14 |
15 | 要精確描述和調整 \LaTeX{} 中的空間及位置,我們必需要有個標準的度量單位。以下都是在 \LaTeX{} 常會用到的單位。這裡有絕對單位及相對單位之分,除非必要,不然,一般是建議使用相對單位,原因是,他會隨著文稿字型大小改變時跟著做適當的調整。當然,在很講求精確、固定大小的顯示時,就得使用絕對單位了。
16 |
17 | 這裡如果是閱覽 HTML 格式版本,請另參考 PDF 格式版本,以免表示上失真。以下表格中所畫出來的長度僅供參考用。
18 |
19 | \subsection{絕對單位}
20 | \index{絕對單位}
21 |
22 | \begin{quote}
23 | \begin{tabular}{>{\tt}lll}
24 | 單位名稱 & 意義 & 長度 \\
25 | \hline
26 | pt & point, $1/72.27$~inch & \drawwidth{1pt} \\
27 | bp & Adobe big point, $1/72$~inch & \drawwidth{1bp} \\
28 | pc & pica, 12pt & \drawwidth{1pc} \\
29 | mm & millimeter, $1/25.4$~inch & \drawwidth{1mm} \\
30 | cm & centimeter, 10mm & \drawwidth{1cm} \\
31 | in & inch, 25.4mm & \drawwidth{1in} \\
32 | \end{tabular}
33 | \end{quote}
34 |
35 | 這裡要注意的是 \TeX{}/\LaTeX{} 系統中所謂的點(point)\index{點(point)},指的是一般的 printer point\index{printer point},也就是 $1/72.27$~inch,但在 Adobe 的規格中,例如 \textsc{PostScript}\index{PostScript@\textsc{PostScript}} 語言中的所謂點,他是 big point\index{big point},等於 $1/72$~inch(小數點的部份捨去了),會比一般的 print point 稍微大一點點。
36 |
37 | \subsection{相對單位}
38 | \index{相對單位}
39 |
40 | \begin{quote}
41 | \begin{tabular}{>{\ttfamily}lll}
42 | 單位名稱 & 意義 & 長度 \\
43 | \hline
44 | em & 約正在使用字型字母 M 的寬度 & \drawwidth{1em} \\
45 | ex & 約正在使用字型字母 x 的高度 & \drawwidth{1ex} \\
46 | \end{tabular}
47 | \end{quote}
48 |
49 | 在 \TeX{} 裡頭所謂的 em\index{em},其實,精確而言是指在 Knuth 教授設計的 Computer Modern 字型裡頭的 em-dash\index{em-dash} 的寬度,由於字母 M 實際上是包在字型上所謂的 em-square 假想方格中,而 em 所指的寬度是指這個 em-square\index{em-square} 的寬度,但字母 M 本身並不全佔有這個 em-square,因此這樣就會造成差異了。所以以字母 M 的寬度來說明的話容易有疑義。\LaTeX{} 有個指令 \verb|\quad|\index{quad@\verb=\quad=} 這就是產生一個正確 em 的寬度的空白,所以在 Knuth 教授的 \textit{The \TeX{}book} 中,說明 em 就直接說他是一個 `quad' 的寬度。
50 |
51 | \section{版面大小}
52 | \label{sec:layout}\index{版面大小}
53 |
54 | 我們對於所能控制的一整張紙的範圍都可以稱為版面。當然,我們的內文(body)\index{內文(body)}並不是佔滿整張紙的範圍,上下左右都會留有一定的空白。小時候在宣紙上練習寫毛筆,老一輩的都會要我們留「天地」,這就是指內文四周的空白,除了視覺上的理由,大概也是人生的哲理吧?:-)
55 |
56 | 在編輯上,也有人稱內文(body)的部份為「版心」或「版口」\index{版心}\index{版口},四周的空白部份,則稱為「版邊」\index{版邊}。突破版心、版邊的設計,就稱之為「出血」\index{出血},例如,以背景圖佈滿整張紙當做是背景的場合,以這個背景圖而言,就無所謂版邊了。但這在 \LaTeX{} 通常是不會有這種情況出現,除非特意去指定內文和紙張大小同樣範圍。
57 |
58 | 當然,在內文以外的空白,也並非全是空白,他包含了頁足(footer)\index{頁足(footer)},頁眉(header)\index{頁眉(header)}及邊註(marginal note)\index{邊註}\index{marginal note}的部份,記載關於頁數、註解等資訊。
59 |
60 | \subsection{版面圖解}
61 | \label{subsec:layout}
62 |
63 | \begin{quote}
64 | \begin{center}
65 | \includegraphics{layout-r}
66 | \end{center}
67 | \end{quote}
68 |
69 | 這裡所謂的紙張大小\index{紙張大小},指的是 {\ttfamily paperwidth}\index{paperwidth} 和 {\ttfamily paperheight}\index{paperheight} 所圍成的範圍,並非實際上手上拿到的紙張大小,實際在手上的紙張通常會略大於我們這裡的所謂紙張,所以,正式列印時,還需做微調或截切才會是真正的這裡所謂的紙張大小(版面大小\index{版面大小})。
70 |
71 | 這是 10pt 內文大小,如果不指定紙張的話,\LaTeX{} 預設會使用美式 {\ttfamily letterpaper}\index{letterpaper} 的大小,如要使用歐、日式的 {\ttfamily a4paper}\index{a4paper} 的話,要另行指定。我們可以稍微看一下 \LaTeX{} 預設是如何安排版面空間的。其中 Header(頁眉)、Footer(頁足)及邊註的空間是不含括在內文 Body 裡頭的,這裡是只是單面的圖,如果是雙面的話,那偶數頁和奇數頁的邊註是要左右對換的,也就是說這個圖是奇數頁,偶數頁的話,邊註是在左邊。
72 |
73 | 這裡我們來看一下這些值所代表的意義:
74 |
75 | \begin{quote}
76 | \begin{tabular}{ll}
77 | 指令(值) & 意義 \\
78 | \hline
79 | \verb=\paperwidth= & 紙張的寬度 \\
80 | \verb=\paperheight= & 紙張的高度 \\
81 | \verb=\textwidth= & 內文(body)的寬度 \\
82 | \verb=\textheight= & 內文(body)的高度 \\
83 | \verb=\headheight= & 頁眉(header)長度 \\
84 | \verb=\headsep= & 頁眉與內文間的距離 \\
85 | \verb=\footskip= & 內文底至頁足底之距離 \\
86 | \verb=\topmargin= & 頁眉上方的空白 \\
87 | \verb=\marginparwidth= & 邊註的寬度 \\
88 | \verb=\marginparsep= & 邊註與內文的距離 \\
89 | \verb=\marginparpush= & 兩邊註間距 \\
90 | \verb=\oddsidemargin= & 內文左邊的空白大小 \\
91 | \verb=\hoffset= & 微調版面在實際紙張的左右位置 \\
92 | \verb=\voffset= & 微調版面在實際紙張的上下位置 \\
93 | \index{paperwidth@\verb=\paperwidth=}\index{paperheight@\verb=\paperheight=}%
94 | \index{textwidth@\verb=\textwidth=}\index{textheight@\verb=\textheight=}%
95 | \index{headheight@\verb=\headheight=}\index{headsep@\verb=\headsep=}%
96 | \index{footskip@\verb=\footskip=}\index{topmargin@\verb=\topmargin=}%
97 | \index{marginparwidth@\verb=\marginparwidth=}\index{marginparsep@\verb=\marginparsep=}%
98 | \index{marginparpush@\verb=\marginparpush=}%
99 | \index{oddsidemargin@\verb=\oddsidemargin=}%
100 | \index{hoffset@\verb=\hoffset=}\index{voffset@\verb=\voffset=}%
101 | \end{tabular}
102 | \end{quote}
103 |
104 | \verb|\hoffset| 及 \verb|\voffset| 就是在調整版面在實際紙張上的正確位置,這樣印出來的時候才會在實際紙張的中央。
105 |
106 | 頭昏了嗎?這很正常,因為 \LaTeX{} 的版面設定對初接觸的人來說,是惡名昭彰的困難、麻煩,因此這裡不多談他的設定,剛開始實在沒有必要把時間花在這個地方。如果實際想調整版面,建議使用 {\sffamily geometry}\index{geometry@\textsf{geometry}} package。舉個例子,想讓各邊緣是 2cm 就好,那只要在 preamble\index{preamble} 區設定:
107 |
108 | \begin{quote}
109 | \begin{verbatim}
110 | \usepackage[margin=2cm]{geometry}
111 | \end{verbatim}
112 | \end{quote}
113 |
114 | 就可以了,如果以 12pt 大小的字,{\ttfamily a4paper} 紙張大小的設定的話,以中文而言,大約是每行 40 個中文字,這是內文的寬度。可以視情形自行調整 {\ttfamily margin}\index{margin} 的值就行了。我們很希望,下一版的 \LaTeX{} 能對這方面做改善,以方便使用者設定。
115 | %更精確、詳細的設定方法,我們留到後面說明書籍成書時再來談,這樣就不致影響我們學習的正常進度。
116 |
117 | \subsection{紙張大小}
118 |
119 | \begin{quote}
120 | \begin{tabular}{>{\ttfamily}ll>{\ttfamily }ll}
121 | 紙張 & 大小 & 紙張 & 大小 \\
122 | \hline
123 | a4paper & 21x29.7cm & letterpaper & 8.5x11in \\
124 | a5paper & 14.8x21cm & legalpaper & 8.5x14in \\
125 | b5paper & 17.6x25cm & executivepaper & 7.25x10.5in \\
126 | \end{tabular}
127 | \end{quote}
128 |
129 | 至於如何指定紙張大小,這裡先簡單說明一下這篇文章的設定,談到 \LaTeX{} 的文稿類別時會再詳細說明。
130 |
131 | \begin{quote}
132 | \begin{verbatim}
133 | % 本文的設類別設定
134 | \documentclass[12pt,a4paper]{report}
135 | \end{verbatim}
136 | \end{quote}
137 |
138 | 所以,這篇文章使用的是 {\ttfamily a4paper},內文字型的大小是 12pt。方括號的參數是選項,可以省略,如果省略的話,預設值就是 10pt/{\ttfamily letterpaper}。
139 |
140 | \section{調整橫向空間}
141 |
142 | 這裡的橫向空間,例如 \verb|~|\index{~@\verb=~=} 這單字間正常空白,及 \verb|\quad| 這個 em\index{em} 寬度空白,都是在調整橫向的空白。但如果是要更大、或更小的空白時該如何調整呢?底下我們就來看看 \LaTeX{} 中有什麼控制指令可以運用:
143 |
144 | \subsection{調整橫向空間的指令}
145 |
146 | \begin{quote}
147 | \begin{tabular}{ll}
148 | 指令 & 意義 \\
149 | \hline
150 | \verb=\hspace{單位}= & 向右空出某個度量單位的空白,如果是負數,則是向左 \\
151 | \verb=\hfill= & 讓左右兩旁的文字往兩邊擴張至一個行寬為止 \\
152 | \verb=\quad= & 空出一個 em 單位的空白 \\
153 | \verb=\qquad= & 空出二個 em 單位的空白 \\
154 | \verb=\thinspace= & 空出 $1/12$ 個 em 單位的空白 \\
155 | \verb=\enspace= & 空出 $1/2$ 個 em 單位的空白 \\
156 | \verb=\dotfill= & 作用和 \verb|\hfill| 相同,只是空白變成點 \\
157 | \verb=\hrulefill= & 作用和 \verb|\hfill| 相同,只是空白變成一橫線 \\
158 | \verb=\centering= & 此指令以後的文字將會居中排列,左右沿將不切齊 \\
159 | \verb=\raggedright= & 此指令以後的文字將會居左排列,右沿將不切齊 \\
160 | \verb=\raggedleft= & 此指令以後的文字將會居右排列,左沿將不切齊 \\
161 | \verb=\centerline{}= & 將大括號內的文字居中排列
162 | \end{tabular}
163 | \end{quote}
164 | \index{hspace@\verb=\hspace=}\index{hfill@\verb=\hfill=}%
165 | \index{quad@\verb=\quad=}\index{qquad@\verb=\qquad=}%
166 | \index{thinspace@\verb=\thinspace=}\index{enspace@\verb=\enspace=}%
167 | \index{dotfill@\verb=\dotfill=}\index{hrulefill@\verb=\hrulefill=}%
168 | \index{centering@\verb=\centering=}\index{raggedright@\verb=\raggedright=}%
169 | \index{raggedleft@\verb=\raggedleft=}\index{centerline@\verb=\centerline{}=}
170 |
171 | 一行的行首使用 \verb|\hspace{單位}| 時將會失效,這時可以加個星號,例如 \verb|\hspace*{3em}|。
172 |
173 | 在使用 \verb|\centerline{}| 的場合,對於短文句很方便,因為他不會影響以下的文字,但他也不會折行,甚至加入換行符號也無效。所以如果文句長度超過一行的行寬,他會超出邊界,甚至就首尾的文字就看不到了。
174 |
175 | 其中 \verb|\thinspace| 又可以使用簡化的 \verb|\,| 來代替,主要是用在引號中又有引號的情形,通常這種情形,兩引號之間要有個間隔,以便區分,例如:
176 |
177 | \begin{quote}
178 | \begin{verbatim}
179 | ``\,`Superman', he said.''
180 | \end{verbatim}
181 | \end{quote}
182 |
183 | 表現出來會是:
184 |
185 | \begin{quote}
186 | ``\,`Superman', he said.''
187 | \end{quote}
188 |
189 | 這樣才能區分出不同引號,否則會變成一個連三個 grave accent\index{grave accent} 的引號。請注意,由於這個指令是由非字母符號構成,所以,他的作用範圍在遇到符號本身後就結束了,後面不必空白或以大括號來限制其作用範圍,就好像曾提到過的 \verb|\@| 一樣的情形。
190 |
191 | \subsection{調整橫向空間的環境}
192 |
193 | \begin{quote}
194 | \begin{tabular}{ll}
195 | \verb|\begin{center}...\end{center}| & 讓這個環境內的內容置中 \\
196 | \verb|\begin{flushleft}...\end{flushleft}| & 讓這個環境內的內容靠左 \\
197 | \verb|\begin{flushright}...\end{flushright}| & 讓這個環境內的內容靠右 \\
198 | \verb|\begin{raggedright}...\end{raggedright}| & 讓這個環境內的內容靠左,右沿將不切齊 \\
199 | \verb|\begin{raggedleft}...\end{raggedleft}| & 讓這個環境內的內容靠右,左沿將不切齊 \\
200 | \end{tabular}
201 | \end{quote}
202 | \index{center@\texttt{center}}\index{flushleft@\texttt{flushleft}}%
203 | \index{flushright@\texttt{flushright}}\index{raggedright@\texttt{raggedright}}%
204 | \index{raggedleft@\texttt{raggedleft}}
205 |
206 | 進入環境,和上一節提到的指令,兩者有什麼不同呢?最大的不同是,這可以方便的指定一個範圍的文句讓他作用,而不會影響環境以外的文句。其次,進入環境,縱使和上下行連在一起,沒有空出空白行,他也會自動的在上、下行空出個空白行出來,使用指令的話則不會。
207 |
208 | 咦!這裡怎麼又有個 {\ttfamily raggedright} 及 {\ttfamily raggedleft}?原來他也是可以當環境來使用。由於這兩個指令會使以下的內容的左、右沿不切齊,因此使用上要非常小心,除非本來就想讓內文的左、右沿不切齊,否則,最好是使用有範圍限制的方式。當然,如果這兩個指令是用在某個其他環境範圍內,他的作用也將僅限於這個環境內,不會影響這個環境外的文句。
209 |
210 | \subsection{引文環境}
211 | \index{引文環境}
212 |
213 | 引文通常就是引用他人的文句,在引文的段落,兩旁都會出現內縮的情形,以便和正文相區隔,這也是一種空間的配置,可增加文章的易讀性。在 \LaTeX{} 裡頭有三種引文環境:{\ttfamily quote}, {\ttfamily quotation}, {\ttfamily verse}。這三者看起來很像,但有些微的差異。
214 |
215 | \begin{quote}
216 | \begin{tabular}{>{\ttfamily }lll}
217 | 環境 & 適用時機 & 特性 \\
218 | \hline
219 | quote & 較短的短引文 & 每個段落第一行不內縮 \\
220 | quotation & 多個段落的長引文 & 每個段落第一行會內縮 \\
221 | verse & 詩歌、詞引文 & 每個段落的第一行不內縮,但第二行起會內縮 \\
222 | \end{tabular}
223 | \end{quote}
224 | \index{quote@\texttt{quote}}\index{quotation@\texttt{quotation}}%
225 | \index{verse@\texttt{verse}}
226 |
227 | 在 {\ttfamily verse} 的情形,通常會使用 \verb=\\=\index{\\@\verb=\\=} 來換行以便控制每一行的寬度。而且段落間距\index{段落間距}將不受外在設定的影響,其中 {\ttfamily quote} 和 {\ttfamily verse} 環境會預插入適當的段落間距,而 {\ttfamily quotation} 環境則不會。
228 |
229 | 底下我們來看看調整橫向空間的一個綜合實例:
230 |
231 | \begin{quote}
232 | \begin{verbatim}
233 | % example11.tex
234 | \documentclass{article}
235 | \usepackage{CJK}
236 | \begin{document}
237 | \begin{CJK}{Bg5}{hwmm}
238 | \section{hspace}
239 | \hspace*{2em}這是一個橫向空間調整的測試。\\
240 | 這是一個\hspace{2em}橫向空間調整的測試。\\
241 | 這是一個 \hspace{2em} 橫向空間調整的測試。
242 | \section{hfill}
243 | 這是一個\hfill{}橫向空間調整的測試。
244 | \section{quad}
245 | 這是一個\quad{}橫向空間調整的測試。\\
246 | 這是一個 \quad{} 橫向空間調整的測試。\\
247 | 這是一個\qquad{}橫向空間調整的測試。
248 | \section{dotfill}
249 | 這是一個\dotfill{}橫向空間調整的測試。\\
250 | 這是一個 \dotfill{} 橫向空間調整的測試。
251 | \section{hrulefill}
252 | 這是一個\hrulefill{}橫向空間調整的測試。
253 | \section{center}
254 | \begin{center}
255 | 這是一個橫向空間調整的測試。
256 | \end{center}
257 | \section{flushleft}
258 | \begin{flushleft}
259 | 這是一個橫向空間調整的測試。
260 | \end{flushleft}
261 | \section{flushright}
262 | \begin{flushright}
263 | 這是一個橫向空間調整的測試。
264 | \end{flushright}
265 | \section{quote}
266 | 這是節錄自伊索寓言的節錄故事:
267 | \begin{quote}
268 | An antwent to the bank of a river to quench its thirst, and
269 | being carried away by the rush of the stream, was on the
270 | point of drowning.
271 | A Dove sitting on a tree overhanging the water plucked a
272 | leaf and let it fall into the stream close to her. The Ant
273 | climbed onto it and floated in safety to the bank.
274 | \end{quote}
275 | \section{quotation}
276 | 這是節錄自伊索寓言的節錄故事:
277 | \begin{quotation}
278 | An antwent to the bank of a river to quench its thirst, and
279 | being carried away by the rush of the stream, was on the
280 | point of drowning.
281 | A Dove sitting on a tree overhanging the water plucked a
282 | leaf and let it fall into the stream close to her. The Ant
283 | climbed onto it and floated in safety to the bank.
284 | \end{quotation}
285 | \section{verse}
286 | 這是節錄自伊索寓言的節錄故事,這是節錄自伊索寓言的節錄故事,%
287 | 這是節錄自伊索寓言的節錄故事,這是節錄自伊索寓言的節錄故事:
288 | \begin{verse}
289 | An antwent to the bank of a river to quench its thirst, and
290 | being carried away by the rush of the stream, was on the
291 | point of drowning.
292 | A Dove sitting on a tree overhanging the water plucked a
293 | leaf and let it fall into the stream close to her. The Ant
294 | climbed onto it and floated in safety to the bank.
295 | \end{verse}
296 | \section{centering}
297 | \centering
298 | 這是一個橫向空間調整的測試。\\ % 這裡要換行,否則會是 \raggedright 的作用
299 | \raggedright
300 | \section{centerline}
301 | \centerline{這是一個橫向空間調整的測試。}
302 | \section{raggedright}
303 | \raggedright
304 | 這是一個橫向空間調整的測試。
305 | \section{raggedleft}
306 | \raggedleft
307 | 這是一個橫向空間調整的測試。
308 | \end{CJK}
309 | \end{document}
310 | \end{verbatim}
311 | \end{quote}
312 |
313 | 編譯好的結果如下:
314 |
315 | \begin{quote}
316 | \url{http://edt1023.sayya.org/tex/latex123/example11.tex}\\
317 | \url{http://edt1023.sayya.org/tex/latex123/example11.pdf}
318 | \end{quote}
319 |
320 | 要注意是指令前後的空白,像 \verb|\hspace|, \verb|\dotfill|, \verb|\hrulell| 這類指令,指令前後空白都會算進去的。\verb|\quad|, \verb|\qquad| 這類指令,則後面的空白也是會算入的。另外,由例子中可以看出來,一個 em\index{em} 的寬度,大約是一個中文字的寬度,所以,我們預設使用 10pt 的字,這個 em 寬度就相當於 10pt 的寬度,所以,我們在第一行插入了 2em 寬度的空白,也就好像是內縮了兩個中文字一樣。
321 |
322 | \section{調整縱向空間}
323 |
324 | \begin{quote}
325 | \begin{tabular}{ll}
326 | \verb=\vspace{單位}= & 向下空出某個單位的空白(行),負數則是向上 \\
327 | \verb=\bigskip= & 產生 12pt(11--12pt)的垂直空白(行) \\
328 | \verb=\medskip= & 產生 6pt(5--7pt)的垂直空白(行) \\
329 | \verb=\smallskip= & 產生 3pt(2--4pt)的垂直空白(行) \\
330 | \verb=\vfill= & 和 \verb|\hfill| 類似,作用是將某段落向上頂,或往下擠 \\
331 | \verb=\parskip=單位= & 調整全文每個段落間的距離為某個單位
332 | \index{vspace@\verb=\vspace=}\index{bigskip@\verb=\bigskip=}%
333 | \index{medskip@\verb=\smallskip=}\index{vfill@\verb=\vfill=}%
334 | \index{parskip@\verb=\parskip=}
335 | \end{tabular}
336 | \end{quote}
337 |
338 | 其中的 \verb|\bigskip, \medskip, \smallskip| 並非固定的,他們會視上下文脈絡的需要自動做微調,以達到一整頁較一致的空間配置。\verb|\vspace| 如果是出現在一頁的第一行或最後一行時,將會失去作用,這時可以加個星號,\verb=\vspace*{單位}=\index{vspace@\verb=\vspace*=}。
339 |
340 | 為了維持版面的一致性\index{版面一致性},使用縱向空間調整的指令時要特別留意,例如章節標題上下的空間、各段落間的空間,進入環境前後所空出的空間,這都有一個固定值,\LaTeX{} 會自動去調整,不必由使用者自行動手,除非是封面這種單獨頁。所以,使用縱向空間調整指令時,要非常注意整體的一致性,這也是排版上的一個很重要的原則。
341 |
342 | 這裡舉這篇文章的內頁封面\index{內頁封面}為例來綜合說明,橫、縱向空間的運用。還記得第 \ref{sec:titlepage} 節的 title page\index{title page} 的指令嗎?其實我們也可以自行設計一個獨立的內頁封面,使用的是 \LaTeX{} 本身的 {\ttfamily titlepage}\index{titlepage@\texttt{titlepage}} 環境。這裡的圖檔引用是我們還沒有學習到的,沒關係,只要大原則抓住就行了。
343 |
344 | \begin{quote}
345 | \begin{verbatim}
346 | % example12.tex
347 | \documentclass[12pt,a4paper]{report}
348 | \usepackage{CJK} % 引入所需要的 packages
349 | \usepackage{graphicx}
350 | \begin{document}
351 | \begin{CJK}{Bg5}{hwmm}
352 | \begin{titlepage} % 使用 titlepage 環境
353 | \vspace*{5ex}
354 | \begin{flushright} % 大標題靠右
355 | \Huge\textbf{大家來學 \LaTeX}
356 | \end{flushright}
357 | \rule{\textwidth}{.256ex}
358 | \begin{flushleft} % 版本號碼及日期靠左,和大標題之間以一橫線隔開
359 | Version 0.1 draft\\
360 | \today
361 | \end{flushleft} % 圖檔位於中央偏左
362 | \vspace{8ex} % 空出 8ex 的垂直空間
363 | \hspace{2em}\includegraphics[scale=.75]{cover2.1} % 引入圖檔,並將這個
364 | \vspace{8ex} % 圖檔橫向右移 2em
365 | \begin{flushright} % 作者資訊靠右
366 | By Edward G.J. Lee 李果正\\
367 | Email:\texttt{edt1023@info.sayya.org}
368 | \end{flushright}
369 | \end{titlepage}
370 | \end{CJK}
371 | \end{document}
372 | \end{verbatim}
373 | \end{quote}
374 |
375 | 由於配合版面的問題,其中有一些數據有更動,而且也省略了一些我們還沒有學習到的 packages,但大結構則和原始文稿一樣。所以,和這篇文章的 PDF 格式比較會發現,大標題的字體小了一點,而且沒有顏色,也沒有超連結\index{超連結}。
376 |
377 | 使用 {\ttfamily titlepage}\index{titlepage@\texttt{titlepage}} 環境後,在 {\ttfamily report/book}\index{report@\texttt{report}}\index{book@\texttt{book}} 文稿他會自成一沒有頁數的單獨頁,在 {\ttfamily article}\index{article@\texttt{article}} 類別,因為會和內文連接,所以,在選項的部份要多加一個 {\ttfamily titlepage}\index{titlepage} 的選項。另外,在 {\ttfamily titlepage} 裡頭就不能再使用 \verb|\title|\index{title@\verb=\title=}, \verb=\author=\index{author@\verb=\author=} 指令了,在本文的地方也不必再下 \verb=\maketitle=\index{maketitle@\verb=\maketitle=} 指令。
378 |
379 | 編譯好的例子如下:
380 |
381 | \begin{quote}
382 | \url{http://edt1023.sayya.org/tex/latex123/example12.tex}\\
383 | \url{http://edt1023.sayya.org/tex/latex123/example12.pdf}
384 | \end{quote}
385 |
386 | 這裡要特別說明的是,引入圖檔要使用 \textsf{graphicx}\index{graphicx@\textsf{graphicx}} package(這是最常用的,也有其他的方法來引用),引入的指令是 \verb=\includegraphics=\index{includegraphics@\verb=\includegraphics=},這個我們會在第 \ref{ch:graphic} 章會討論,在這裡我們把圖檔縮小成為原圖的 {\ttfamily 75\%},否則整個封面會超出一頁。這個圖檔是由 \MP\index{metapost@\MP} 檔案所編譯而來的,他是一種 eps 圖檔\index{eps 圖檔}(簡單的說,是含有邊界數據去除不必要周圍空白的 ps 檔\index{ps 檔},方便引入或輸出至文稿中),編譯的方法如下:
387 |
388 | \begin{quote}
389 | \begin{verbatim}
390 | mpost cover2.mp
391 | \end{verbatim}
392 | \end{quote}
393 |
394 | 這樣就會產生 {\ttfamily cover2.1} 這個 eps 圖檔,這樣就可以直接引入了。他的原始碼及 eps 圖檔在:
395 |
396 | \begin{quote}
397 | \url{http://edt1023.sayya.org/tex/latex123/cover2.mp}\\
398 | \url{http://edt1023.sayya.org/tex/latex123/cover2.1}
399 | \end{quote}
400 |
401 |
402 | \section{條列環境}
403 |
404 | 條列環境\index{條列環境}也是屬於一種空間的控制,他把一些文字按一定的方式來排列,條列環境中一些起頭的符號、文數字或字串,我們稱之為項目標籤(item label)\index{項目標籤(item label)},利用這些不一樣的排列位置及不一樣的項目標籤起頭來敘述文句,就可以達到醒目的作用。這是以章節分隔以外,相當常用讓內容一目了然的方法,建議多多利用。請千萬記得,環境中還可以有環境,而且以下三種的條列方式可以混合交叉使用。
405 |
406 | \subsection{項目式條列環境(itemize)}
407 | \index{項目式條列環境(itemize)}
408 |
409 | 這是以符號來起頭醒目的一種條列方式。例如:
410 |
411 | \begin{quote}
412 | \begin{verbatim}
413 | \begin{itemize}
414 | \item 第一大項,這裡是第一大項。
415 | \item 第二大項,這裡是第二大項。
416 | \begin{itemize}
417 | \item 第一小項,這裡是第一小項。
418 | \item 第二小項,這裡是第二小項。
419 | \end{itemize}
420 | \item 第三大項,這裡是第三大項。
421 | \item 第四大項,這裡是第四大項。
422 | \end{itemize}
423 | \end{verbatim}
424 | \end{quote}
425 |
426 | 排版出來會變成:
427 |
428 | \begin{quote}
429 | \begin{itemize}
430 | \item 第一大項,這裡是第一大項。
431 | \item 第二大項,這裡是第二大項。
432 | \begin{itemize}
433 | \item 第一小項,這裡是第一小項。
434 | \item 第二小項,這裡是第二小項。
435 | \end{itemize}
436 | \item 第三大項,這裡是第三大項。
437 | \item 第四大項,這裡是第四大項。
438 | \end{itemize}
439 | \end{quote}
440 |
441 | \subsection{列舉式條列環境(enumerate)}
442 | \label{subsec:enume}\index{列舉式條列環境(enumerate)}
443 |
444 | 這是以數目字或字母或羅馬數字來起頭醒目的條列方式。同樣的例子,改成 {\ttfamily enumerate} 的話,會排版成:
445 |
446 | \begin{quote}
447 | \begin{enumerate}
448 | \item 第一大項,這裡是第一大項。
449 | \item 第二大項,這裡是第二大項。
450 | \begin{enumerate}
451 | \item 第一小項,這裡是第一小項。
452 | \item 第二小項,這裡是第二小項。
453 | \end{enumerate}
454 | \item 第三大項,這裡是第三大項。
455 | \item 第四大項,這裡是第四大項。
456 | \end{enumerate}
457 | \end{quote}
458 |
459 | \subsection{敘述式條列環境(description)}
460 | \index{敘述式條列環境(description)}
461 |
462 | 這是以一個簡短文字敘述來起頭醒目的條列方式。再把他改成 {\ttfamily description} 的話,他是以粗體文字來起頭醒目的,這些文字要用方括號括住。
463 |
464 | \begin{quote}
465 | \begin{verbatim}
466 | \begin{description}
467 | \item[第一大項] 這裡是第一大項。
468 | \item[第二大項] 這裡是第二大項。
469 | \begin{description}
470 | \item[第一小項] 這裡是第一小項。
471 | \item[第二小項] 這裡是第二小項。
472 | \end{description}
473 | \item[第三大項] 這裡是第三大項。
474 | \item[第四大項] 這裡是第四大項。
475 | \end{description}
476 | \end{verbatim}
477 | \end{quote}
478 |
479 | 排版出來的結果是:
480 |
481 | \begin{quote}
482 | \begin{description}
483 | \item[第一大項] 這裡是第一大項。
484 | \item[第二大項] 這裡是第二大項。
485 | \begin{description}
486 | \item[第一小項] 這裡是第一小項。
487 | \item[第二小項] 這裡是第二小項。
488 | \end{description}
489 | \item[第三大項] 這裡是第三大項。
490 | \item[第四大項] 這裡是第四大項。
491 | \end{description}
492 | \end{quote}
493 |
494 | 要注意的是,不管哪一種的條列環境,每個項目(item)的文字敘述會自動折行,這相當方便,使用者只要把條列的結構弄妥,專心打每個項目的內容就成了。而且,如果使用方括號括住一些字元、字串或符號,那帶頭的標示將會是這些字元、字串或符號,如果是列舉式的條列方式,那麼有方括號的將不被編號,會自動跳過,編號順序則會自動順延。
495 |
496 | %\section{enumerate 巨集套件}
497 |
498 | %\subsection{條列環境內的空間控制}
499 |
500 |
501 | \section{線框}
502 | \index{線框}
503 |
504 | 線框在排版上佔有一定的地位,因為他可以區隔不同的空間,也可以讓某些部份突顯出來。但是,過多的線框也是會有喧賓奪主的不好副作用,使用上可能要適可而止。這裡我們要談的是單純的線框,表格\index{表格}也是線框的一種應用,我們將會在第 \ref{ch:graphic} 章,再來談表格的處理。
505 |
506 | %在 \LaTeX{} 的線框可分為三種:LR、Rule 及 Par。
507 |
508 | %\begin{quote}
509 | %\begin{tabular}
510 | %線框種類 & 意義 \\
511 | %\hline
512 | %LR & left-right,線框及線框中的內容由左至右 \\
513 | %Rule &
514 | %Par
515 | %\end{tabular}
516 | %\end{quote}
517 |
518 | \subsection{直線(rule)}
519 | \index{直線(rule)}
520 |
521 | 直線也是屬於方框的一種,就是一個實體長方形,只不過,他的高或寬(線的組細)只有一點點,所以,看起來就一像直線罷了。
522 |
523 | \begin{quote}
524 | \begin{verbatim}
525 | \rule[上下位置(單位)]{寬}{高}
526 | \end{verbatim}
527 | \end{quote}
528 |
529 | 寬及高應不必多做解釋,那個上下位置是什麼呢?這個上下位置是和基線(baseline)\index{基線}\index{baseline}在比較的,如果沒有指定,那就是在基線的位置,如果有指定,就依正負值調整和基線的相對位置,正值由基線向上調整,負值則由基線向下調整。這裡來看個個實例就瞭解了:
530 |
531 | \begin{quote}
532 | \begin{verbatim}
533 | % example13.tex
534 | \documentclass{article}
535 | \parskip=3pt
536 | \parindent=0pt
537 | \begin{document}
538 | This is a line. % 畫高 1pt 寬 3cm 的橫線。
539 | \rule{3cm}{1pt}
540 | \rule[1ex]{3cm}{1pt}
541 | \rule[-1ex]{3cm}{1pt}
542 | \rule{1pt}{3cm} % 畫高 3cm 寬 1pt 的直線。
543 | \rule{3cm}{0pt}TEST. % 把 TEST 向右推 3cm。
544 | \rule{2cm}{3cm} % 畫高 3cm 寬 2cm 的實體方框。
545 | \textcolor{blue}{This is color lines.}
546 | \textcolor{red}{\rule{3cm}{1pt}} % 有顏色的線框。
547 | \textcolor{green}{\rule[1ex]{3cm}{1pt}}
548 | \textcolor{blue}{\rule[-1ex]{3cm}{1pt}}
549 | \end{document}
550 | \end{verbatim}
551 | \end{quote}
552 |
553 | 編譯好的例子在:
554 |
555 | \begin{quote}
556 | \url{http://edt1023.sayya.org/tex/latex123/example13.tex}\\
557 | \url{http://edt1023.sayya.org/tex/latex123/example13.pdf}
558 | \end{quote}
559 |
560 | 由例子中可以看得出來,這個畫線指令並不是單單縱、橫畫線而已,靈活運用的話,可以做出許多不同的效果,例如方條圖之類的。
561 |
562 | \subsection{文字底線(underline)}
563 | \index{文字底線(underline)}
564 |
565 | 有時候我們希望在書寫文字的同時,也在其下畫線。\LaTeX{} 有現成的指令可以使用,那就是 \verb|\underline{文字}|\index{underline@\verb=\underline=},會在文字底線的部份同時畫上線條。當然,使用上常常會和現在的橫線搞混,因此使用時要特別留意整個頁面上是否已經存在了許多橫線。
566 |
567 | \subsection{方框(box)}
568 | \index{box}
569 |
570 | 這裡主要指的文字方框,繪圖上的一般框形在第 \ref{ch:graphic} 章時再來討論。這一章的開頭就已談到,整篇文章是由一個個的 box 所構成的,這裡的方框則是一個典型的 box,他的地位,當然是和前面所說的 box 一樣,\TeX/\LaTeX{} 會把他視為一個單一的字母來處理。
571 |
572 | 我們先來看看最簡單的方框的指令:
573 |
574 | \begin{quote}
575 | \begin{tabular}{ll}
576 | 指令 & 意義及作用 \\
577 | \hline
578 | \verb=\frame{文字}= & 將文字內容以可見的方框框住,方框和文字間沒有間距 \\
579 | \verb=\fbox{文字}= & 將文字內容以可見的方框框住,方框和文字間有一定間距 \\
580 | \verb=\mbox{文字}= & 作用和 \verb|\fbox| 同,但方框不可見
581 | \end{tabular}
582 | \end{quote}
583 | \index{frame@\verb=\frame=}\index{fbox@\verb=\fbox=}%
584 | \index{mbox@\verb=\mbox=}
585 |
586 | 以上的指令都可以形成方框文字。
587 |
588 | 方框也有可以調整的指令:
589 |
590 | \begin{quote}
591 | \begin{tabular}{ll}
592 | 指令 & 意義及作用 \\
593 | \hline
594 | \verb|\framebox[寬度][對齊方式]{文字}| & 與 \verb|\fbox| 同,但可指定寬度及對齊方式 \\
595 | \verb|\makebox[寬度][對齊方式]{文字}| & 與 \verb|\mbox| 同,但可指定寬度及對齊方式
596 | \index{framebox@\verb=\framebox=}\index{makebox@\verb=\makebox=}
597 | \end{tabular}
598 | \end{quote}
599 |
600 | 這裡的寬度指的是方框的寬度,不指定的話,作用就如同 \verb|\fbox| 及 \verb|\mbox| 一樣,以包住整個文字範圍為寬度,由於我們不容易測知文字內容的寬度有多少,因此寬度的指定可以使用下列相對單位的方式:
601 |
602 | \begin{quote}
603 | \begin{tabular}{ll}
604 | 寬度 & 作用 \\
605 | \hline
606 | \verb|\width| & 這個寬度就是 \verb|\fbox| 圍住時的方框寬度 \\
607 | \verb|\height| & 這是正常基線至框頂的高度 \\
608 | \verb|\depth| & 這是正常基線至框底的高度 \\
609 | \verb|\totalheight| & 這是 \verb|\height| 和 \verb|\depth| 之總和 \\
610 | \end{tabular}
611 | \end{quote}
612 |
613 | 例如,我們指定 \verb|2\width| 他的意思就是以 \verb|\fbox| 包住此文字內容時,其方框寬度的二倍寬。參數裡頭的對齊方式,可有下列幾種:
614 |
615 | \begin{quote}
616 | \begin{tabular}{>{\ttfamily }ll}
617 | 對齊方式 & 作用 \\
618 | \hline
619 | c & center,文字位於方框中央,這是預設值 \\
620 | l & flushleft,文字位於方框左方 \\
621 | r & ushright,文字位於方框右方 \\
622 | s & stretch,文字平均分分布於方框中
623 | \end{tabular}
624 | \end{quote}
625 |
626 | 不指定的話,當然就是位於方框中央位置了。我們也可以指定可見方框的線的粗細,及方框和文字間的間隔距離:
627 |
628 | \begin{quote}
629 | \begin{tabular}{ll}
630 | 指令 & 作用 \\
631 | \hline
632 | \verb|\fboxrule=單位| & 指定方框線條粗細 \\
633 | \verb|\fboxsep=單位| & 指定文字和框緣的間距 %
634 | \index{fboxrule@\verb=\fboxrule=}\index{fboxsep@\verb=\fboxsep=}%
635 | \end{tabular}
636 | \end{quote}
637 |
638 | 請注意,這不會影響 \verb|\frame{}|。如果想特別的置放方框的位置,也可以使用 \verb|\raisebox|\index{raisebox@\verb=raisebox=} 指令:
639 |
640 | \begin{quote}
641 | \begin{verbatim}
642 | \raisebox{上下位置(單位)}[深度][高度]{文字內容}
643 | \end{verbatim}
644 | \end{quote}
645 |
646 | 這裡的上下位置的意義和 \verb|\rule| 指令裡頭的一樣,只不過,這裡的上下位置一定要指定,沒有預設值,不指定會編譯錯誤。請千萬記得,方框中當然是還可以有方框的。我們現在就來看一個綜合的實例:
647 |
648 | \begin{quote}
649 | \begin{verbatim}
650 | % example14.tex
651 | \documentclass{article}
652 | \parskip=3ex
653 | \parindent=0pt
654 | \begin{document}
655 | \frame{This is frame.}
656 | \mbox{This is mbox.}
657 | \fbox{This is fbox.}
658 | \framebox{This is a framebox with no argumant.}
659 | \framebox[1.5\width]{This is a framebox.}
660 | \framebox[1.5\width][l]{This is a framebox with \texttt{l}.}
661 | \framebox[1.5\width][r]{This is a framebox with \texttt{r}.}
662 | \framebox[1.5\width][s]{This is a framebox with \texttt{s}.}
663 | This is baseline.
664 | \raisebox{3ex}[5\height]{This is a raisebox which lift 3ex.}
665 | This is baseline.
666 | \fbox{\raisebox{-3ex}[5\height]{This is a raisebox which lift $-$3ex.}}
667 | \fboxrule=1.5pt
668 | \fboxsep=8pt
669 | \framebox[1.5\width][s]{This is a framebox with \texttt{s}.}
670 | \end{document}
671 | \end{verbatim}
672 | \end{quote}
673 |
674 | 這應無需多加解釋,編譯好的例子在:
675 |
676 | \begin{quote}
677 | \url{http://edt1023.sayya.org/tex/latex123/example14.tex}\\
678 | \url{http://edt1023.sayya.org/tex/latex123/example14.pdf}
679 | \end{quote}
680 |
681 | \subsection{段落方框}
682 | \index{段落方框}
683 |
684 | 另外,也有用於段落文字的方框,可以控制某個段落出現在某特定的空間、位置。我們常常把這種安排稱為迷你版面,把版面內容置於一個不可見的方框當中,當然,這個方框和一般的 box,例如字母,仍然處於同樣的地位,\LaTeX{} 會把他當成一個字母單位來處理。
685 |
686 | \begin{quote}
687 | \begin{verbatim}
688 | \parbox[對齊方式][高度][內文位置]{寬度}{文字內容}
689 | \begin{minipage}[對齊方式][高度][內文位置]{寬度}
690 | 段落內容
691 | \end{minipage}
692 | \end{verbatim}
693 | \end{quote}
694 | \index{parbox@\verb=parbox=}\index{minipage@\texttt{minipage}}
695 |
696 | 這裡的第一個選擇性參數「對齊方式」:
697 |
698 | \begin{quote}
699 | \begin{tabular}{>{\ttfamily }ll}
700 | t & top,段落方框的上沿對齊一行的基線 \\
701 | b & bottom,段落方框的下沿對齊一行的基線 \\
702 | c & center,段落方框的中央對齊一行的基線,這是預設 \\
703 | \end{tabular}
704 | \end{quote}
705 |
706 | \verb|\parbox| 指令通常用於較短的文字內容,如果是較長的段落,那使用 {\ttfamily minipage} 環境會比較方便。這些段落方框和上面所談到的一些方框最大的不同是,段落方框本就是用來排版小段落文句,因此他會和一般正常文章段落一樣的處理,例如他會自動斷行,碰到空白行也會起新段落,但各段落預設是不縮排的,而且,在安排上會比一般的段落緊湊,一些邊緣的間距會縮減成 0pt。
707 |
708 | 高度不去指定的話,那就是以整個版面經斷行處理後,整個文字段落所形成的高度。至於內文位置指的也是 \texttt{t, b, c} 這些,意思是文字段落在方框內的上下位置,當然,這要有指定方框高度時才會有意義,因此,「內文位置」和「高度」是要同時指定的,要非常注意的是,如果指定了高度,但沒有指定內文位置,則預設是等於前面使用的「對齊方式」所指定的參數。
709 |
710 | 這些參數的使用會有些煩複,但這是彈性所帶來的「必要之惡」,不必去死記,只有在第一次接觸時把他搞清楚就夠了,實際要用到時再來查他的詳細參數,常用的指令、環境,大概多查幾次就自然而然的記起來了。
711 |
--------------------------------------------------------------------------------
/contents/chapter06.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{\LaTeX\ 的標準文稿類別}
4 | \label{ch:class}\index{文稿類別}
5 |
6 | 這章主要是在說明 \LaTeX{} 文稿的類別(document class\index{document class})\footnote{這在舊的版本稱為 style,這兩個詞意義上差不多,這些都是 \TeX{} 延伸出來的巨集定義,專門用來定義文章的大結構,以便簡化使用上及文稿的內容。},這是 \LaTeX{} 規範文稿整體結構的方法。使用 class 的用意,就是把版面結構處理和實際文稿分開,這樣的最大好處就是維持整篇文章排版結構上的一致性,也使文稿內容更清爽簡潔,使用者只要專心於文稿內容的寫作即可,如果 class 定義的好,也可以達到一文多變化又不變更文稿內容的目的,只要把引用的 class 換成別的就可以了,其他的可以不必更動。
7 |
8 | 目前,\LaTeX{} 有五種標準類別用於一般文件,可用於一般的書信、雜誌、期刊、報告及論文。但有些期刊、論文會要求一定的結構,這時得依需求另行訂定。因此,也有其他的類別存在,標準類別並不是唯一的。甚至,也可以自行撰寫自己的文稿類別。當然,我們一般使用是不需要這麼講究,這裡只介紹 \LaTeX{} 的標準類別。而且,如果有和他人交換文稿的需求時,我們應該盡可能的使用流通性較廣泛的類別。
9 |
10 | 另外,也有一些是關於 \LaTeX{} 說明文件及 macro\index{macro} 寫作時要用到的類別,這些已超出本篇文章的範圍。
11 |
12 | \section{\LaTeX{} 類別的宣告}
13 | \index{類別的宣告}
14 |
15 | \LaTeX{} 的類別,要在文稿的一開頭時就宣告(當然,其上有註解是沒有關係的),他的一般格式如下:
16 |
17 | \begin{quote}
18 | \begin{verbatim}
19 | \documentclass[選擇性參數]{類別}
20 | \end{verbatim}
21 | \end{quote}
22 | \index{documentclass@\verb=\documentclass=}
23 |
24 | 選擇性參數是可以省略的,但類別名稱則不能省,一定要指定一個類別。而且只能只有一個類別。
25 |
26 | \section{類別的選擇性參數}
27 |
28 | 選擇性參數可以選擇多個,各個選項是以逗點分開的。
29 |
30 | \begin{enumerate}
31 | \item {\ttfamily 10pt, 11pt, 12pt}\\
32 | 指定內文一般正常字的大小,預設是 {\ttfamily 10pt}。其他點數沒有外來 package 的幫忙不能指定。
33 | \item {\ttfamily a4paper, letterpaper, b5paper, executivepaper, legalpaper}\\
34 | 指定紙張大小,預設是 {\ttfamily letterpaper}。
35 | \item {\ttfamily fleqn} \\
36 | 使數學式靠左對齊,預設是居中對齊。\index{fleqn@\texttt{fleqn}}
37 | \item {\ttfamily leqno} \\
38 | 使數學式編號靠左,預設是靠右。
39 | \item {\ttfamily titlepage, notitlepage}\index{titlepage@\texttt{titlepage}}\index{notitlepage@\texttt{notitlepage}} \\
40 | 決定 title page 是否獨佔一頁。預設 \texttt{article}\index{article@\texttt{article}} 不獨佔一頁,但 \texttt{report/book}\index{book@\texttt{book}}\index{report@\texttt{report}} 則會獨佔一頁,在這裡是可以指定來變更預設行為,例如 \texttt{article} 文稿,指定 \texttt{titlepage} 的話,那 title page 就會獨佔一頁。
41 | \item {\ttfamily onecolumn, twocolumn} \\
42 | 文章單欄或兩欄式,預設是單欄,也就是不分欄。\index{onecolumn@\texttt{onecolumn}}\index{twocolumn@\texttt{twocolumn}}
43 | \item {\ttfamily twoside, oneside}\index{twoside@\texttt{twoside}}\index{oneside@\texttt{oneside}} \\
44 | 是否區分奇偶數頁。預設 \texttt{article/report} 不區分,\texttt{book} 則會區分。一般的書籍,在裝訂的部份,他的中央線稱為書脊,偶數頁會在打開書籍時的左方,而且其中內容會偏向書脊的中央(此時是向右),反之,奇數頁會在右,內容一樣會偏左向書脊,在 \texttt{oneside} 的情形則不做這樣的區分,不管奇偶頁都會在紙張的中央部位。
45 | \item {\ttfamily landscape} \\
46 | 橫向列印或縱向列印,預設縱向(portait)。\index{landscape@\texttt{landscape}}\index{portait@\texttt{portait}}
47 | \item {\ttfamily draft}\index{draft@\texttt{draft}} \\
48 | 草稿式編譯,這時圖檔將不會被引入,可加快編譯的速度。不過,如果編譯是使用向量字型的話,編譯速度應該是還算很快。但使用 {\ttfamily draft} 的一個好處是,過長的地方會標示出來。
49 | \item {\ttfamily openright, openany}\index{openright@\texttt{openright}}\index{openany@\texttt{openany}} \\
50 | 這是在控制,章的開始是否是奇數頁(right-hand page)\index{奇數頁(right-hand page)}。在 \texttt{book} 類別,預設章會從奇數頁開始,report 類別則不會。\texttt{article} 類別沒有章,所以,對此一設定會忽略。
51 | \end{enumerate}
52 |
53 | \section{類別的種類}
54 |
55 | 這裡只列出一般文章使用的類別,其他特殊巨集或 \LaTeX{} 正式文件所使用的類別就不列出了,一般使用,這些類別就足夠了。
56 |
57 | \begin{quote}
58 | \begin{tabular}{>{\ttfamily }lll}
59 | 類別 & 一般用途 & 特性 \\
60 | \hline
61 | article & 一般短文 & 無章,連續頁方式的安排,無奇偶數頁的區分 \\
62 | report & 較長論文 & 章會起新頁,預設無奇偶數頁的區分 \\
63 | book & 書籍類 & 章會於奇數頁起新頁,預設有偶數頁的區分 \\
64 | letter & 信件 & 英文信件格式 \\
65 | slides & 幻燈片 & 幾乎另用外來套件取代 \\
66 | minimal & 測試及寫新類別 & 這是最簡單的類別,只規定了內文的寬、高,正常字
67 | \end{tabular}
68 | \end{quote}
69 | \index{article@\texttt{article}}\index{report@\texttt{report}}%
70 | \index{book@\texttt{book}}\index{letter@\texttt{letter}}%
71 | \index{slides@\texttt{slides}}\index{minimal@\texttt{minimal}}
72 |
73 | 當然,這些用途並不是固定不變的,得看使用者的安排,不想多花時間、精神的話,那就依 \LaTeX{} 預設的格式去使用,至少就不會太離譜。其中 \texttt{minimal} class 是用來測試用的,或者寫新的 class 用的,他完全沒有版面的安排,例如,沒有章節的結構,各種間距也沒有定義,預設的字型是正常字,沒有其他的變化,幾乎所有的變化要自行去定義。
74 |
--------------------------------------------------------------------------------
/contents/chapter07.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{巨集套件}
4 | \label{ch:package}\index{巨集套件}
5 |
6 | \LaTeX{} 系統已經好久沒有更新,有些部份可能會跟不上實際的腳步,而且有些內定的巨集定義,經過大家的使用,發覺並不是那麼的順手,尤其是功能的強化方面,因此這章談談如何引用他人已經寫好的巨集,這很重要,盡量避免重複製造輪子,寫 \TeX{}/\LaTeX{} macro\index{macro} 可說是很專業的工作,要避免破壞了整體的結構,所以先找看看有什麼巨集套件可以使用。
7 |
8 | % %萬一找不到適合的巨集套件,或這些巨集套件的定義仍不符所需,這時我們就得自行修改定義,甚至是重新定義來符合所需,這也是這一章準備探討的一個主題。但是,不是每一個人都有充裕的時間去學習 \TeX/\LaTeX{} 的巨集語言,所以這裡探討的以實用、簡單的定義方法為主,稍微複雜的已不符合一般使用的原則,也和這篇文章的構想範圍不符。
9 |
10 | \section{一般套件的使用}
11 |
12 | 我們曾在第 \ref{subsec:preamble} 小節,頁 \pageref{subsec:preamble},提到過簡單巨集的引用,事實上,有些巨集含有許多的參數來做微調,但是每個巨集套件的參數都不會一樣,因此,使用套件之前要先看一看他所附上的使用手冊。幾乎大部份的巨集套件都有使用手冊,如果是系統上就有的巨集,那麼這些文件通常會放在:
13 |
14 | \begin{quote}
15 | \begin{verbatim}
16 | $TEXMF/doc => Unix-like 系統
17 | $TEXMF\doc => DOS/Windows 系統
18 | \end{verbatim}
19 | \end{quote}
20 |
21 | 這些目錄底下,這些文件會有原始 \TeX/\LaTeX{} 文稿,也有編譯好的 \texttt{*.dvi} 或 \textsc{PostScript}\index{PostScript@\textsc{PostScript}} 檔可以閱覽,為求方便的話,可以將他們轉成 pdf 格式來閱覽,原因是可以以關鍵字來搜尋全文,在查指令、環境時會比較方便。在 Unix-like\index{Unix-like} 系統或 Windows\index{Windows} 下的 cygwin\index{cygwin} 環境的話,可以使用 \texttt{texdoc}\index{texdoc@\texttt{texdoc}} 這個指令來閱覽,例如:
22 |
23 | \begin{quote}
24 | \begin{verbatim}
25 | texdoc amsguide => 閱覽 amsguide.dvi 這個檔的說明
26 | texdoc -s ams => 查系統上所有含 ams 字樣的文件
27 | \end{verbatim}
28 | \end{quote}
29 |
30 |
31 | \section{\LaTeX{} 官方文件中的標準巨集套件}
32 |
33 | 底下是 \LaTeX{} 官方文件中所附的標準巨集套件。雖然是標準巨集套件,但一般情形下,使用這些 packages 的機會並不多,都是有特殊需要時才會引入。
34 |
35 | \subsection{alltt}\index{alltt@\textsf{alltt}}
36 |
37 | 這個巨集套件提供 \texttt{alltt}\index{alltt@\texttt{alltt}} 環境,和 \texttt{verbatim}\index{verbatim@\texttt{verbatim}} 環境的作用相同,只是 \textbackslash{},\{,\} 的作用和一般文章中相同會被 \LaTeX{} 解讀。這有什麼用呢?這樣一來 \LaTeX{} 這個特殊標誌也可以使用,也可以讓環境中的文字具有顏色,或做其他變化,當然,裡頭的文字預設仍然是使用打字機字族\index{打字機字族}的。
38 |
39 | \subsection{doc}\index{doc@\textsf{doc}}
40 |
41 | 這是用來寫 \LaTeX{} 文件的巨集套件,這在使用 \texttt{ltxdoc}\index{ltxdoc@\texttt{ltxdoc}} 這個 class 的同時就會載入 \textsf{doc} package。由於這不是用於一般的文件使用場合,所以,這裡就不多談,有興趣的話可自行參考他的文件說明。
42 |
43 | \subsection{exscale}\index{exscale@\textsf{exscale}}
44 |
45 | 由於原先的 Computer Modern font\index{Computer Modern font} 中的數學延伸符號(\texttt{cmex}\index{cmex@\texttt{cmex}})只有 10pt 大小的字型(\texttt{cmex10}),內文放大到 \texttt{large} 以上的字型時,例如放大到 \texttt{Large} 時,有些數學符號仍然會維持一定的大小,這時可以使用這個套件,讓這些數學符號也跟著放大,例如積分符號。\textsf{exscale} 只有字型縮放的定義,因此只要把這個套件在 preamble\index{preamble} 區引用就可以了,無需任何指令。
46 |
47 | 不過,這裡要說明一下,在 \TeX/\LaTeX{} 裡字型放大,有時可能會造成表現失真的情形,尤其是數學式子,為了顧及數學式子中各個字母間的空間安排,\texttt{cmex10} 的設計並不適合拿來放大,可以把 \texttt{cmr5} 放大成 10pt 和真正的 \texttt{cmr10} 來比較就會知道表現出來會不一樣,因此,如果考慮精確配合的問題,放大數學式子的字型時可能要考慮一下使用場合,尤其目前採用向量字更是如此。請試試以下的例子,我們把 \texttt{cmr5}、\texttt{cmr10} 及 \texttt{cmr12} 同樣放大到 30pt 來看看結果會不會一樣:
48 |
49 | \begin{quote}
50 | \begin{verbatim}
51 | % test-fonts.tex
52 | \font\largecmr=cmr12 at 30pt
53 | \largecmr
54 | This is cmr12 at 30pt.
55 | \font\largecmr=cmr10 at 30pt
56 | \largecmr
57 | This is cmr10 at 30pt.
58 | \font\largecmr=cmr5 at 30pt
59 | \largecmr
60 | This is cmr5 at 30pt.
61 | \bye
62 | \end{verbatim}
63 | \end{quote}
64 |
65 | 請注意,這是 \TeX\ 文稿,不是 \LaTeX{} 文稿,所以要使用 \texttt{tex}\index{tex@\texttt{tex}} 或 \texttt{pdftex}\index{pdftex@\texttt{pdftex}} 來編譯,他的結果如下,大家可很清楚的看得出來,雖然同樣是向量字,但放大時的表現並不會一樣:
66 |
67 | \begin{quote}
68 | \url{http://edt1023.sayya.org/tex/latex123/test-fonts.tex}\\
69 | \url{http://edt1023.sayya.org/tex/latex123/test-fonts.pdf}
70 | \end{quote}
71 |
72 | 根據 Knuth\index{Knuth} 教授當初設計 \MF\index{metafont@\MF},他的理念是一個同樣的字型在放大的時候,同一個字,他的筆劃置放的相對位置應該要隨放大的倍數而稍加調整。因此,假如我們只使用一種向量字型\index{向量字型},用在不同的放大倍率的時候,文字符號間的空間配合會產生不一樣的結果,尤其是用在數學式子\index{數學式子}的時候,更加明顯。
73 |
74 | 當然,實用上 \MF\ 雖然也是一種向量字型,但由於太過於複雜,不適合拿來螢幕顯示上用,所以才會退而求其次,轉成 pk 點陣字型來使用。這也就是為什麼同樣是 \texttt{cmr} 的字型,會有幾種不同點數的獨立字型的原因,縱使是向量字也是如此。\TeX\ 已經 20 幾歲了,但是,我們的字型技術似乎還是沒有完全趕上當初 Knuth 教授的理念。
75 |
76 | \subsection{fontenc}\index{fontenc@\textsf{fontenc}}
77 |
78 | 在第 \ref{subsec:font-attr} 小節,頁 \pageref{subsec:font-attr},曾提到字型編碼的問題。要改變字型編碼,可以使用這個 \textsf{fontenc} package。以 T1 font encoding\index{T1} 來說:
79 |
80 | \begin{quote}
81 | \begin{verbatim}
82 | ...
83 | \usepackage[T1]{fontenc}
84 | ...
85 | \end{verbatim}
86 | \end{quote}
87 |
88 | 這樣就可以了,但由於一些字型,例如歐洲字元,在原來的 Computer modern Type1 字型中安排不一樣,所以,有些部份會使用原始的 \MF\ 字型所轉換成的 pk 點陣字,這樣的話,一般印表機印出來是差異不大,但如果是想製作成 PDF 格式在螢光幕閱覽的話,字型的表現會變得很醜。理想的話,要安裝 \texttt{cm-super}\index{cm-super@\texttt{cm-super}} Type1 字型,但是一般使用者恐怕自行安裝字型會有困難。這在 te\TeX\ 2.x\index{tetex@te\TeX} 以後的版本,已經有附上 \textsf{pxfonts}\index{pxfonts@\textsf{pxfonts}} 及 \textsf{txfonts}\index{txfonts@\textsf{txfonts}} package 及其字型,所以,如果是新近版本的 te\TeX\ 的話,可以由以下的方式來使用:
89 |
90 | \begin{quote}
91 | \begin{verbatim}
92 | ...
93 | \usepackage{txfonts}
94 | \usepackage[T1]{fontenc}
95 | ...
96 | \end{verbatim}
97 | \end{quote}
98 |
99 | 其中 \textsf{txfonts} 是模擬 Times 系列的字型,\textsf{pxfonts} 是模擬 Palatino 系列的字型。當然,這裡關於字型的問題有點複雜,這不在這篇文章的討論範圍,只能做簡單的說明,如果沒有特殊需要,例如,歐洲字元、一些有重音符號的字母,那使用預設的 OT1 編碼就行了,因為這些套件所附的有些字型,只有一種大小的 Type1 字型在縮放,因此使用上恐怕會有失真\index{失真}的情形。
100 |
101 | \subsection{graphpap}\index{graphpap@\textsf{graphpap}}
102 |
103 | 這是產生方格紙的巨集。他提供了一個指令,可以畫方格,可以配合 \texttt{picture}\index{picture@\texttt{picture}} 環境來使用,他的語法是:
104 |
105 | \begin{quote}
106 | \begin{verbatim}
107 | ...
108 | \usepackage{graphpap}
109 | ...
110 | \graphpaper[n](x,y)(x1,y1)
111 | ...
112 | \end{verbatim}
113 | \end{quote}
114 |
115 | 其中的 \texttt{n} 如果省略的話,預設是 10,他指的是方格紙的最小刻度單位。\texttt{(x,y)} 及 \texttt{(x1,y1)} 指的是左下角及右上角的座標值,例如:
116 |
117 | \begin{quote}
118 | \begin{verbatim}
119 | \documentclass{article}
120 | \usepackage{graphpap}
121 | \begin{document}
122 | \graphpaper(0,0)(360,360)
123 | \end{document}
124 | \end{verbatim}
125 | \end{quote}
126 |
127 | 這樣會畫出以 10 為最小刻度的方格,編譯好的例子如下:
128 |
129 | \begin{quote}
130 | \url{http://edt1023.sayya.org/tex/latex123/test-graphpap.tex}\\
131 | \url{http://edt1023.sayya.org/tex/latex123/test-graphpap.pdf}
132 | \end{quote}
133 |
134 | \subsection{ifthen}\index{ifthen@\textsf{ifthen}}
135 |
136 | \TeX\ 本身是一種排版程式語言,當然會有條件判斷式\index{條件判斷式}來方便寫巨集,但如果文稿中也充滿了條件判斷式,將會使文稿複雜化,難以閱讀、維護,因此,一般條件判斷式大多數使用在巨集定義,而不是寫在文稿當中。這個 package 就是在簡化條件判斷式,以便也可以方便使用在文稿當中。
137 |
138 | \textsf{ifthen} package 提供了 \verb|\ifthenelse|\index{ifthenelse@\verb=\ifthenelse=} 指令來做條件判斷。他後面有三個參數,第一個是條件式,第二個是條件為真的時候要執行的內容,第三個是條件為偽的時候要執行的內容。這裡不多談他的使用,底下只提供一個實例片段:
139 |
140 | \begin{quote}
141 | \begin{verbatim}
142 | ...
143 | \usepackage{ifthen}
144 | ...
145 | \ifthenelse{\isodd{\thepage}}%
146 | {\setlength{\leftmargin}{10pt}}%
147 | {\setlength{\leftmargin}{0pt}}
148 | ...
149 | \end{verbatim}
150 | \end{quote}
151 |
152 | 這樣奇數頁時,\texttt{leftmargin} 會設為 10pt,偶數頁時則為 0pt。後面加 \texttt{\%} 代表,這三行是一整行,其間沒有空白。
153 |
154 | \subsection{inputenc}\index{inputenc@\textsf{inputenc}}
155 |
156 | 由於 \textsf{fontenc} package 的一些字型編碼安排,和一般所謂的 Latin-1\index{Latin-1} 這些編碼(input encoding),他們的內容不一定相符,所以,\textsf{fontenc}\index{fontenc@\textsf{fontenc}} package 常會和 \textsf{inputenc} package 互相配合使用,以確保在使用歐洲字元、符號時能正確取得到字。例如:
157 |
158 | \begin{quote}
159 | \begin{verbatim}
160 | ...
161 | \usrpackage[T1]{fontenc}
162 | \usepackage[latin1]{inputenc}
163 | ...
164 | \inputencoding{ascii} % 也可以在文稿內文變換
165 | ...
166 | \inputencoding{latin2}
167 | ...
168 | \inputencoding{latin1}
169 | ...
170 | \end{verbatim}
171 | \end{quote}
172 |
173 | 當然,我們的文稿如果只是英美語系的文章,那這些都可以不必理會。
174 |
175 | \subsection{latexsym}
176 | \label{subsec:latexsym}\index{latexsym@\textsf{latexsym}}
177 |
178 | 這是 \LaTeX{} 額外提供的符號。在新版的 \LaTeXe\ 並不會自動載入,要自行引入這個獨立出來的 package。這主要是提供 \texttt{lasy*} 這些字型裡頭的符號。如果有使用 \textsf{amsfonts}\index{amsfonts@\textsf{amsfonts}} 或 \textsf{amssymb}\index{amssymb@\textsf{amssymb}} package 的話,這些 \textsf{latexsym}\index{latexsym@\textsf{latexsym}} 符號應該是可以無需引入(有少數符號是 \LaTeX{} 特有的)。至於各種符號的 package 有哪些內容,可以參考系統上的 \texttt{symbols*} 這些檔案,他可能存在的形式是:
179 |
180 | \begin{quote}
181 | \begin{verbatim}
182 | symbols.dvi
183 | symbols-a4.ps[pdf]
184 | symbols-letter.ps[pdf]
185 | \end{verbatim}
186 | \end{quote}
187 |
188 | 或者,也可以從 CTAN\index{CTAN} 下載最新的版本:
189 |
190 | \begin{quote}
191 | \url{ftp://cam.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf}
192 | \end{quote}
193 |
194 | \subsection{makeidx}\index{makeidx@\textsf{makeidx}}
195 |
196 | 這是在製作索引\index{索引}時要引入的 package,我們會在第 \ref{sec:index} 節,頁 \pageref{sec:index} 再來討論。
197 |
198 | \subsection{newlfont}
199 | \index{newlfont@\textsf{newlfont}}
200 |
201 | 這是模擬舊版 \LaTeX{} 的字型用法,讓他使用新的取字機制的 package。也就是我們在第 \ref{subsec:font-command},頁 \pageref{subsec:font-command} 所提到的用法。為免麻煩,我們盡量避免使用舊用法,而使用字型的標準指令。
202 |
203 | \subsection{oldlfont}
204 | \index{oldlfont@\textsf{oldlfont}}
205 |
206 | 這是模擬舊版 \LaTeX{} 的字型用法的 package。
207 |
208 | \subsection{showidx}
209 | \index{showidx@\textsf{showidx}}
210 |
211 | 這個 package 會顯示,\verb|\index|\index{index@\verb=\index=} 指令下在什麼地方。這也會在第 \ref{sec:index} 節來討論。
212 |
213 | \subsection{syntonly}
214 |
215 | \textsf{syntonly}\index{syntonly@\textsf{syntonly}} package 提供 \verb|\syntaxonly|\index{syntaxonly@\verb=\syntaxonly=} 指令,他可以檢查語法是否正確,並不會有 {\ttfamily *.dvi} 檔的輸出。但這個 \verb|\syntaxonly| 指令一定要放在 preamble 區。
216 |
217 | \subsection{tracefnt}
218 | \index{tracefnt@\textsf{tracefnt}}
219 |
220 | 這是追蹤字型使用情形的 package。通常編譯時所產生的資訊已經很足夠,但如果希望有更詳細的字型使用資訊的話,可以使用這個 package:
221 |
222 | \begin{quote}
223 | \begin{verbatim}
224 | ...
225 | \usepackage[debugshow]{tracefnt}
226 | ...
227 | \end{verbatim}
228 | \end{quote}
229 |
230 | 請注意,這樣會增加編譯的時間,而且 {\ttfamily *.log} 檔會很大。
231 |
232 | \section{\LaTeX{} 官方文件中的工具組}
233 |
234 | 這些巨集套件,\LaTeX{} 官方文件是歸類在相關軟體(relative software)中,可能會比上一節提到的標準巨集套件來得實用些。但也同時可以看得出來 \LaTeX{} 非內建的套件不少,加上其他外來的巨集套件,那真的是套件滿天飛,我們很希望在可能的情形下 \LaTeX{} team 可以考慮將一些必要的套件納入內建,更加落實版面處理和文稿寫作分開的理念。
235 |
236 | \subsection{\AmS-\LaTeX}
237 | \index{AmS-LaTeX@\AmS-\LaTeX}
238 |
239 | \LaTeX{} 本身就有排版數學式子的能力,但在比較專業使用時,可能會需要增強他的功能,\AmS-\LaTeX{} 是美國數學協會(American Mathematical Society, AMS\index{AMS}\index{American Mathematical Society}\index{美國數學協會})所發展的一個增強 \LaTeX{} 數學式子編輯的巨集組,是由 \AmS-\TeX\\index{amstex@\AmS-\TeX} 移植過來給 \LaTeX{} 使用的,他主要分成兩個部份:\textsf{amscls}\index{amscls@\textsf{amscls}} 及 \textsf{amsmath}\index{amsmath@\textsf{amsmath}},前者提供符合 AMS 的文件規格的文稿類別,後者可加強原來 \LaTeX{} 的數學模式。我們會在第 \ref{ch:math} 章,頁 \pageref{ch:math} 加以介紹。
240 |
241 | \subsection{babel}
242 | \index{babel@\textsf{babel}}
243 |
244 | 如果想排版英文以外的其他歐洲國家的語文,例如:德文、法文,那可以利用 \textsf{babel} 巨集套件。
245 |
246 | \subsection{cyrillic}
247 | \index{cyrillic@\textsf{cyrillic}}
248 |
249 | 這是專為排版斯拉夫民族語文,例如:俄文,那可以使用這個套件。
250 |
251 | \subsection{graphics}
252 | \index{graphics@\textsf{graphics}}
253 |
254 | 這是處理圖形要用到的巨集套件\index{巨集套件}。但目前一般都使用功能較完善的 \textsf{graphicx}\index{graphicx@\textsf{graphicx}} 巨集套件來取代 \textsf{graphics}\index{graphics@\textsf{graphics}} 了,事實上,引用 \textsf{graphicx} 會自動的引用 \textsf{graphics},而在指令使用的方便性上,\textsf{graphicx} 較佳,因此我們往後都是以 \textsf{graphicx} 為主來說明的。這兩個套件屬於 \LaTeX{} 的圖形工具組,這個工具組包括了和顏色、圖形相關的各種巨集,我們會在第 \ref{ch:graphic} 章,頁 \pageref{ch:graphic} 來討論。
255 |
256 | \subsection{psnfss}
257 | \index{psnfss@\textsf{psnfss}}
258 |
259 | 這是 Type1 字型的巨集套件組,例如:\textsf{times}, \textsf{charter}, \textsf{mathptmx}\index{mathptmx@\textsf{mathptmx}} 等等,他會去使用這些 Type1 字型\index{Type1 字型}。但通常這些字型有許多是商業字型,系統上不一定會有,如果沒有的話,會去使用 free 的代替字型,或者就不嵌入這些字型了。如果沒有這些商業字型,又想要嵌入替代的 Type1 字型的話,可以考慮使用 \textsf{txfonts} 或 \textsf{pxfonts} 巨集套件及其所附字型。當然,如果專業使用的話,可能得考慮購買專業的商業字型來使用。
260 |
261 | \subsection{array}
262 | \index{array@\textsf{array}}
263 |
264 | 這是加強原來的 \texttt{array}, \texttt{tabular} 環境的巨集套件,可增許多細部微調的功能。這在第 \ref{sec:array} 節,頁 \pageref{sec:array},時會討論到。
265 |
266 | \subsection{calc}
267 | \index{calc@\textsf{calc}}
268 |
269 | 這個套件可以讓 \LaTeX{} 接受一些簡單的代數運算。主要用於微調一些原始預設的長度及計數器(counter\index{計數器}\index{counter})。
270 |
271 | \subsection{dcolumn}
272 | \index{dcolumn@\textsf{dcolumn}}
273 |
274 | 這是讓表格中具有小數點的數字對齊的巨集套件。我們會在第 \ref{sec:dcolumn} 節,頁 \pageref{sec:dcolumn} 中詳細討論。
275 |
276 | \subsection{delarray}
277 | \index{delarray@\textsf{delarray}}
278 |
279 | 這是加強 \textsf{array}\index{array@\textsf{array}} 巨集套件的功能,讓矩陣或行列式的大分界符號可以使用較簡單的指令。這個套件要配合 \textsf{array} 巨集套件來使用。通常在 \textsf{array} 巨集套件中,這些矩陣或行列式的大分界符號是由 \verb|\left| 及 \verb|\right| 來引導才會出來,但使用 \textsf{delarray} 巨集則不必如此麻煩。這在第 \ref{ch:math} 章會討論到。
280 |
281 | \subsection{hhline}
282 | \index{hhline@\textsf{hhline}}
283 |
284 | 這個巨集套件會方便在畫橫線時也可以插入表格的縱線。
285 |
286 | \subsection{longtable}
287 |
288 | \textsf{longtable}\index{longtable@\textsf{longtable}} 是用在跨頁表格。通常在 \LaTeX{} 中的 \texttt{tabular} 表格是當做一個 box\index{box} 來處理,因此無法再分割,所以無法跨頁來表現。這也會在第 \ref{sec:longtable},頁 \pageref{sec:longtable} 談到表格時提及。
289 |
290 | \subsection{tabularx}
291 | \index{tabularx@\textsf{tabularx}}
292 |
293 | 這是 \texttt{tabular}\index{tabular@\texttt{tabular}} 表格環境\index{表格環境}的加強版,他可以方便的排版指定寬度的表格。同樣的,這會在第 \ref{sec:tabular} 節,頁 \pageref{sec:tabular} 時提及。
294 |
295 | \subsection{afterpage}
296 | \index{afterpage@\textsf{afterpage}}
297 |
298 | 這個件主要在調整 \LaTeX{} 的浮動環境(floating environment)\index{浮動環境}\index{floating environment}時,置放浮動物件,例如:圖、表的位置。
299 |
300 | \subsection{bm}
301 |
302 | \textsf{bm}\index{bm@\textsf{bm}} 的意思,就是 bold math(symbol),這會讓數學式子以粗體的方式來顯示。這個巨集套件,提供一個 \verb|\bm{}| 指令,只要把數學式子置於大括號中就會由粗體來顯示。
303 |
304 | \subsection{enumerate}
305 | \label{subsec-enump}\index{enumerate@\textsf{enumerate}}
306 |
307 | 這是加強 \texttt{enumerate}\index{enumerate@\texttt{enumerate}} 列舉式條列環境\index{列舉式條列環境}的巨集套件。他可以很方便的指定要使用什麼方式來起頭,原始的 \texttt{enumerate} 環境,預設第一層是阿拉伯數目字,雖然也可變更,但要重新定義,不是很方便。這裡舉個例子:
308 |
309 | \begin{quote}
310 | \begin{verbatim}
311 | % example15.tex
312 | \documentclass{article}
313 | \usepackage{enumerate}
314 | \begin{document}
315 | \begin{enumerate}[Example-1.]
316 | \item This is a item 1.
317 | \item This is a item 2.
318 | \begin{enumerate}[(1)]
319 | \item This is a item (1).
320 | \item This is a item (2).
321 | \end{enumerate}
322 | \item This is a item 3.
323 | \item This is a item 4.
324 | \end{enumerate}
325 | \end{document}
326 | \end{verbatim}
327 | \end{quote}
328 |
329 | 可以指定會順延顯示的有:\texttt{A, a, I, i, 1},如果這些是屬於固定顯示的部份,則要以大括號括起來,否則他會順序計算顯示。請試著和第 \ref{subsec:enume} 小節,頁 \pageref{subsec:enume} 的標準 \texttt{enumerate} 環境比較一下。編譯後的結果如下:
330 |
331 | \begin{quote}
332 | \url{http://edt1023.sayya.org/tex/latex123/example15.tex}\\
333 | \url{http://edt1023.sayya.org/tex/latex123/example15.pdf}
334 | \end{quote}
335 |
336 | 這裡請注意一下一些同名的環境、巨集套件,例如 \textsf{array} 巨集套件及 \texttt{array} 環境,這裡的 \texttt{enumerate} 巨集套件也是一樣。
337 |
338 | \subsection{fontsmpl}
339 | \index{fontsmpl@\textsf{fontsmpl}}
340 |
341 | 這是字型 sample 測試 package,他可以是互動的,也可以引用這個 package 後直接使用 \verb|\fontsample| 這個指令來印出目前使用的字型 sample。
342 |
343 | 互動的話,要自行輸入字族名稱。sample 檔在 \texttt{\$TEXMF/tex/latex/tools} 目錄下,只要下:
344 |
345 | \begin{quote}
346 | \begin{verbatim}
347 | latex fontsmpl.tex
348 | \end{verbatim}
349 | \end{quote}
350 |
351 | 就可以了,他會出現:
352 |
353 | \begin{quote}
354 | \begin{verbatim}
355 | This is TeX, Version 3.14159 (Web2C 7.4.5)
356 | (./fontsmpl.tex
357 | LaTeX2e <2001/06/01>
358 | Babel and hyphenation patterns for american, french,
359 | german, ngerman, nohyphenation, loaded.
360 | (/usr/share/texmf/tex/latex/base/article.cls
361 | Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
362 | (/usr/share/texmf/tex/latex/base/size10.clo)) (./fontsmpl.sty)
363 | Please enter a family name (for example `cmr').
364 | \family=
365 | \end{verbatim}
366 | \end{quote}
367 |
368 | 只要輸入要測試的字型字族,例如 \texttt{cmr},他就會產生 \texttt{fontsmpl.dvi} 這個檔,然後就可以使用 \texttt{dvips}\index{dvips@\texttt{dvips}} 或 \texttt{dvipdfm[x]}\index{dvipdfmx@\texttt{dvipdfm[x]}} 把他轉成 ps/pdf 格式的檔案。他只會測試 OT1\index{OT1} 及 T1\index{T1} 兩種字型編碼。
369 |
370 | \subsection{ftnright}
371 | \index{ftnright@\textsf{ftnright}}
372 |
373 | \LaTeX{} 在兩欄式排版(two-column mode)\index{兩欄式排版(two-column mode)}時,他的腳註是置放在各自欄位底部。\textsf{ftnright} 會將兩欄式排版時,把所有的腳註都置放在右欄底部。這樣可以將腳註集中,看起來不會那麼凌亂。
374 |
375 | \subsection{indentfirst}
376 |
377 | 通常,\LaTeX{} 的章節開頭的第一個段落是不縮排的,在第二個段落起才會縮排。如果習慣每個段落都有縮排,可以使用 \textsf{indentfirst}\index{indentfirst@\textsf{indentfirst}} package。這個套件也是引入就可以了,無需任何指令。
378 |
379 | \subsection{layout}
380 | \index{layout@\textsf{layout}}
381 |
382 | 這是顯示目前版面配置\index{版面配置}的 package。引入這個 package 後,只要在本文區下 \verb|\layout| 指令,他就會畫出目前的版面配置,也會將各種數據顯示出來。我們在第 \ref{subsec:layout} 小節,頁 \pageref{subsec:layout},裡頭所顯示的版面圖,就是這樣畫出來的。
383 |
384 |
385 | \subsection{multicol}
386 | \label{subsec:multicol}\index{multicol}
387 |
388 | 在 \LaTeX{} 宣告文稿類別的同時,我們可以選用 \texttt{twocolumn} 來選擇兩欄式的排版,再多則不行。在兩欄式的排版時,我們可以使用 \verb|\onecolumn|\index{onecolumn@\verb=\onecolumn=} 及 \verb|\twocolumn|\index{twocolumn@\verb=\twocolumn=} 指令,在單欄及兩欄間變換,但這有一個很嚴重的缺點,那就是欄位變換也會迫使換新頁,原來的頁面將會顯得空曠。
389 |
390 | \textsf{multicol} 的目的,不僅突破兩欄,可以做多欄式的排版(最多可至十欄的排版),也可以在變換欄位編排時在同一頁面變換,而不必換新頁。他提供了 \texttt{multicols}\index{multicols@\texttt{multicols}} 環境來做欄位的變換。他的使用方法很簡單,欄位數目及變換完全由環境來控制:
391 |
392 | \begin{quote}
393 | \begin{verbatim}
394 | ...
395 | \usepackage{multicol}
396 | ...
397 | \begin{multicols}{欄數}
398 | ...
399 | 內容,依正常單欄方式書寫即可
400 | ...
401 | \end{multicols}
402 | \end{verbatim}
403 | \end{quote}
404 |
405 | 請注意,引入時 \textsf{multicol} 是沒有 `s' 的,而環境中的 \texttt{multicols} 是有 `s' 的。\textsf{multicol} package 處理腳註的方式,和單欄排版相同,就是通通置於本頁底部,不分左右欄位。
406 |
407 | \subsection{rawfonts}
408 | \index{rawfonts@\textsf{rawfonts}}
409 |
410 | 這是模擬 \LaTeX{} 2.09 舊版的低階字型指令,例如 \verb|\texrm| 代表 10pt 的羅馬字族的字。在新版的 \LaTeXe\ 並沒有定義這些指令。
411 |
412 | \subsection{somedefs}
413 | \index{somedefs@\textsf{somedefs}}
414 |
415 | 這是寫 \LaTeX{} 巨集的一些範例定義,可以很容易的更改其中設定來寫自己的 package。這不在這篇文章的討論範圍,因此就不多談了。
416 |
417 | \subsection{showkeys}
418 | \index{showkeys@\textsf{showkeys}}
419 |
420 | 這個 package 會把 \verb|\label|, \verb|\ref|, \verb|\pageref| 等交互參照的指令內容,或文獻引用內容,在指令所在處印出來。
421 |
422 | \subsection{varioref}
423 | \index{varioref@\textsf{varioref}}
424 |
425 | 這是加強型的交互參照\index{交互參照}的方式,我們會在第 \ref{ch:abook} 章來討論。
426 |
427 | \subsection{verbatim}
428 | \index{verbatim@\textsf{verbatim}}
429 |
430 | 這是加強 \LaTeX{} 原來的 \texttt{verbatim} 環境的同名套件。可以在裡頭使用註解,也可以利用 \verb|\verbatiminput{檔案名}|\index{verbatiminput@\verb=\verbatiminput=} 指令來引入外來檔案,當然,引入後會自動進入 \texttt{verbatim} 環境中。
431 |
432 | \subsection{xr}
433 |
434 | \textsf{xr}\index{xr@\textsf{xr}} 是 eXternal References 的縮寫,意思就是交互參照外部的檔案。這會在第 \ref{sec:ref} 節,頁 \pageref{sec:ref} 來討論。
435 |
436 | \subsection{xspace}
437 | \index{xspace@\textsf{xspace}}
438 |
439 | 這個 package 會在一個巨集結束時聰明的插入適當的空白。我們在第 \ref{gen:gamerules},頁 \pageref{gen:gamerules},時曾談到 \LaTeX{} 指令的結束的問題,所以,我們得在指令後加 `\verb|\ |' 或者 `\verb|{}|' 來結束一個指令。但如果巨集定義時使用了 \textsf{xspace} 巨集套件的一個指令 \verb|\xspace|,那麼他就會自動判斷指令何時結束,而不必自行插入 `\verb|\ |' 或 `\verb|{}|' 了。
440 |
441 | \subsection{theorem}
442 | \index{theorem@\textsf{theorem}}
443 |
444 | 這是 \LaTeX{} 內建的 \texttt{theorem} 環境的加強型巨集套件。我們會在第 \ref{ch:math},頁 \pageref{ch:math},再來討論。
445 |
446 |
447 | \section{巨集套件何處尋?}
448 | \label{sec:pkgwhere}
449 |
450 | 重複發明輪子要盡量避免,所以,如果需要些功能,而 \LaTeX{} 似乎沒有,那可以先找看看是不是別人已經有寫好類似的功能的巨集套件,首先要找的應該是 FAQ\index{FAQ} 文件:
451 |
452 | \begin{quote}
453 | \url{http://www.tex.ac.uk/faq}
454 | \end{quote}
455 |
456 | 在 \url{news://tw.bbs.comp.tex} 也有一篇 Chun-Chieh Huang\index{Chun-Chieh Huang} 所維護的中文 FAQ\index{中文 FAQ} 可以參考。另外 \url{news://comp.text.tex} 則是英文討論群組,可以多多利用。如果已經知道套件名或關鍵字,那可以到:
457 |
458 | \begin{quote}
459 | \url{http://tug.ctan.org/CTANfind.html}
460 | \end{quote}
461 |
462 | 去搜尋,搜尋到後可以抓整個目錄的壓縮檔。通常,安裝 package,他裡頭會說明如何安裝,萬一沒有的話,可以到 bbs/news 上發問,或者下載以下這個 sh script:
463 |
464 | \begin{quote}
465 | \url{http://edt1023.sayya.org/tex/latex123/ltxins.sh}
466 | \end{quote}
467 |
468 | 他的使用方法很簡單,把他置於執行路徑可及之處:
469 |
470 | \begin{quote}
471 | \begin{verbatim}
472 | ltxins.sh your.dtx(or your.ins)
473 | \end{verbatim}
474 | \end{quote}
475 |
476 | 這樣就行了,他會產生必要的 \texttt{*.sty} 或 \texttt{*.tex} 及 pdf 格式的說明文件。這裡頭使用的是 \texttt{dvipdfm[x]},所以要有安裝這兩種工具才行。當然,他不會自動安裝,你還是要手動把一些檔案拷貝到 \LaTeX{} 找得到的地方。這只是一個很簡單的工具,因此不保證能成功編譯出文件出來。
477 |
478 | 如果想知道某個套件在系統上是否已安裝,安裝在什麼地方,可使用以下的小工具:
479 |
480 | \begin{quote}
481 | \url{http://edt1023.sayya.org/tex/latex123/ltxpkg.sh}
482 | \end{quote}
483 |
484 | 把他拷貝至路徑所及之處,使用方法如下:
485 |
486 | \begin{quote}
487 | \begin{verbatim}
488 | ltxpkg.sh package-name[.sty]
489 | \end{verbatim}
490 | \end{quote}
491 |
492 | 這會列出所查詢的套件是否已安裝,及安裝在什麼目錄下,及這個 package 是否有預先載入其他的 package(s)。當然,這兩個小工具都是 bash script 寫的,你的系統要有安裝 bash,一般的 Unix-like 系統應該沒有問題,Mac OS X 及 Windows/cygwin 環境就不敢保證了。這也是個很簡單的小工具,如果是由 \verb|\input| 指令所載入的其他 {\ttfamily .tex} 檔,可能就會偵測不出來了,許多特殊細節也是沒有去考慮到,因此實際上要以 package 的原始 macro\index{macro} 內容為準。以下為一個使用實例:
493 |
494 | \begin{quote}
495 | \begin{verbatim}
496 | edt1023:~$ ltxpkg.sh colortbl
497 | The position of this package is at:
498 | /usr/share/texmf/tex/latex/carlisle/colortbl.sty
499 | The preloaded package(s) of `colortbl.sty' is(are):
500 | array,color
501 | \end{verbatim}
502 | \end{quote}
503 |
504 | 所以,得知 {\sffamily colortbl} package,系統上已經安裝,而且他會在引入的同時也引入 {\sffamily array} 及 {\sffamily color} 這兩個 packages,除非要變更這兩個 package 引入時的選項參數,不然就可以不必引入這兩個 packages 了。
505 |
506 |
507 |
508 | %\section{微調與自行定義}
509 |
510 | %這裡所談的微調,指的是對一些 \LaTeX{} 的預設值做變更或自行定義一些簡單方便的指令、環境。雖然,我們有些處理還沒有學習到,這沒有關係,我們只是瞭解如何調整就行了,一些還沒談到的預設值,等討論到時會再提出來。
511 |
512 | %在 \LaTeX{} 裡頭有許多固定的值,例如:
--------------------------------------------------------------------------------
/contents/chapter08.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{表格的處理}
4 | \label{ch:table}
5 |
6 | 這是屬於一般人覺得比較困難,但卻是很重要的部份,讓我們多花點時間研究。\LaTeX\ 的表格,因為是抽象邏輯的思考方式來製作表格,對一般使用者而言,比較不容易轉換成直觀印象。當然,有些編輯器,例如 GNU Emacs\index{GNU Emacs},有方便畫 \LaTeX\ 表格的編輯器 script,但這些我們先不去理他,先從 \LaTeX\ 本身表格的結構理解起,這樣在使用其他的輔助工具時也會比較得心應手,甚至沒有其他工具,只要把握住表格的大結構,製作表格就不會摸不著頭緒了。
7 |
8 | 由於 \LaTeX\ 內建的表格功能算有點陽春,因此這一章會介紹一些外來的巨集套件,來彌補 \LaTeX\ 表格功能的不足,這些巨集,使用上算相當普遍,幾乎所有的 \TeX\ 的各種發行版本都會附上,因此不必擔心可攜性的問題。
9 |
10 | \section{表格的種類}\index{表格!表格的種類}
11 |
12 | 表格\index{表格}的使用,在文章上常常是必備的要件,他有歸納及醒目的作用,當然,表格太多也是會喧賓奪主。通常,我們中文的使用習慣,表格就是大方框內有小方框,文字置於小方框內,甚至某些小方框內還有斜線在分隔。為了排版上的方便及視覺表現上的美觀、清楚,在國際上大部份較正式的論文已不使用縱線、斜線,表格通常由橫線來做區隔,甚至完全沒有線條,使用空間區隔的方式。這種趨勢幾乎在二十幾年前就已開始普遍,只是國內的文件似乎還是很喜歡有縱、斜線在表格之中,好像沒有一些框線層層包住就不像表格。如非特殊的表現上的需求,我們應該朝簡化表格本身的方向走,將重點置於表格的內容及表格的邏輯結構安排,漂漂亮亮的表格外觀加上不當的內容配置,個人覺得這是個失敗的表格製作。
13 |
14 | 另外,等粗的雙線條,可能也是得盡量避免,通常粗細不等的外框雙線條有裝飾的作用,因此,如果文件是較正式的論文,那就可能要避免,如果是海報、DM 或要讓人們填寫的表格之類的,那又是另外一回事,這時封閉性的方框可能會有需要。這些規範只不過是一些慣例,並非一成不變的,得視文件的性質及使用場合來做變化,一個大原則是,如果是以文字敘述為主的文件,那麼,表格本身如果比文字內容搶眼太多的話,或許就要考慮簡化表格本身了。
15 |
16 | 我們這裡就來比較,有縱線、無縱線、完全沒有線框及含雙線表格的各種形式的表格,大家就自由心證,看哪一種表格看起來比較順眼。由於 HTML 格式在表格的表現上可能會失真,因此這裡製作成 PDF 格式供參考:
17 |
18 | \begin{quote}
19 | \url{http://edt1023.sayya.org/tex/latex123/test-tables.tex}\\
20 | \url{http://edt1023.sayya.org/tex/latex123/test-tables.pdf}
21 | \end{quote}
22 |
23 | \section{tabbing 環境}
24 | \label{sec:tabbing}\index{tabbing@\texttt{tabbing}}
25 |
26 | 這是 \LaTeX\ 裡頭最基本的表格形式,除非自行另外定義、繪製,他並沒有方便可用的線條指令來區隔,完全使用空間、位置的配置來顯示表格內容,這時整個 \texttt{tabbing} 表格在 \LaTeX\ 的地位並不是一個最小單位的 box,\LaTeX\ 不會把整個表格當成一個單位來處理。所以,\texttt{tabbing} 表格是可以跨頁的,他可以被分成兩半來處理。因此,要和其他文字、圖表並排排版時,得另外放進一個 box\index{box} 中,讓他自成一個 box 單位,例如 \verb|\parbox|\index{parbox@\verb=\parbox=} 或 \texttt{minipage}\index{minipage@\texttt{minipage}} 環境裡頭。
27 |
28 | 在 \texttt{tabbing} 環境中,第一個列(row)是以 \verb|\=|\index{\=@\verb+\=+} 來標示 \textsf{Tab} 寬度來區隔欄位(column),這個寬度是由欄位裡頭的字串寬度所決定的。後續的每個欄位是由 \verb|\>|\index{\>@\verb=\>=} 這個符號來區隔,每列尾要自行加上 \verb|\\|\index{\\@\verb=\\=} 來換行,最後一行可以不必使用 \verb|\\| 換行。\texttt{tabbing} 的基本大結構是:
29 |
30 | \begin{quote}
31 | \begin{verbatim}
32 | \begin{tabbing}
33 | column1 \= column2 \= column3 \\
34 | item1 \> item2 \> item3 \\
35 | itemA \> itemB \> itemC
36 | \end{tabbing}
37 | \end{verbatim}
38 | \end{quote}
39 |
40 | 這裡特意把他排列整齊(事實上,不排整齊 \LaTeX\ 也會幫忙排好),這樣才能看得出來他的表格結構。那如果想調整欄位寬度時可以使用 template 的方式,例如:
41 |
42 | \begin{quote}
43 | \begin{verbatim}
44 | \begin{tabbing}
45 | xxxxxxxxxx\=xxxxxxxxxx\=xxxxxxxxxx \kill
46 | column1 \> column2 \> column3 \\
47 | item1 \> item2 \> item3 \\
48 | itemA \> itemB \> itemC
49 | \end{tabbing}
50 | \end{verbatim}
51 | \end{quote}
52 |
53 | 這裡以 10 個 \texttt{x} 為欄位的寬度,這裡的 \verb|\kill|\index{kill@\verb=\kill=} 表示這一行是不印出來的,只是在表示各個欄位的樣本寬度,而且他會自動換行。當然,要使用其他的字串也是可以,例如以表格中最長字串來取代整個 {\ttfamily x} 字串,這樣就會讓欄位寬度剛好都可以容納其他欄內內容。也可以使用 \verb|\hspace{6em}| 或其他的長度指令,來指定欄位的寬度。
54 |
55 | 對於欄位內文字的控制,\texttt{tabbing} 較不完備,雖然 \LaTeX\ 有提供 \verb|\'| 讓這個符號之前的文字靠左,及 \verb|\`|\index{\`@\verb=\`=} 讓這個符號之後的文字靠右,但實際運用,可能不是使用者想要的結果,因此 \LaTeX\ 的表格,主要還是以 \texttt{tabular} 環境較為常用。但 \texttt{tabbing} 環境的好處是,他不見得一定要用於表格的排版,例如他也可以表現如條列環境\index{條列環境}般的另一種表現方式,而且他可以跨頁排版。
56 |
57 | \section{\texttt{tabular} 環境}
58 | \label{sec:tabular}\index{tabular@\textsf{tabular}}
59 |
60 | 這大概是最常使用的表格形式,可以很方便的畫線框。這種表格,\LaTeX\ 是把整個表格當成一個單位來處理,就像字母一樣,因此他在版面的安排上是和一般的字母一般的處理,所以,這種表格不經特殊處理,無法被分割成兩個部份來跨頁。
61 |
62 | 和 \texttt{tabbing} 環境的不同,除了可以有線條之外(\texttt{tabular} 環境,當然也是可以完全沒有線條),分隔欄位的符號是 {\ttfamily \&}\index{\&@\verb=\&=},而且,一定要指定欄內文字的置放位置,欄內文字超出指定的寬度時,會自動折行,還有許多其他更細節的調整。
63 |
64 | \subsection{{\ttfamily tabular} 表格的基本結構}
65 |
66 | \begin{quote}
67 | \begin{verbatim}
68 | \begin{tabular}[t]{lll}
69 | \hline
70 | column1 & column2 & column3 \\
71 | \hline
72 | item1 & item2 & item3 \\
73 | itemA & itemB & itemC \\
74 | \hline
75 | \end{tabular}
76 | \end{verbatim}
77 | \end{quote}
78 |
79 | 其中 \verb|[t]| 表示 top,也可以是 {\ttfamily b} 表示 bottom,或 {\ttfamily c} 代表 center,這要在前後有文字相並排的時候才會顯現作用,因為 \LaTeX\ 會把整個 \texttt{tabular} 表格當成一個字母單位,所以可以和其他文字、圖表並排排版。這些參數的意思是和同行文字的對齊方式,top 是表格頂端和前後文字對齊,bottom 則是表格底部和前後文字對齊,center 則是和表格中央對齊。
80 |
81 | 換行的方式和 \texttt{tabbing} 環境一樣,其中的 \verb|\hline| 是畫一條橫線的意思,連續兩個 \verb|\hline\hline| 會畫雙橫線,他本身會自動換行,因此不必加上換行符號。其中 \verb|\begin{tabular}{lll}| 的 \texttt{lll} 是在指定各欄位內容在小方框內的置放位置,{\ttfamily l} 表示靠左(left),{\ttfamily r} 表示靠右(right),{\ttfamily c} 表示置中(center)。在 \verb|{lll}| 中加上 bar(\verb+|+)會畫縱線,例如 \verb+{|l|l|l|}+ 這樣就會變成傳統的大方框、小方框的表格。而兩個 bar 就會畫雙縱線。
82 |
83 | \texttt{tabular} 環境內尚可使用另一個 \texttt{tabular} 環境來製作更複雜的表格,這在 \texttt{tabbing} 環境是不被允許的。
84 |
85 | \subsection{\texttt{tabular} 環境對欄位的調整}
86 |
87 | \begin{enumerate}
88 | \item \verb|p{寬度}|\\
89 | 這裡的 {\ttfamily p} 指的是段落(paragraph)。通常用於一個小段落的文字,指定了寬度後裡頭的文字會自動折行,而且這個段落的頂端會和其他欄位的頂端對齊。
90 | \item \verb|@{文字、符號或指令}|\\
91 | 這可以作用在本欄的各個列,讓他們都出現某個文字、符號或都在某個指令的作用下。這個指令另外會同時將欄位間距縮成 0,置於首尾的話,會有讓橫線和文字切齊的作用(預設不會切齊,橫線兩端會多出欄位間距的部份)。
92 | \item \verb|\multicolumn{欄位數}{左右位置}{文字內容}|\\
93 | 跨欄排版,例如一小段文字跨兩欄。左右位置可使用 {\ttfamily lrc} 之一。\index{multicolumn@\verb=\multicolumn=}
94 | \item \verb|\cline{a-b}|\\
95 | 畫某部份欄位的橫線,其中的 \texttt{a-b} 指的就是要畫線的欄位數,例如 \verb|\cline{2-3}| 就是畫第二欄至第三欄的橫線。\index{cline@\verb=\cline=}
96 | \item \verb|\arrayrulewidth=單位長度|\\
97 | 調整表格線條的粗細,預設值是 0.4pt。使用方法:\verb|\arrayrulewidth=1.5pt| 即可,但要注意的是要在進入 \texttt{tabular} 環境之前設定好。\index{arrayrulewidth@\verb=\arrayrulewidth=}
98 | \item \verb|\tabcolsep=單位長度|\\
99 | 調整兩欄位的左右間距。請注意,這個值是實際兩欄位間距值的一半,預設是 6pt。使用方法和 \verb|\arrayrulewidth| 一樣。\index{tabcolsep@\verb=\tabcolsep=}
100 | \item \verb|\doublerulesep=單位長度|\\
101 | 調整畫雙線時,這兩線間的間距,預設值是 2pt。使用方法和 \verb|\arrayrulewidth| 一樣。\index{doublerulesep@\verb=\doublerulesep=}
102 | \item \verb|\arraystretch|\\
103 | 調整表格的上下行距。請注意,這要由 \verb|\renewcommand| 來重設,因為在 \LaTeX\ 定義出的一個常數值,而這個 \verb|\arraystretch| 只是這些常數值的倍數,我們要重新改變他才能改變預設倍數。例如:\texttt{example16.tex} 中的使用方法。\index{arraystretch@\verb=\arraystretch=}
104 | \end{enumerate}
105 |
106 | 在 \texttt{tabular} 環境的參數中,可能是取代原來的參數,例如 \verb|p{}|。也可能是置放在原參數的前後,如 \verb|@{}|,這看一下實際例子就可以瞭解:
107 |
108 | \begin{quote}
109 | \begin{verbatim}
110 | % example16.tex
111 | \documentclass{article}
112 | \usepackage{textcomp} % for \textcelsius
113 | \renewcommand{\arraystretch}{1.2} % 將表格行間距加大為原來的 1.2 倍
114 | \arrayrulewidth=1pt % 調整線條粗細為 1pt
115 | \tabcolsep=12pt % 調整欄間距為 24pt
116 | \begin{document}
117 | \centering
118 | \section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}
119 | \begin{tabular}{@{\sffamily }lll@{}} % 第一欄位使用 sans serif 字族
120 | \hline
121 | & \multicolumn{2}{c}{\bf Specific Heats} \\ % 跨二三欄排版,文字置中
122 | \cline{2-3} % 只畫二三欄橫線
123 | & $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\
124 | \hline
125 | Aluminum & 900 & 24.3 \\
126 | Copper & 385 & 24.4 \\
127 | Gold & 130 & 25.6 \\
128 | Steel/Iron & 450 & 25.0 \\
129 | Lead & 130 & 26.8 \\
130 | Mercury & 140 & 28.0 \\
131 | Water & 4190 & 75.4 \\
132 | Ice ($-$10 \textcelsius) & 2100 & 38 \\
133 | \hline
134 | \end{tabular}
135 | \end{document}
136 | \end{verbatim}
137 | \end{quote}
138 |
139 | \textsf{textcomp}\index{textcomp@\textsf{textcomp}} 也是 \LaTeX\ 的標準巨集之一,他提供了許多符號,不必進入數學模式也是可以正常使用。但一般編譯的話,可能會使用到 pk 點陣字,如果有安裝 \texttt{cm-super}\index{cm-super@\texttt{cm-super}} Type1 字型的話,可以使用以下的編譯方式:
140 |
141 | \begin{quote}
142 | \begin{verbatim}
143 | latex example16.tex
144 | dvisp -Pcm-super example16.dvi
145 | ps2pdf example16.ps
146 | \end{verbatim}
147 | \end{quote}
148 |
149 | 這樣就會完全使用 Type1 字型。如果沒有安裝 \texttt{cm-super} Type1 字型,則可引用 \textsf{txfonts}\index{txfonts@\textsf{txfonts}} 或 \textsf{pxfonts}\index{pxfonts@\textsf{pxfonts}} 巨集套件。
150 |
151 | \verb|@{}| 如果完全沒有加入任何參數,那麼他的作用只是在去掉左右兩欄間距而已,大家可以把有關 \verb|@{}| 的部份拿掉,試著再編譯看看,仔細比較看有什麼不同。有些專業排版的專家建議把表格前後加個 \verb|@{}| 去除突出來的橫線(實際上就是去除原有左右兩邊間距的部份)。編譯好的例子在:
152 |
153 | \begin{quote}
154 | \url{http://edt1023.sayya.org/tex/latex123/example16.tex}\\
155 | \url{http://edt1023.sayya.org/tex/latex123/example16.pdf}
156 | \end{quote}
157 |
158 | 如果 \verb|@{}| 裡頭不是指令,而是文字或符號,那這個文字或符號會加在各欄文字內容的前或後。
159 |
160 | \verb|p{}| 指令的使用時機是某一個欄位的文字比較多,需限定欄位的寬度讓他自動折行的情形,例如以下的例子:
161 |
162 | \begin{quote}
163 | \begin{verbatim}
164 | % example17.tex
165 | \documentclass{article}
166 | \renewcommand{\arraystretch}{1.2} % 將表格行間距加大為原來的 1.2 倍
167 | \begin{document}
168 | \centering
169 | \section*{Yi Syllables Area Character Blocks}
170 | \begin{tabular}{@{}llp{6cm}@{}}
171 | \hline
172 | Start & End & Character Block Name \\
173 | \hline
174 | A000 & A48F & Yi Syllables.
175 | Yi also known as Lolo, is a script resembling Chinese
176 | in overall shaps that is used in the Yunnan province
177 | China. \\
178 | A490 & A4CF & Yi Radicals.
179 | Basic units of the Yi syllables. \\
180 | \hline
181 | \end{tabular}
182 | \end{document}
183 | \end{verbatim}
184 | \end{quote}
185 |
186 | 這樣會把 \verb|p{}| 指定的欄位當成一整個段落來處理,空一個空白行,同樣是表示新段落的開始。編譯好的例子如下:
187 |
188 | \begin{quote}
189 | \url{http://edt1023.sayya.org/tex/latex123/example17.tex}\\
190 | \url{http://edt1023.sayya.org/tex/latex123/example17.pdf}
191 | \end{quote}
192 |
193 |
194 | \section{array 巨集套件}
195 | \label{sec:array}\index{array@\textsf{array}}
196 |
197 | 這個巨集套件可以加強原有 \texttt{tabular}\index{tabular@\texttt{tabular}} 環境的功能。使用上只要引入 \textsf{array} 巨集套件即可,\texttt{tabular} 環境依原來的使用方法,只是多了些相關調整指令。
198 |
199 | \begin{enumerate}
200 | \item \verb|m{寬度}|\\
201 | 這和 \verb|p{}| 一樣的作用,只是置放的位置不一樣,此時其他欄位的內容會對齊這個段落的中央位置。
202 | \item \verb|b{寬度}|\\
203 | 同 \verb|p{}|,但其他欄位的內容會對齊整個段落的底部。
204 | \item \verb|>{指令}|\\
205 | 這可以置於 {\ttfamily l,r,c,p,m,b} 參數之前,是對於某個欄位的內容下指令,這個指令會在此一欄位內容之前作用。引用了 \textsf{array} package 後,可能會抑制某些 \verb|@{指令}| 的作用,此時要改用 \verb|>{指令}|,但這沒有去除欄位間距的功能,可在前頭再加個 \verb|@{}| 即可。
206 | \item \verb|<{指令}|\\
207 | 和 \verb|>{指令}| 相同,但會在此一欄位內容之後才作用。
208 | \item \verb|!{指令}|\\
209 | 這是取代 \verb+|+ 的作用,可以方便使用特殊符號來代替原來的縱線。
210 | \item \verb|\extrarowheight|\\
211 | 這是在調整欄位內容頂端的空間大小,但不會改變底部的空間大小。\index{extrarowheight@\verb=\extrarowheight=}
212 | \end{enumerate}
213 |
214 |
215 | \section{tabularx 巨集套件}
216 | \label{sec:tabularx}\index{tabularx@\textsf{tabularx}}
217 |
218 | \textsf{tabularx} 巨集套件提供一個 \texttt{tabularx} 環境,這是加強型的 \texttt{tabular} 環境,附在 \LaTeX\ 的工具組裡頭。主要作用是改善 \verb|\tabular*| 指令,指定表格寬度的功能。
219 |
220 | 在原始 \texttt{tabular} 環境,加了個星號,可以指定表格的寬度。但由於 \verb|\tabular*| 這個原始環境,他會去修改欄內空間,而不是實際整個表格方框的寬度,這使得某些文字會超出表格範圍,因此,使用上可能 \texttt{tabularx} 會比較方便,他提供了 {\ttfamily X} 參數來取代原來的 {\ttfamily lrc} 參數,這個參數實際的作用是 \verb|p{}| 的功能,因此會實際調整欄位方框的寬度,而且裡頭的文字敘述超過欄位寬度時會自動折行。這個套件會自動引入 \textsf{array} package\footnote{套件查詢,可使用第 \ref{sec:pkgwhere} 節,頁 \pageref{sec:pkgwhere},所提到的
221 | \htmladdnormallink{\texttt{ltxpkg.sh}}{http://edt1023.sayya.org/tex/latex123/ltxpkg.sh}\index{ltxpkg.sh@\texttt{ltxpkg.sh}}
222 | 來查詢是否有預先載入其他的 package{s}。}。這裡使用這兩種環境來排版,大家比較一下他的結果,就知道差異了:
223 |
224 | \begin{quote}
225 | \begin{verbatim}
226 | % example18.tex
227 | \documentclass{article}
228 | \usepackage{tabularx}
229 | \parindent=0pt
230 | \renewcommand{\arraystretch}{1.2}
231 | \begin{document}
232 | \centering
233 | \section*{\texttt{tabular*} environment}
234 | \begin{tabular*}{8cm}{lll}
235 | \hline
236 | Start & End & Character Block Name \\
237 | \hline
238 | 3400 & 4DB5 & CJK Unified Ideographs Extension A \\
239 | 4E00 & 9FFF & CJK Unified Ideographs \\
240 | \hline
241 | \end{tabular*}
242 | \section*{\textsf{tabularx} package}
243 | \begin{tabularx}{8cm}{llX} % 8cm 減去前兩個欄位寬度後,剩下的通通給
244 | \hline % 第三欄位使用,文字超出的部份會自動折行
245 | Start & End & Character Block Name \\
246 | \hline
247 | 3400 & 4DB5 & CJK Unified Ideographs Extension A \\
248 | 4E00 & 9FFF & CJK Unified Ideographs \\
249 | \hline
250 | \end{tabularx}
251 | \end{document}
252 | \end{verbatim}
253 | \end{quote}
254 |
255 | \textsf{tabularx} package 並不是都沒有缺點的,例如,使用 \verb|\verb|\index{verb@\verb=\verb=} 指令時會有一些不相容,另外,在 \texttt{tabularx} 環境內還要有其他的 \texttt{tabularx} 環境時,這個在裡頭的 \texttt{tabularx} 環境要由大括號括住,不能像 \texttt{tabular} 環境一下的直接巢狀使用。編譯好的例子在:
256 |
257 | \begin{quote}
258 | \url{http://edt1023.sayya.org/tex/latex123/example18.tex}\\
259 | \url{http://edt1023.sayya.org/tex/latex123/example18.pdf}
260 | \end{quote}
261 |
262 |
263 | \section{表格線條粗細的控制(booktabs)}
264 | \label{sec:booktabs}\index{booktabs@\textsf{booktabs}}
265 |
266 | 由前面幾節所述,可以看得出來 \LaTeX\ 表格巨集的功能稍嫌陽春了點,對於一些特殊狀況可能會無法處理,對於表格外觀要求較高的使用者也會感到不足,雖然也可以自行去定義巨集,但這樣一來不但可能有可攜性的問題,而且也不是每個人都有時間去學習 \TeX/\LaTeX\ 巨集的寫作。我們試圖來看看有沒有其他的解決方式,這裡不得不會提到一些外來的巨集套件,但這些套件的使用相當的普遍,幾乎可以忽略他的可攜性的問題。
267 |
268 | 我們前面曾學過 \verb|\arraryrulewidth|\index{arraryrulewidth@\verb=\arraryrulewidth=} 指令,可以調整線條的粗細,但是這無法各別調整線條,每個在 \texttt{tabular} 表格環境內的線條會調整成一樣的粗細。\textsf{booktabs}\index{booktabs@\textsf{booktabs}} 巨集套件可以很方便的達成這個目的。我們來看看這個提供了什麼方便的指令:
269 |
270 | \begin{quote}
271 | \begin{tabular}{ll}
272 | 指令 & 功能 \\
273 | \hline
274 | \verb|\toprule[線條粗細]| & 畫表格頂端的橫線 \\
275 | \verb|\midrule[線條粗細]| & 畫表格裡頭的橫線 \\
276 | \verb|\bottomrule[線條粗細]| & 畫表格底部的橫線 \\
277 | \verb|\cmidrule| & 指令某個欄位畫橫線,取代原來的 \verb|\cline|
278 | \end{tabular}
279 | \end{quote}
280 |
281 | 使用方法和 \texttt{tabular} 環境差不多,連環境名稱都一樣,但可在指令後加個方括號來指定線條的粗細,不指定的話,\texttt{toprule} 及 \texttt{bottomrule} 都會比中間的其他線條粗一點。其中 \texttt{cmidrule} 另有更進一步的功能:
282 |
283 | \begin{quote}
284 | \begin{verbatim}
285 | \cmidrule[線條粗細](左右是否去邊){畫線欄位}
286 | \end{verbatim}
287 | \end{quote}
288 |
289 | 其中「畫線欄位」和 \verb|\cline| 一樣,指定欄位數即可,例如 2--3。左右去邊要表明左({\ttfamily l})或/及右({\ttfamily r}),也可由大括號指定要去掉多少(預設 0.5em),如:\verb|(lr{0.7em}){2-3}|。我們把
290 | \htmladdnormallink{\texttt{example16}}{http://edt1023.sayya.org/tex/latex123/example16.tex}
291 | 拿來改一下,大家試著看看有什麼不同,編譯好的例子如下:
292 |
293 | \begin{quote}
294 | \url{http://edt1023.sayya.org/tex/latex123/example19.tex}\\
295 | \url{http://edt1023.sayya.org/tex/latex123/example19.pdf}
296 | \end{quote}
297 |
298 | 由於螢幕解析度的關係,如果分不出不同,請由印表機印出來比較,或將檔案放大再來觀察。這裡最粗的是 {\ttfamily toprule} 及 {\ttfamily bottomrule} 再來是 {\ttfamily midrule},最細的是 {\ttfamily cmidrule}。而且 \textsf{booktabs} 已經調整過原來 \texttt{tabular} 表格的上下間距,除非想得更大,不然的話,不需另外再去設定 \texttt{arraystretch} 的值了。
299 |
300 |
301 | \section{彩色表格(colortbl)}
302 |
303 | 彩色表格已經是很普遍,但千萬要小心喧賓奪主的情況,也別弄成了大花臉。因此,淡色系可能會比較合適。我們在第 \ref{subsubsec:package} 小節及
304 | \htmladdnormallink{\texttt{example13}}{http://edt1023.sayya.org/tex/latex123/example13.tex}
305 | 曾提到過 \textsf{color}\index{color@\textsf{color}} package 的引用,但並沒有詳細說明這個套件的用法,而 \textsf{colortbl}\index{colortbl@\textsf{colortbl}} 會使用到這些顏色的功能,因此這裡稍微說明一下。
306 |
307 | \subsection{color 巨集套件}
308 | \label{subsec:color}
309 |
310 | 這是附在 \LaTeX\ 工具組 \textsf{graphics}\index{graphics@\textsf{graphics}} package 中的一個巨集,使用上非常簡單,只要把 \textsf{color} 巨集在文稿 preamble\index{preamble} 區引上就可以使用顏色了。以下是常要用到的控制指令:
311 |
312 | \begin{quote}
313 | \begin{tabular}{lp{17em}}
314 | 指令 & 作用 \\
315 | \hline
316 | \verb|\color{顏色}| & 這會使用文章所有內容都使用這個顏色 \\
317 | \verb|\definecolor| & 定義顏色 \\
318 | \verb|\textcolor{顏色}{文字內容}| & 讓文字內容使用某特定顏色 \\
319 | \verb|\pagecolor{顏色}| & 這是在設定背景顏色,本頁及其後的頁面會使用這個背景顏色 \\
320 | \verb|\normalcolor{顏色}| & 回復原來的顏色 \\
321 | \verb|\colorbox{顏色}{文字內容}| & 這是方框背景的顏色 \\
322 | \verb|\fcolorbox{框色}{框內背景色}{文字內容}| & 這是方框顏色和其內背景顏色不同
323 | \end{tabular}
324 | \end{quote}
325 |
326 | 這裡要注意的是,指令裡頭使用的顏色,必需是有定義過的顏色才能使用。\textsf{color} 巨集只定義了一些基本顏色,\textcolor{red}{\bf r}ed, \textcolor{green}{\bf g}reen, \textcolor{blue}{\bf b}lue (RGB 模型原色\index{RGB 模型原色}), \textcolor{cyan}{\bf c}yan, \textcolor{magenta}{\bf m}agenta, \textcolor{yellow}{\bf y}ellow, blac{\bf k} (CMYK 模型原色\index{CMYK 模型原色}), white,另外一個常用的 gray 灰階模型(gray-scale\index{灰階模型}\index{gray-scale}),其他的顏色得自行定義。定義顏色的語法如下:
327 |
328 | \begin{quote}
329 | \begin{verbatim}
330 | \definecolor{顏色名稱}{色彩模型}{調色盤值}
331 | \end{verbatim}
332 | \end{quote}
333 |
334 | 第一個參數就是自訂的一個顏色名稱,色彩模型可使用 rgb、cmyk 或 gray,各顏色深淺值在 0--1 之間,「調色盤值」就是各種原色的值。RGB 顏色的索引值,如果是 Unix-like 系統,可找一下 \texttt{rgb.txt} 這個檔案,裡頭就會有各種顏色的索引值,或者,參考
335 | \htmladdnormallink{\texttt{example24.pdf}}{http://edt1023.sayya.org/tex/latex123/example24.pdf}。這裡以 bisque 這個顏色為例子,他的 rgb 三原色的深淺比例為 255, 228, 196,各除以 256 得 0.996, 0.891, 0.755,定義方法如下:\footnote{每一個原色在電腦上最小可由一個 byte(8-bits) 來儲存,共有 256($2^8$) 種變化,所以,三原色可調出 $256^3$ 共 16,777,216 種顏色,但這不表示你的螢幕、印表機有辦法顯示那麼多顏色。}
336 |
337 | \begin{quote}
338 | \begin{verbatim}
339 | \definecolor{bisque}{rgb}{.996,.891,.755}
340 | \definecolor{mypink}{cmyk}{.1,.8,.4,.1} % cmyk 模型的例子
341 | \end{verbatim}
342 | \end{quote}
343 |
344 | 這樣以後就可以使用 bisque 及 mypink 這兩種顏色了。gray 則支援灰階,可以增減他的顯現深淺,例如:
345 |
346 | \begin{quote}
347 | \begin{verbatim}
348 | \definecolor{mygray}{gray}{.6}
349 | 或直接定義及使用,不事先定義好顏色名稱:
350 | \textcolor[gray]{.3}{文字內容}
351 | \textcolor[rgb]{.2,.5,.7}{文字內容}
352 | \end{verbatim}
353 | \end{quote}
354 |
355 | 這樣 mygray 會得到淺灰色的效果,他的顏色名稱就是 mygray。直接定義及使用雖然也可以,但不建議這麼做,因為如果有兩個地方要使用同一種顏色時,又得重複定義一次。要注意的是 gray 不能直接使用,要先定義他的灰色度,其他顏色也不能這樣單純靠一個值來定義他的深淺度。通常我們引用的時候,會加入以下的選項參數:
356 |
357 | \begin{quote}
358 | \begin{verbatim}
359 | \usepackage[usenames,dvipsnames]{color}
360 | \usepackage{colortbl}
361 | \end{verbatim}
362 | \end{quote}
363 |
364 | 這樣就可以使用 \texttt{dvipsnam.def}\index{dvipsnam.def@\texttt{dvipsnam.def}} 這個檔裡頭所定義好的顏色,例如 Salmon, Orchid, BlueViolet\chdots{}等等,請自行查閱這個檔案內容,{\ttfamily dvipsnames} 這個參數也可以不用,只用 {\ttfamily usenames} 即可。這裡引用時請注意順序,\textsf{colortbl} 要在後面,原因是 \textsf{colortbl} 巨集會自動引入 \textsf{color} 及 \textsf{array} 這兩個巨集,但裡頭並沒有含任何選項參數,所以要搶先去宣告。
365 |
366 | \subsection{colortbl 的主要指令}
367 | \label{subsec:colortbl}
368 |
369 | \begin{quote}
370 | \begin{tabular}{ll}
371 | 指令 & 作用 \\
372 | \hline
373 | \verb=\columncolor= & 讓整個欄位著色 \\
374 | \verb=\rowcolor= & 整整個橫列著色 \\
375 | \verb=\arrayrulecolor{顏色}= & 指定線條的顏色 \\
376 | \verb=\doublerulesepcolor{顏色}= & 指定雙並線內間隔的顏色
377 | \end{tabular}
378 | \end{quote}
379 | \index{columncolor@\verb=\columncolor=}\index{rowcolor@\verb=\rowcolor=}%
380 | \index{arrayrulecolor@\verb=\arrayrulecolor=}%
381 | \index{doublerulesepcolor@\verb=\doublerulesepcolor=}
382 |
383 | 在這裡,\verb|\columncolor| 和 \verb|\rowcolor| 的參數是一樣的,他們的共同語法是:
384 |
385 | \begin{quote}
386 | \begin{verbatim}
387 | \columncolor[色彩模型]{顏色}[左緣突出長度][右緣突出長度]
388 | \end{verbatim}
389 | \end{quote}
390 |
391 | 我們現在就來看個實例,這裡頭有四個小例子,包括:灰階橫條、部份欄位著色、整個表格在著色背景及單一個表格內方框著色:
392 |
393 | \begin{quote}
394 | \url{http://edt1023.sayya.org/tex/latex123/example20.tex}\\
395 | \url{http://edt1023.sayya.org/tex/latex123/example20.pdf}
396 | \end{quote}
397 |
398 |
399 | \section{表格的註解(threeparttable)}
400 | \label{sec:3parttable}\index{表格!註解}
401 |
402 | 表格的註解比較麻煩,\LaTeX\ 把 \texttt{tabular} 環境視為一個單位,對裡頭的文字做腳註\index{腳註}的話,將會不翼而飛,有些巨集套件有辦法在表格內做腳註(例如 \textsf{longtable}\index{longtable@\textsf{longtable}} package),但卻是置於頁面底部,和一般內文的註腳混在一起,多數使用者希望的是能把註解就置於表格底部。解決的方法就是使用 \textsf{threeparttable}\index{threeparttable@\textsf{threeparttable}} package,暫時將表格的某部份分割出來。
403 |
404 | 如果你的 \textsf{threeparttable} package 的表現和這裡的例子有不一樣的情形,請更新這個套件,這篇文章使用的是 2003/06/13 v3.0 的版本。
405 |
406 | \begin{quote}
407 | \url{ftp://ctan.unsw.edu.au/tex-archive/macros/latex/contrib/misc.zip}
408 | \end{quote}
409 |
410 | 下載後解開壓縮檔,把 \texttt{threeparttable.sty} 拷貝至 \texttt{\$TEXMF/latex/misc} 目錄下,執行一下 {\ttfamily texhash}\index{texhash@\texttt{texhash}} 一下即可。他的環境名稱和套件名稱一樣,就是 {\ttfamily threeparttable}。把 {\ttfamily tabular} 及註解的指令和內容,通通包在 {\ttfamily threeparttable} 環境裡頭即可。
411 |
412 | 他是使用 \verb|\tnote{符號或文字}|\index{tnote@\verb=\tnote=} 先標出要註解的地方,在 \texttt{tabular} 環境結束後,再使用 \texttt{tablenotes}\index{tablenotes@\texttt{tablenotes}} 環境來寫註解內容,這兩個部份都是整個被 \texttt{threeparttable} 環境包住的。底下這個例子來自這個套件的作者 Donald Arseneau\index{Donald Arseneau},這裡把他和 \textsf{booktabs} package 結合起來用:
413 |
414 | \begin{quote}
415 | \url{http://edt1023.sayya.org/tex/latex123/example21.tex}\\
416 | \url{http://edt1023.sayya.org/tex/latex123/example21.pdf}
417 | \end{quote}
418 |
419 | 要注意的是,在 \texttt{tablenotes} 環境下,字體並沒有縮小,可參考 \texttt{example21} 裡頭,使用 \texttt{footnotesize} 的字體大小。
420 |
421 | \section{小數點對齊(dcolumn)}
422 | \label{sec:dcolumn}\index{dcolumn@\textsf{dcolumn}}\index{表格!小數點對齊}
423 |
424 | 這是 \LaTeX\ 的標準巨集,用於將表格內的小數點對齊。原來的 \texttt{tabular} 環境的作法是去增加一個欄位,那個欄位使用 \verb|@{.}| 來專門排小數點,這樣一來兩欄的間距會消掉,看起來就像連在一起的數字了,但這樣實在是有點 dirty,使用 \textsf{dcolumn} 巨集的話,就可以很有規律的去對齊小數點或逗點。
425 |
426 | \textsf{dcolumn} 的用法,主要是去取代 \texttt{tabular} 參數中的 \texttt{lrc} 這些參數。他使用的是一個大 D 指令,後接三個參數:
427 |
428 | \begin{quote}
429 | \begin{verbatim}
430 | D{文稿輸入符號}{排版後輸出之符號}{小數位數}
431 | \end{verbatim}
432 | \end{quote}
433 |
434 | 例如以下的表格我們再怎麼去排,小數點總是無法對齊,因為 \texttt{tabular} 環境是以整個字串在處理的:
435 |
436 | \begin{quote}
437 | \begin{verbatim}
438 | \begin{tabular}{lllll}
439 | \toprule
440 | & headA & headB & headC & headD \\
441 | \midrule
442 | test1 & 7.879 & 921.661 & 1382.81 & 998.98 \\
443 | test2 & 1.97 & 35.21 & 321.3 & 4791112.11 \\
444 | test3 & 211.97 & 5.2 & 213.629 & 748261594.106 \\
445 | \bottomrule
446 | \end{tabular}
447 | \end{verbatim}
448 | \end{quote}
449 |
450 | 我們只要把 \texttt{tabular} 的後面參數改成:
451 |
452 | \begin{quote}
453 | \begin{verbatim}
454 | ...
455 | \usepackage{dcolumn}
456 | ...
457 | \begin{tabular}{lD{.}{.}{3}D{.}{.}{3}D{.}{.}{3}D{.}{.}{3}}
458 | ...
459 | \end{verbatim}
460 | \end{quote}
461 |
462 | 就可以讓小數點對齊。這個 3 就是最長的小數位數,我們輸入、輸出都是英文句點(就是小數點),這樣的表示法也可以另外宣告 \verb|\newcolumntype| 的標準格式,以簡化 \texttt{tabular} 參數的輸入,即:
463 |
464 | \begin{quote}
465 | \begin{verbatim}
466 | ...
467 | \usepackage{dcolumn}
468 | ...
469 | \newcolumntype{z}[1]{D{.}{.}{#1}} % 定義一個新的 z 指令
470 | ...
471 | \begin{tabular}{lz{3}z{3}z{3}z{3}}
472 | ...
473 | \end{verbatim}
474 | \end{quote}
475 |
476 | 那個 \verb|#1| 就是 {\ttfamily z} 這個新指令的參數({\ttfamily z} 可以是任意的字母或符號),\verb|z{3}| 其實就是代表 \verb|D{.}{.}{3}|。中括號裡頭的 1 代表這個新的 {\ttfamily z} 後面只接一個參數,在這個例子裡就是小數點個數 3。以下是編譯好的例子:
477 |
478 | \begin{quote}
479 | \url{http://edt1023.sayya.org/tex/latex123/example22.tex}\\
480 | \url{http://edt1023.sayya.org/tex/latex123/example22.pdf}
481 | \end{quote}
482 |
483 | 這裡要特別注意的是,在 \textsf{dcolumn} 的效力範圍裡頭,例如以上例子,受 {\ttfamily z} 指令影響的欄位,他會自動進入數學模式,裡頭要表現數學式的話,前後不必再加 \verb|$|,否則會跳出數學模式。例如 {\ttfamily example22} 裡頭,那些 headA 會變成斜體字,這是因為進入了數學模式\index{數學模式},要讓他正常的話,就要寫成 \verb|$headA$| 這樣來跳出數學模式。
484 |
485 | \section{大型表格(longtable)}
486 | \label{sec:longtable}\index{longtable}\index{表格!大型表格}
487 |
488 | 這可能有兩種情形。一種是很寬的表格,另一種是很長的表格。太寬的表格可考慮旋轉一下,讓他橫放,至於長的表格可以使用 \textsf{longtable} 讓他可以跨頁連續。如果都不行,那只考慮夾頁,圖表另外製作,或者試著簡化圖表一途了。
489 |
490 | \subsection{太寬的表格}
491 |
492 | 要把表格橫放,方法很多,例如 \textsf{graphics} package 一起 release 的 \textsf{lscape}\index{lscape@\textsf{lscape}} 巨集套件,他會讓內文旋轉九十度,或者使用 \textsf{graphics/graphicx} package 本身的 \verb|\rotatebox|\index{rotatebox@\verb=\rotatebox=} 指令,將表格旋轉九十度。另外,也可以使用 \textsf{rotating}\index{rotating@\textsf{rotating}} package 來旋轉。這些 package 基本上使用的都是 \textsf{graphics/graphicx}\index{graphics@\textsf{graphics}}\index{graphicx@\textsf{graphicx}} 巨集上的旋轉指令的功能,所以,不限定只能使用在圖表而已。
493 |
494 | 這裡就以 \textsf{rotating} package 為例來說明,他提供了 \texttt{sidewaystable} 及 \texttt{sidewaysfigure}\index{sidewaystable@\texttt{sidewaystable}}\index{sidewaysfigure@\texttt{sidewaysfigure}} 環境,前者會讓表格旋轉九十度,後者會讓圖形旋轉九十度。這個套件會自動引用 \textsf{graphicx} 巨集,不使用這些套件,使用 \textsf{graphicx} 的 \verb|rotatebox{90}{表格}| 也是可以達到相同的功能,只不過限制會比較多。這裡舉一個 \textsf{rotating} 的例子,把表格置於 \texttt{sidewaystable} 環境內就行了:
495 |
496 | \begin{quote}
497 | \url{http://edt1023.sayya.org/tex/latex123/example23.tex}\\
498 | \url{http://edt1023.sayya.org/tex/latex123/example23.pdf}
499 | \end{quote}
500 |
501 | \subsection{太長的表格}
502 |
503 | 表格想跨頁,可以使用 {\ttfamily tabbing}\index{tabbing@\texttt{tabbing}} 表格,如果想使用 {\ttfamily tabular} 表格,又想可以跨頁的話,可以使用 {\sffamily longtable} package,這是 \LaTeX\ 所附上的工具組。他提供了 \texttt{longtable}\index{longtable@\textsf{longtable}} 環境來取代原來的 \texttt{tabluar}\index{tabluar@\texttt{tabluar}} 環境。如果想要和 \textsf{booktabs}\index{booktabs@\textsf{booktabs}} 合用的話,請更新 \textsf{booktabs} package 的版本,目前最新的版本是 2003/03/28 v1.618:
504 |
505 | \begin{quote}
506 | \url{ftp://ctan.unsw.edu.au/tex-archive/macros/latex/contrib/booktabs.zip}
507 | \end{quote}
508 |
509 | 我們把前面提到過的 {\ttfamily rgb.txt} 拿來排成表格參考,例子如下:
510 |
511 | \begin{quote}
512 | \url{http://edt1023.sayya.org/tex/latex123/example24.tex}\\
513 | \url{http://edt1023.sayya.org/tex/latex123/example24.pdf}
514 | \end{quote}
515 |
516 | \section{浮動環境}
517 | \label{sec:float}\index{浮動環境}
518 |
519 | \texttt{tabular} 表格,\LaTeX\ 都會把他視為一個獨立的 box\index{box},也就是會把他當成一個字母單位在處理,他不能被分割,常常因為圖表稍大些 \LaTeX\ 就會起新頁去置放,但這樣一來原本的頁面就會顯得空盪,整個版面看起來很不自然,這種情形下,他們的置放位置就很重要了,使用浮動環境的話,\LaTeX\ 會繼續文字的部份,而把圖表置放在下一頁的頂端。通常,在 \LaTeX\ 的浮動環境下,圖表通常會置放在一頁的頂端或都是底部,正常是不置放在一頁中間的位置,除非強迫指定,有放不下的情形時,就會讓他佔一整頁。因此,\LaTeX\ 就得把前後位置經過整體的計算後再來決定圖表應該置放在什麼地方,這就是所謂的浮動環境。\footnote{這篇文章並不使用浮動環境,因為這篇文章的原先構想是一種講義形式的文件,並非一份正式的文件格式。所以這篇文章中,圖表並無 caption,他們的位置是當做一般文字內容排版的,為了敘述的連續性,圖表都可能置於一頁中央。}
520 |
521 | \subsection{基本的浮動環境}
522 |
523 | \LaTeX\ 的浮動環境很簡單,就是把表格置於 \texttt{table} 環境當中就可以了。在裡頭有 \verb|\{caption}|\index{caption@\verb=\caption=} 指令可以指定表格的標頭,而且編譯後會自動標上 `Table n:' 字樣,後接 caption 的內容,那個 n 會自動編號。
524 |
525 | 一般國際上較正式的文件,caption 置放的位置慣例是「表上圖下」,也就是說表格的標題是置於表格上方,圖形則在下方。但 \LaTeX\ 對 caption 的置放位置,是對於不管圖表皆置於下方的配置,我們把 caption 置於上方時,caption 和表格的間距將會太小。如果不想手動去調整,可以找 \textsf{topcapt}\index{topcapt@\textsf{topcapt}} package 試試看。手動修改的方法如下:
526 |
527 | \begin{quote}
528 | \begin{verbatim}
529 | ...
530 | \begin{table} % 進入浮動環境
531 | \begin{table}[置放位置選項]
532 | \setlength{\abovecaptionskip}{0pt}
533 | \setlength{\belowcaptionskip}{10pt}
534 | \caption{表格的標題}
535 | \begin{tabular}{表格參數}
536 | 表格內容
537 | \end{tabular}
538 | \end{table}
539 | \end{verbatim}
540 | \end{quote}
541 |
542 | 原始的定義,{\ttfamily abovecaptionskip} 和 {\ttfamily belowcaptionskip} 的值剛好相反。如果是兩欄排版時,要加個星號,\verb|\begin{table*}...\end{table*}|。
543 |
544 | \subsection{浮動環境選項參數}
545 |
546 | \LaTeX\ 的浮動環境的配置,有時會不符和我們實際上的期望,這時可加入選項參數。
547 |
548 | \begin{quote}
549 | \begin{tabular}{>{\ttfamily }lp{24em}}
550 | 位置選項 & 作用 \\
551 | \hline
552 | h(here) & 置於下指令處位置 \\
553 | t(top) & 置於一頁的頂端 \\
554 | b(bottom) & 置於本頁底部,如空間不夠會置於次頁 \\
555 | p(page) & 單獨佔一頁,此頁沒有內文的部份 \\
556 | \verb|\suppressfloats[位置]| & 抑制浮動物件置放於本頁的某處,他會出現在次頁 \\
557 | ! & 置於以上選頁之前,會更強烈要求達到此選項的作用。但對 {\ttfamily p} 則無作用
558 | \end{tabular}
559 | \end{quote}
560 |
561 | 如果都沒有指定,那預設是 \verb|[tbp]|。其中 \verb|\suppressfloats[位置]| 只能指定 {\ttfamily t} 或 {\ttfamily b},不能同時指定好幾個,而且 {\ttfamily !} 的作用會優先,他會忽略 \verb|\suppressfloats|\index{suppressfloats@\verb=\suppressfloats=} 的指示。這些指示,\LaTeX\ 經過整體計算後,如果覺得窒礙難行的話,仍然會「抗命行事」的,畢竟他要以大局為重。
562 |
--------------------------------------------------------------------------------
/contents/chapter10.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{數學排版}
4 | \label{ch:math}\index{數學排版}
5 |
6 | 好啦!這章是 \LaTeX{} 的拿手把戲了。就讓我們就來見識一下 \LaTeX{} 的威力吧!光這一章的內容就可以寫一本厚厚的書了,所以,只能點到為止,先小酌一番。這一章的內容,他們排版精確性,以 PDF 格式的內容為準,HTML 格式的內容,僅供參考。
7 |
8 | 對於較複雜的數學式子,除非是自行定義巨集,否則 \LaTeX{} 內建所提供的排版數學式子的能力可能會有不足,這時可以使用美國數學協會所開發的 \AmS{}-\LaTeX{}\index{AmS-LaTeX@\AmS{}-\LaTeX{}} 巨集套件,目前所有的 \TeX{} 發行版本應該都會附上,而且也會附上另一套 {\sffamily AMSFonts} 巨集套件及其字型。這個套件的使用,這裡並不做詳細的說明,只在必要的時候附帶提及,可以另外參考系統上所附的 {\ttfamily amsldoc.dvi} 文件及 \textit{The \LaTeX{} Companion} 這本書第八章,這個部份網路上可以抓得到,檔名是 {\ttfamily ch8.pdf},CTAN 有收錄:
9 |
10 | \begin{quote}
11 | \url{http://www.ctan.org/tex-archive/info/companion-rev/ch8.pdf}
12 | \end{quote}
13 |
14 | \section{進入數學模式(math mode)的方法}\index{數學模式(math mode)}
15 |
16 | 我們平常寫文章的模式無法正確處理數學式子間的空間位置,而且要鍵入次方、方根、積分 \chdots{} 等等符號,會有困難,因此,所有的數學式子都得進入數學模式來處理。在數學模式下,不僅大部份文字、符號會採用斜體字,而且空間會另做安排,額外的空白會被 \LaTeX{} 忽略,在數學模式中要鍵入一般的正常文字,要退出數學模式,或者由 \verb|\mbox{}| 或 \verb|\textmr{}| 包圍起來才行。
17 |
18 | \LaTeX{} 的數學模式有兩種,一種是和內文排列在一起的隨文數式(math inline mode),他是和一般正常文字混在一起排版的;另外一種是獨立的展式數式(math display mode),他會單獨成一行,而且上下會和正常文字有一定的空間來區隔。
19 |
20 | \subsection{隨文數式(math inline mode)}
21 | 這是在夾雜在一般文章內的數學式子,是隨著整個文章段落一起排版的。\index{隨文數式(math inline mode)}
22 |
23 | \begin{enumerate}
24 |
25 | \item \verb|$ 數學式子 $| \newline
26 | 其實,我們在前面的章節的例子裡,就已經常常在使用了,只是沒有詳細說明。由兩個錢字符號 {\ttfamily \$} 所包圍的內容就會進入隨文的數學模式,在一般文字段落內要使用到一些數學式子的話,這是最方便的方法。為什麼是使用錢字符號?因為 Knuth\index{Knuth} 教授認為數學是很「昂貴」的!真正文章中要寫錢字符號時,要把他 escape,寫成 \verb|\$|,大概是指,平常不必把錢看得太重的意思吧(這是我猜的)!:-)
27 |
28 | \item \verb|\begin{math} 數學式子 \end{math}| \newline
29 | 如果數學式子很長,那麼使用環境的方式亦可。但是這個環境和一般的環境不同的是,他不會在上下行區隔出來,而是隨著其他正常文字一起排版的。要非常注意的是,在這個環境的上下行不要留空白行,否則會另起段落排版,那就不是我們所要的隨文數式了。
30 |
31 | \item \verb|\( 數學式子 \)| \newline
32 | 這是 \verb|\begin{math} 數學式子 \end{math}| 省略寫法。
33 |
34 | \end{enumerate}
35 |
36 | 我們來試試看,到底進入數學模式和不進入數學模式會有什麼不同:
37 |
38 | \begin{quote}
39 | \begin{verbatim}
40 | f(x,y)=3x+4y % 不進入數學模式
41 | f(x, y) = 3x + 4y % 不進入數學模式,空白是有作用的
42 | $f(x,y)=3x+4y$ % 進入數學模式
43 | $f(x, y) = 3x+ 4y$ % 數學模式中留不留空白,及留幾個空白,作用都一樣
44 | sin(2x)=-sin x cos x % 這樣排版出來會慘不忍睹喔!
45 | $\sin (2x) = -\sin x \cos x$
46 | f(x,y) = 3(x+y)y / (2xy-7) % 這樣排版出來也是會慘不忍睹!
47 | $f(x,y) = 3(x+y)y / (2xy-7)$
48 | \end{verbatim}
49 | \end{quote}
50 |
51 | 排版出來的結果會是:
52 |
53 | \begin{quote}
54 | \begin{tabular}{ll}
55 | 誤 & 正 \\
56 | \hline
57 | f(x,y)=3x+4y & $f(x,y)=3x+4y$ \\
58 | f(x, y) = 3x + 4y & $f(x, y) = 3x + 4y$ \\
59 | sin(2x)=-sin x cos x & $\sin (2x) = -\sin x \cos x$ \\
60 | f(x,y) = 3(x+y)y / (2xy-7) & $f(x,y) = 3(x+y)y / (2xy-7)$
61 | \end{tabular}
62 | \end{quote}
63 |
64 | 可以看得出來,英文字的部份變成斜體字了,而且加號、逗點、等號前後的空白也不一樣。但是函數名則還是使用正常字體,這在後面第 \ref{subsec:mathrules} 會談到數學模式中的遊戲規則。
65 |
66 | \subsection{展式數式(math display mode)}
67 | \index{展式數式(math display mode)}
68 |
69 | 通常獨立的數學式子,我們不會使用一般文章一樣的做法去換行,而是讓他進入展式數式的數學模式,他會獨立成一行,有需要的話也可以加入編號,以方便在文章中引用。和隨文數式另一個很大的不同是,展示數式會適當的選用較大的數學符號及字體,尤其是較複雜的數學式子的時候。
70 |
71 | \begin{enumerate}
72 |
73 | \item \verb|\begin{displaymath} 數學式子 \end{displaymath}| \newline
74 | 這會使數學式子獨立成一行。
75 |
76 | \item \verb|\[ 數學式子 \]| \newline
77 | 這種方式也可以,也比較常用。這兩種的展示數式都不會編號。
78 |
79 | \item \verb|\begin{equation} 數學式子 \end{equation}| \newline
80 | 這種使用方式,亦會獨立成一行,而且會附上編號。{\ttfamily equation*} 則不附編號。
81 |
82 | \end{enumerate}
83 |
84 | 使用展式數式要注意的是和上下文章不要空出空白行出來,裡頭也不要空出空白行。請不要使用 \TeX{} 裡頭的 {\ttfamily \$\$} 指令,這在 \LaTeX{} 並沒有完整去重定義他,這在某些 \LaTeX{} 指令的效果上會沒有作用。
85 |
86 | \subsection{在數學模式中的一些遊戲規則}
87 | \label{subsec:mathrules}
88 |
89 | 在數學模式中,由於一些空間的安排和一般文章段落不一樣,因此在編輯文稿時,會有一些地方需要注意。
90 |
91 | \begin{enumerate}
92 |
93 | \item 關於標點符號 \newline
94 | 在數學模式中,我們要注意一下標點符號的問題,一般而言,數學式後面如果有標點符號,在隨文數式,這個標點符號不能納入數學模式中;反之,在展式數式的場合,這些標點符號則要納入數學模式中。例如:
95 |
96 | \begin{quote}
97 | \begin{verbatim}
98 | Let $f(x)=\sqrt[4]{x+1}$ and $g(x)=\sqrt{9-x^2}$,... % 逗點不納入數學模式
99 | Let
100 | \[
101 | f(x)=\sqrt[4]{x+1}
102 | \]
103 | and
104 | \[
105 | g(x)=\sqrt{9-x^2}, % 逗點納入數學模式,標點符號也獨立成行
106 | \]
107 | ...
108 | \end{verbatim}
109 | \end{quote}
110 |
111 | 所以,展式數式,如果數學式最後有個句點或逗點的話,請不要懷疑,你搞對了!:-)
112 |
113 | \item 數學模式的斜體字 \newline
114 | 數學模式裡頭,預設會使用斜體字,但這些斜體字是數學斜體,和一般文章中的斜體是不一樣的,他字母間的距離比較寬,也沒有所謂的連體字(ligature)\index{連體字(ligature)},因此,如果需要這些效果,可以指定要使用斜體字,這樣就會表現和一般文章一樣的斜體了。例如:
115 |
116 | \begin{quote}
117 | \begin{verbatim}
118 | \textit{proffer} normal italic. % 正常文章的斜體
119 | $proffer\ math\ mode\ iatlic.$ % 數學斜體
120 | $\textit{proffer\ math\ mode\ normal\ italic.}$ % 指定為正常斜體
121 | \end{verbatim}
122 | \end{quote}
123 |
124 | 表現出來會是:
125 |
126 | \begin{quote}
127 | \textit{proffer normal italic.} \\
128 | $proffer\ math\ mode\ iatlic.$ \\
129 | $\textit{proffer\ math\ mode\ normal\ italic.}$
130 | \end{quote}
131 |
132 | 當然,這種情形很少發生,正常排版的話,無需特別去指定使用一般文章的斜體。
133 |
134 | \item 例外不使用斜體字的情形 \newline
135 | 一般函數名是不使用斜體字的,例如 log、三角函數名 \chdots{} 等等,為了避免失誤打錯,可以直接使用指令的方式,例如 \verb|\log|、\verb|\sin|、\verb|\tan|\chdots{}等等,這樣雖然是在數學模式中,也會使用一般的正常字體。\TeX{}/\LaTeX{} 系統提供了預先定義好的 32 種函數名供使用:
136 |
137 | \begin{quote}
138 | \begin{tabular}{lllllll}
139 | \verb|\arccos| & \verb|\cos| & \verb|\csc| & \verb|\exp| & \verb|\ker| & \verb|\limsup| & \verb|\min| \\
140 | \verb|\arcsin| & \verb|\cosh| & \verb|\deg| & \verb|\gcd| & \verb|\lg| & \verb|\ln| & \verb|\Pr| \\
141 | \verb|\arctan| & \verb|\cot| & \verb|\det| & \verb|\hom| & \verb|\lim| & \verb|\log| & \verb|\sec| \\
142 | \verb|\arg| & \verb|\coth| & \verb|\dim| & \verb|\inf| & \verb|\liminf| & \verb|\max| & \verb|\sin| \\
143 | \verb|\sinh| & \verb|\sup| & \verb|\tan| & \verb|\tanh| \\
144 | \end{tabular}
145 | \end{quote}
146 |
147 | 這樣往後只要是函數名就直接在數學模式中使用這些現成的指令就行了。當然,如果是這裡沒有涵蓋的函數名,就得自行加以注意了。
148 |
149 | 另外,單位名、化學元素、數字、簡寫縮寫文字等都不使用斜體字。但例外的例外,物理中的常數名則仍然是要使用斜體字,例如光速 \textit{c}。
150 |
151 | \item 不要加入換行指令或插入空白行 \newline
152 | 一個數學式子,在 \LaTeX{} 是視為一個單獨的單位或段落,而且,在這個特殊的段落裡,\LaTeX{} 會抑制 line break 及 page break 的機制,所以,除非是矩陣及矩陣方程式外,不能去強迫換行也不能插入空白行。
153 |
154 | \end{enumerate}
155 |
156 |
157 | \section{數學符號}
158 | \index{數學符號}
159 |
160 | 我們打字,通常是無法打出一些特殊數學符號,縱使字型裡頭有這種符號,但由於要和其他符號、文字調整他們的相對位置,因此,除了一些常用的運算符號外,數學符號通常是使用指令的方式來鍵入。我們在第 \ref{subsec:latexsym} 小節裡頭曾提到 {\ttfamily symbols-a4.pdf} 符號表,這個總表非常重要,幾乎羅列了目前所有可用的現成符號,並且會標明需要引入什麼 package,所以,這裡就不把符號表列出來,以節省篇幅。
161 |
162 | 當然,有些編輯器的巨集會設定好方便的按鈕方式來插入這些數學符號,但建議開始接觸的時候,多花點時間親自鍵入,等熟悉以後再來使用這種方便的設定來增加生產力。理由是,編譯錯誤或校稿修改時才知道要改什麼地方,連 \verb|\sum|、\verb|\infty|、\verb|\int| 是什麼符號都不知道的話,那麼要微調就變成很困難了,而且什麼地方錯誤也常會搞不清楚,這些後續的動作所花的時間,可能會比你剛開始學指令所花的時間還多。
163 |
164 |
165 | \section{各種數學式子的書寫方法}
166 |
167 | 我們這裡就正式來看看數學式子到底是如何書寫,這裡不做符號的列表,直接舉例子,如對相關符號指令的書寫有疑問,請自行查閱 {\ttfamily symbols-a4.pdf}。
168 |
169 | \subsection{分式(fraction)}
170 | \index{分式(fraction)}
171 |
172 | \begin{quote}
173 | \begin{tabular}{ll}
174 | 書寫方式 & 排版結果 \\
175 | \hline
176 | \verb|$f(x,y)=3(x+y)y/(2xy-7)$| & $f(x,y)=3(x+y)y/(2xy-7)$ \\
177 | \verb|$f(x,y)=\frac{3(x+y)y}{(2xy-7)}$| & $f(x,y)=\frac{3(x+y)y}{(2xy-7)}$ \\
178 | \end{tabular}
179 | \end{quote}
180 |
181 | 簡單的分式,直接使用 {\ttfamily /} 就可以了,否則就要使用 \verb|\frac{分子}{分母}|\index{frac@\verb=\frac=} 這個分式的的指令。我們可以看到,隨文數式為了和前後文配合,分式的情形會把字母、符號縮小,如果太複雜的分式,就不適合使用隨文數式了,要把他單獨列出來:
182 |
183 | \begin{quote}
184 | \begin{verbatim}
185 | \[
186 | f(x,y)=\frac{3(x+y)y}{(2xy-7)}
187 | \]
188 | \begin{equation} % 有編號的情形
189 | f(x,y)=\frac{3(x+y)y}{(2xy-7)}
190 | \end{equation}
191 | \end{verbatim}
192 | \end{quote}
193 |
194 | 這樣,排版出來的結果是:
195 | \begin{quote}
196 | \[
197 | f(x,y)=\frac{3(x+y)y}{(2xy-7)}
198 | \]
199 | \begin{equation}
200 | f(x,y)=\frac{3(x+y)y}{(2xy-7)}
201 | \end{equation}
202 | \end{quote}
203 | 請注意,和上下行的原來文字不要有空白行,展式數式會自動處理。更複雜的分式的例子:
204 |
205 | \begin{quote}
206 | \begin{verbatim}
207 | \[
208 | \frac{\frac{a}{x-y}+\frac{b}{x+y}}{\frac{x-y}{x+y}+\frac{a-b}{a+b}}
209 | \]
210 | \end{verbatim}
211 | \end{quote}
212 |
213 | 排版出來的結果是:
214 | \begin{quote}
215 | \[
216 | \frac{\frac{a}{x-y}+\frac{b}{x+y}}{\frac{x-y}{x+y}+\frac{a-b}{a+b}}
217 | \]
218 | \end{quote}
219 | 如果覺得,字體似乎太小了,可以指定字體:
220 |
221 | \begin{quote}
222 | \begin{verbatim}
223 | \[
224 | \frac{\frac{\displaystyle a}{\displaystyle x-y}+
225 | \frac{\displaystyle b}{\displaystyle x+y}}
226 | {\frac{\displaystyle x-y}{\displaystyle x+y}+
227 | \frac{\displaystyle a-b}{\displaystyle a+b}}
228 | \]
229 | \end{verbatim}
230 | \end{quote}
231 |
232 | 排版出來的結果是:
233 | \begin{quote}
234 | \[
235 | \frac{\frac{\displaystyle a}{\displaystyle x-y}+
236 | \frac{\displaystyle b}{\displaystyle x+y}}
237 | {\frac{\displaystyle x-y}{\displaystyle x+y}+
238 | \frac{\displaystyle a-b}{\displaystyle a+b}}
239 | \]
240 | \end{quote}
241 | 可指定的字體大小有:
242 |
243 | \begin{quote}
244 | \begin{tabular}{ll}
245 | \verb|\displaystyle| & 展示數式的標準字體大小 \\
246 | \verb|\textstyle| & 隨文數式的標準字體大小 \\
247 | \verb|\scriptstyle| & 第一層上下標字體大小 \\
248 | \verb|\scriptscriptstyle| & 第二層上下標字體大小
249 | \end{tabular}
250 | \end{quote}
251 |
252 |
253 | \subsection{上下標}
254 | \index{上下標}
255 |
256 | \begin{quote}
257 | \begin{tabular}{ll}
258 | 書寫方式 & 排版結果 \\
259 | \hline
260 | \verb|$(a+b)^2=a^2+2ab+b^2$| & $(a+b)^2=a^2+2ab+b^2$ \\
261 | \verb|$\cos 2x=\cos^2x-\sin^2x$| & $\cos 2x=\cos^2x-\sin^2x$ \\
262 | \verb|$(y^m)^n=y^{mn}$| & $(y^m)^n=y^{mn}$ \\
263 | \verb|$^a_bY^c_d$| & $^a_bY^c_d$ \\
264 | \verb|$e^{t \cos\theta}$| & $e^{t \cos\theta}$ \\
265 | \verb|$\lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}$| & $\lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}$ \\
266 | \verb|$y_1=1/3(x_1+\omega x_2+\omega^2x_3)$| & $y_1=1/3(x_1+\omega x_2+\omega^2x_3)$
267 | \end{tabular}
268 | \end{quote}
269 |
270 | 需要注意的是,不管是上下標,如果裡頭有兩個以上的字元都要當做上下標時,要使用大括號把他括住,否則會只作用在第一個字元而已。而且,上下標是左右兩邊都能標註的。這裡的 \verb|\to| 指令,是 \verb|\rightarrow| 的簡寫,就是向右的單箭號。相對的向左的單箭號 \verb|\leftarrow|,他的簡寫是 \verb|\gets|。
271 |
272 | 另外,像 \verb|\sum|、\verb|\lim|、\verb|\int| 這類符號,如果是在展示數式的時候,他的上下標的表現會和隨文數式不一樣,符號也會比較大,例如:
273 |
274 | \begin{quote}
275 | \begin{verbatim}
276 | \[
277 | \lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}\sin\frac{k}{n}
278 | \]
279 | \end{verbatim}
280 | \end{quote}
281 |
282 | 表現出來會變成:
283 | \begin{quote}
284 | \[
285 | \lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}\sin\frac{k}{n}
286 | \]
287 | \end{quote}
288 |
289 | \subsection{根號}
290 | \index{根號}
291 |
292 | \begin{quote}
293 | \begin{tabular}{ll}
294 | 書寫方式 & 排版結果 \\
295 | \hline
296 | \verb|$\sqrt{x^2+y^2}$| & $\sqrt{x^2+y^2}$ \\
297 | \verb|$\sqrt[5]{a+\sqrt{b}}$| & $\sqrt[5]{a+\sqrt{b}}$
298 | \end{tabular}
299 | \end{quote}
300 |
301 | \section{矩陣(array)}
302 | \index{矩陣(array)}
303 |
304 | 矩陣的排版方式和第 \ref{sec:tabular} 節所談的 tabular 表格類似,也是以 {\ttfamily \&} 來區隔欄位,以 \verb|\\| 來換行,只不過,矩陣的情形是在數學模式裡頭。
305 |
306 | 其中的分界符號(delimiter)\index{分界符號(delimiter)},在 \LaTeX{} 是由 \verb|\left| 及 \verb|\right| 指令來引導,這些分界符號會隨裡頭式子的多寡,自動調整大小。至於有什麼分界符號可以使用,也請自行查一下 {\ttfamily symbols-a4.pdf}。我們來看例子:
307 |
308 | \begin{quote}
309 | \begin{verbatim}
310 | \[
311 | A = \left( % 視 \left 後面跟的是什麼分界符號,就是使用什麼
312 | \begin{array}{clr}
313 | t_{11} & t_{12} & t_{13} \\
314 | t_{21} & t_{22} & t_{23} \\
315 | t_{31} & t_{32} & t_{33}
316 | \end{arrary}\right)
317 | \]
318 | \end{verbatim}
319 | \end{quote}
320 |
321 | 排版結果是:
322 | \begin{quote}
323 | \[ A = \left(
324 | \begin{array}{clr}
325 | t_{11} & t_{12} & t_{13} \\
326 | t_{21} & t_{22} & t_{23} \\
327 | t_{31} & t_{32} & t_{33}
328 | \end{array}\right) \]
329 | \end{quote}
330 | 是不是和排版表格一樣呢?指定的位置 {\ttfamily lcr} 的意思,和排版表格時是一樣的。如果右邊不需分界號,那麼可以使用 \verb|\right.| 來代替,例如:
331 |
332 | \begin{quote}
333 | \begin{verbatim}
334 | \[
335 | g(x,y) = \left\{\begin{array}{ll}
336 | f(x,y), & \mbox{if $xy$} \\ % 包住,讓他使用正常字體
338 | 0, & \mbox{otherwise.}
339 | \end{array} \right.
340 | \]
341 | \end{verbatim}
342 | \end{quote}
343 |
344 | 排版的結果是:
345 | \begin{quote}
346 | \[
347 | g(x,y) = \left\{\begin{array}{ll}
348 | f(x,y), & \mbox{if $xy$} \\
350 | 0, & \mbox{otherwise.}
351 | \end{array} \right.
352 | \]
353 | \end{quote}
354 |
355 | \AmS-\LaTeX{}index{AmS-LaTeX@\AmS-\LaTeX} 另外提供了 {\ttfamily matrix}\index{matrix@\texttt{matrix}} 環境,這是沒有分界符號的,另外有固定分界符號的環境:
356 |
357 | \begin{quote}
358 | \begin{tabular}{>{\ttfamily }ll>{\ttfamily }ll}
359 | 環境 & 分界符號 & 環境 & 分界符號 \\
360 | \hline
361 | matrix & 無分界號 & bmatrix & 方括號 {\ttfamily [ ]} \\
362 | pmatrix & 小括號 {\ttfamily ( )} & Bmatrix & 大括號 {\ttfamily \{ \}} \\
363 | vmatrix & 單垂直線 {\ttfamily | |} & Vmatrix & 雙垂直線 {\ttfamily || ||}
364 | \end{tabular}
365 | \end{quote}
366 |
367 | 這樣就可以不必使用 \verb|\left| 及 \verb|\right| 來引導出分界符號,我們把上面的例子再排版一次:
368 |
369 | \begin{quote}
370 | \begin{verbatim}
371 | ...
372 | \usepackage{amsmath} % 要記得引用 amsmath 巨集
373 | ...
374 | \[
375 | A =
376 | \begin{pmatrix} % 使用小括號
377 | t_{11} & t_{12} & t_{13} \\
378 | t_{21} & t_{22} & t_{23} \\
379 | t_{31} & t_{32} & t_{33}
380 | \end{pmatrix}
381 | \]
382 | \end{verbatim}
383 | \end{quote}
384 |
385 | 排版出來的結果是:
386 | \begin{quote}
387 | \[
388 | A =
389 | \begin{pmatrix}
390 | t_{11} & t_{12} & t_{13} \\
391 | t_{21} & t_{22} & t_{23} \\
392 | t_{31} & t_{32} & t_{33}
393 | \end{pmatrix}
394 | \]
395 | \end{quote}
396 | 看起來會比較緊湊一點。{\ttfamily matrix} 環境仍然可以使用 \verb|\left| 及 \verb|\right| 來加上分界號。
397 |
398 | \subsection{矩陣方程式}
399 | \index{矩陣方程式}
400 |
401 | \LaTeX{} 有一個內建的 {\ttfamily eqnarray}\index{eqnarray@\texttt{eqnarray}} 環境,來排版矩陣方程式,但這個環境對數學式子的空間安排會有潛在的瑕疵,因此,許多 \LaTeX{} 專家建議使用 \AmS-\LaTeX{} 所提供的 {\ttfamily align}\index{align@\texttt{align}} 環境。因此,這裡只討論 {\ttfamily align} 環境。而且,使用 {\ttfamily align} 環境的好處是,每一個數學式子只需要一個 {\ttfamily \&} 即可,排版出來會依這個 {\ttfamily \&} 來對齊,如果有數個數學式在同一行,那各個數學式子也是使用 {\ttfamily \&} 來區隔。所有式子要向左對齊的話,只要把 {\ttfamily \&} 置於行首就可以了。
402 |
403 | {\ttfamily align} 環境中的每行數學式子都會加以編號,要不編號的話,可在每行數學式子換行符號前加個 \verb|\notag| 指令,這一行便不會編號,要所有的數學式子都不編號的話,就使用 {\ttfamily align*} 環境。要使用特別指定的符號來編號的話,可使用 \verb|\tag{符號}| 放在這一行的換行指令前。使用 {\ttfamily subequations} 環境則會有子編號。我們來看個例子:
404 |
405 | \begin{quote}
406 | \begin{verbatim}
407 | ...
408 | \usepackage{amsmath} % 要記得引用 amsmath package
409 | ...
410 | \begin{subequations} % 讓編號同數,但以英文小寫為子編號
411 | \begin{align} % 韓信點兵,同餘方程式
412 | x & \equiv 2 \pmod 3 \\ % 三三數之剩二
413 | x & \equiv 3 \pmod 5 \\ % 五五數之剩三
414 | x & \equiv 2 \pmod 7 % 七七數之剩二
415 | \end{align}
416 | \end{subequations}
417 | \end{verbatim}
418 | \end{quote}
419 |
420 | 排版出來的結果是:
421 | \begin{quote}
422 | \begin{subequations}
423 | \begin{align}
424 | x & \equiv 2 \pmod 3 \\
425 | x & \equiv 3 \pmod 5 \\
426 | x & \equiv 2 \pmod 7
427 | \end{align}
428 | \end{subequations}
429 | \end{quote}
430 |
431 |
432 | \section{定理}
433 | \index{定理}
434 |
435 | \LaTeX{} 有一個 \verb|\newtheorem|\index{newtheorem@\verb=\newtheorem=} 指令來定義,Theorem, Lemma, Definition\chdots{}等等環境,但他的功能算是滿陽春的,因此,這裡也附帶說明美國數學協會的 {\sffamily amsthm}\index{amsthm@\textsf{amsthm}} package 的使用,他仍然是建立在 \LaTeX{} 的 \verb|\newtheorem| 而來的,因此可以配合 \LaTeX{} 原有的定義。
436 |
437 | \subsection{原始 \LaTeX{} 的定義}
438 |
439 | 定理環境,在 \LaTeX{} 裡頭是要我們自行去指定環境名稱,他的語法是:
440 |
441 | \begin{quote}
442 | \begin{verbatim}
443 | \newtheorem{環境名稱}{定理名稱}[章節層次]
444 | \end{verbatim}
445 | \end{quote}
446 |
447 | 編號如要加入章節編號,可加入選項參數的部份,例如 {\ttfamily chapter} 則會按 chapter 的編號來成為定理、定義的編號。我們來看看實際的例子:
448 |
449 | \begin{quote}
450 | \begin{verbatim}
451 | ...
452 | \newtheorem{defi}{Definition} % 在 preamble 區先定義好環境名稱
453 | ...
454 | \begin{defi}
455 | Let $f$ be continuous on the half-open interval $[a, b)$ and suppose
456 | $\lim_{x\rightarrow b^-}|f(x)|=\infty$. Then,
457 | \[
458 | \int_a^bf(x)dx=\lim_{t\rightarrow b^-}\int_a^tf(x)dx
459 | \]
460 | provided this limit exists and is finite, in which case we say the
461 | integral converges. Otherwise, we say it diverges.
462 | \end{defi}
463 | \end{verbatim}
464 | \end{quote}
465 |
466 | 表現出來的將會是:
467 | \begin{quote}
468 | \begin{defi}
469 | Let $f$ be continuous on the half-open interval $[a, b)$ and suppose
470 | $\lim_{x\rightarrow b^-}|f(x)|=\infty$. Then,
471 | \[
472 | \int_a^bf(x)dx=\lim_{t\rightarrow b^-}\int_a^tf(x)dx
473 | \]
474 | provided this limit exists and is finite, in which case we say the
475 | integral converges. Otherwise, we say it diverges.
476 | \end{defi}
477 | \end{quote}
478 |
479 | 如果是定理的話,接著可能需要排版證明,我們可以直接使用 {\sffamily amsthm} package 的 {\ttfamily proof} 環境,來排版證明的部份。
480 |
481 | \subsection{amsthm 巨集套件}
482 |
483 | 我們在上一個小節裡頭看到了 \LaTeX{} 預設的定理、定義環境,但彈性很小,這裡我們來使用 {\sffamily amsthm}\index{amsthm@\textsf{amsthm}} 巨集套件,並且試著排版中文:
484 |
485 | \begin{quote}
486 | \begin{verbatim}
487 | ...
488 | \usepackage{CJK} % 引入 CJK 環境
489 | \usepackage{amsmath,amsthm,amssymb} % 引入 AMS 數學環境
490 | \theoremstyle{remark} % 內文使用正常字體
491 | \newtheorem{cdefi}{\bf 定義} % 改用粗體,預設 remark style 是斜體
492 | ...
493 | \begin{CJK}{Bg5}{hwmm}
494 | \begin{cdefi}
495 | 設函數 $f:[a,b]\rightarrow\mathbb{R}$ 為可微分,且 $(f')^2$ 為可積,則稱
496 | \[
497 | L(s)=\int^b_a\sqrt{1+(f'(x))^2}dx
498 | \]
499 | 為 $f$ 之圖形自點 $(a,f(a))$ 至點 $(b,f(b))$ 之弧 $s$ 的弧長。
500 | \end{cdefi}
501 | \end{CJK}
502 | \end{verbatim}
503 | \end{quote}
504 |
505 | 排版出來的結果是:
506 |
507 | \begin{quote}
508 | \includegraphics{cmath01}
509 | \end{quote}
510 |
511 | 其中 {\ttfamily theoremstyle} 有三種 style,{\ttfamily plain, difinition, remark},預設使用的是 {\ttfamily plain},即定理名稱會用粗體字,內文則是 italic 斜體字,但這在中文並不適當,所以改由 {\ttfamily remark} style 來排版。要注意的是定理環境內的 {\ttfamily plain} style 雖然使用 italic 字型,但他並沒有進入數學模式,因此裡頭的數學式子仍然要進入數學模式來排版。另外,實數的那個特殊符號 $\mathbb{R}$ 要引用 {\sffamily amssymb} package 才會有,這也是美國數學協會\index{美國數學協會}發展的。
512 |
513 |
514 | {\sffamily amsthm} 另提供了 \verb|\theoremstyle|\index{theoremstyle@\verb=\theoremstyle=} 給使用自行定義除了 {\ttfamily plain}、{\ttfamily definition} 及 {\ttfamily remark} 三種形式外的 style。另外,\LaTeX{} 本身的工具組也提供了一個 {\sffamily theorem} 巨集套件,能更有彈性的來細部微調,也有現成的指令,可以去改變所要使用的字體,可以參考系統上就有的 {\ttfamily theorem.dvi} 這個說明檔。
515 |
516 | \section{數學模式中的字型及空間調整}
517 |
518 | 我們前面已有談到調整數學模式字體大小的四個指令。這裡我們再來看看其他的調整指令。
519 |
520 | \subsection{數學字體的改變}
521 |
522 | 以下的指令,相信大家從他的簡寫就可以知道意思:
523 |
524 | \begin{quote}
525 | \begin{tabular}{lll}
526 | 指令 & 作用 & 實例 \\
527 | \hline
528 | \verb|\mathrm| & 正常字體 & $\mathrm{ABCabc}$ \\
529 | \verb|\mathtt| & 打字機字族 & $\mathtt{ABCabc}$ \\
530 | \verb|\mathbf| & 粗體字 & $\mathbf{ABCabc}$ \\
531 | \verb|\mathsf| & sans serif & $\mathsf{ABCabc}$ \\
532 | \verb|\mathit| & italic 斜體 & $\mathit{ABCabc}$ \\
533 | \verb|\mathcal| & 數學花體字 & $\mathcal{ABC}$
534 | \end{tabular}
535 | \end{quote}
536 |
537 | 其他的套件會有更多的不同字體,請參考系統裡頭的 {\ttfamily symbols-a4.pdf}。要注意的是,有些字型並不是都完全有各種字體組合,像花體字並沒有小寫字母。
538 |
539 | \subsection{數學模式中調整間距}
540 |
541 | 正常情況下,數學模式中的空間調整應不必使用者去操心,但程式畢竟不會思考,有些特殊場合仍然需要人為的調整。
542 |
543 | \begin{quote}
544 | \begin{tabular}{llll}
545 | 指令 & 作用 & 指令 & 作用 \\
546 | \hline
547 | \verb|\quad| & 空出一個 em 單位的空白 & \verb|\qquad| & 空出兩個 em 的空白 \\
548 | \verb|\,| & 加入 1/6 quad 的空白 & \verb|\!| & 減去 1/6 quad 的空白 \\
549 | \verb|\;| & 加入 5/18 quad 的空白 & \verb|\:| & 加入 2/9 quad 的空白
550 | \end{tabular}
551 | \end{quote}
552 |
553 | 其中 \verb|\,|、\verb|\quad| 及 \verb|\qquad| 可以用在一般的文字模式及數學模式,其他的只能使用在數學模式中。我們把上一個弧長定義的例子來試著調整一下:
554 |
555 | \begin{quote}
556 | \begin{verbatim}
557 | ...
558 | \begin{cdefi}
559 | 設函數 $f:[a,b]\rightarrow{\mathbb R}$ 為可微分,且 $(f')^2$ 為可積,則稱
560 | \[
561 | L(s)=\int^b_a\!\sqrt{1+(f'(x))^2}\,dx
562 | \]
563 | 為 $f$ 之圖形自點 $(a,f(a))$ 至點 $(b,f(b))$ 之弧 $s$ 的弧長。
564 | \end{cdefi}
565 | ...
566 | \end{verbatim}
567 | \end{quote}
568 |
569 | 排版出來的結果是:
570 |
571 | \begin{quote}
572 | \includegraphics{cmath02}
573 | \end{quote}
574 |
575 | 但是,要注意的是,如果文章有點長,數學式子也不少,那一定要注意整體的一致性,要調整的話就全文相同的地方都要去調整,否則就使用預設值就可以了,至少他不會太離譜。
--------------------------------------------------------------------------------
/contents/chapter11.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{一篇文章、一本書的完整結構}
4 | \label{ch:abook}
5 |
6 | 好了,寫文章最後也要整理成冊,這也是排版系統要負責的部份。如果只是簡單幾百、幾千字的小文章,那很容易,只要個文章題目,章節標題,那也就夠了。但如果是較正式的論文,那可能還有目錄、參考文獻、索引 \chdots{}等等,甚至一本書籍的話,也要有個封面,及送印刷廠時要用到的裁切記號(crop marks)\index{裁切記號(crop marks)}。如果要置放在網頁上的,那還得注意網路超連結互動的問題,所以,這些細節算是滿瑣碎的,但卻是必要的。
7 |
8 | 當然,個人也並不是什麼排版、印刷的專家,只能談談我所知道的事項,如果需要補充或修正,請有這方面經驗的朋友,不吝提供心得及指正。個人出版,這實際上不是夢,尤其網路發達的今日。
9 |
10 | \section{目錄(Contents)\index{目錄}\index{Contents}}
11 |
12 | 目錄的問題,如果不講究的話,使用 \LaTeX\ 預設的就行了。就像第 \ref{sec;toc} 節所舉的例子一樣。但如果要做調整的話,除非熟悉 \LaTeX\ 巨集的寫法、定義,否則就得使用現成的巨集套件,例如 {\sffamily minitoc}\index{minitoc@\textsf{minitoc}} 可讓目錄更緊湊,{\sffamily titletoc}\index{titletoc@\textsf{titletoc}} 更可做相當幅度的調整及美化。
13 |
14 | 在 \LaTeX\ 文稿內,\verb|\tablofcontents| 可以排版一般的章節目錄。\verb|\listoffigures| 指令可以排版圖目錄,\verb|\listoftables| 指令則可排版表目錄。但圖表的話是指有進入浮動環境,使用 \verb|\caption| 指令,有編號的圖表而言。請注意,這些目錄指令的置放位置會影響實際目錄出現的順序,沒有特殊需求的話,一般的順序是文、圖、表。
15 |
16 | \subsection{更改目錄標題名稱}
17 |
18 | 預設的情形下,在目錄開頭都會有個標題來引導,例如:\textbf{Contents}、\textbf{List of Figueres} 及 \textbf{List of Tables} 等,但是這在中文的情形看起來會不相稱,我們可以去更改預設值。更改 \LaTeX\ 預設值得視原來這個值是以什麼形式出現,在目錄是以指令定義的形式出現,所以我們要使用 \verb|\renewcommand| 這個指令去重定義他。
19 |
20 | 原來的這些 \textbf{Contents} 標題是怎麼「弄」出來的呢?如果手頭上沒有相當的參考書籍,可以參考他的原始定義,例如這篇文章是使用 {\ttfamily report} class,那麼找一下:
21 |
22 | \begin{quote}
23 | \begin{verbatim}
24 | /usr/share/texmf/tex/latex/base/report.cls % Unix-like 系統
25 | C:\texmf\tex\latex\base\report.cls % DOS/Windows 系統
26 | \end{verbatim}
27 | \end{quote}
28 |
29 | 這個檔(依安裝的地方不同,可能會有不同的路徑),搜尋 Contents 這個關鍵字,就可以發現,他們原來的定義是:
30 |
31 | \begin{quote}
32 | \begin{verbatim}
33 | \newcommand\contentsname{Contents}
34 | \newcommand\listfigurename{List of Figures}
35 | \newcommand\listtablename{List of Tables}
36 | \end{verbatim}
37 | \end{quote}
38 |
39 | 這樣就清楚了,我們要重指定的是 \texttt{contentsname}、\texttt{listfigurename} 及 \texttt{listtablename}。其他的情形請依此類推。現在我們來把他改成中文:
40 |
41 | \begin{quote}
42 | \begin{verbatim}
43 | \renewcommand\contentsname{目~錄~}
44 | \renewcommand\listfigurename{圖~目~錄}
45 | \renewcommand\listtablename{表~目~錄}
46 | \end{verbatim}
47 | \end{quote}
48 |
49 | 這裡以 {\sffamily CJK}\index{CJK@\textsf{CJK}} 巨集為例,由於我們需要中文環境,所以這些更改要放在 \texttt{CJK} 環境中,如果只是更改成其他英文字樣,那我們置於 preamble 區就可以了。
50 |
51 | \subsection{目錄的深度}
52 |
53 | 通常,有編號的章節或有 caption\index{caption} 的圖表才會編入目錄中,但如果想讓目錄的結構更細,那麼我們就得更改列入目錄的深度。目錄深度的表現形式是一種計數器(counter),他的名稱是 \texttt{tocdepth}。以這篇文章的 \texttt{report} class 為例,他的預設值是(請自行查一下 \texttt{report.cls}):
54 |
55 | \begin{quote}
56 | \begin{verbatim}
57 | \setcounter{tocdepth}{2}
58 | \end{verbatim}
59 | \end{quote}
60 |
61 | 所以會計算到 \texttt{subsection},以下的就不列入了(請參考第 \ref{subsec:chapstruc} 小節的章節深度標號)。我們只要在 preamble 區,使用 \verb|\setcounter| 指令去重新指定,就會改變他的目錄深度。
62 |
63 | \subsection{額外的目錄}
64 |
65 | 這是指沒有編入目錄,但想自行加進去的情形,例如:章節指令使用了星號就不會編號,圖表目錄沒有使用 \verb|\caption| 指令,也不編入目錄了,這時我們可以使用 \verb|\addcontentsline| 指令來把他們手動加進去。我們來看看文圖表的三種不同情況:
66 |
67 | \begin{quote}
68 | \begin{verbatim}
69 | \addcontentsline{toc}{章節名}{標題}
70 | \addcontentsline{lof}{figure}{標題}
71 | \addcontentsline{lot}{table}{標題}
72 | \end{verbatim}
73 | \end{quote}
74 |
75 | 這樣就會把這些納入目錄,但是,這還是沒有編號的。目錄中所顯示的頁數,就是這些指令(圖表)所在的頁數。
76 |
77 | \section{交互參照(Cross References)}
78 | \label{sec:ref}\index{交互參照}\index{Cross References}
79 |
80 | 所謂的參照,指的是在文章某處提及某個其他的章節,或某個頁數,甚至是某個圖表,某個數學式子及某個列舉項目,排版系統必需要有這樣的功能來自動達成這種效果,而 \LaTeX\ 本身提供了三個簡單易用的指令來自動處理,他會自動計算相對的章節、頁數。
81 |
82 | 當然,由於網路的發達,超連結上的交互參照也變得是不可或缺,但 \TeX/\LaTeX\ 畢竟是平面排版系統,並沒有這樣的原始功能,但我們可以經由巨集套件來達成這樣的目的,{\sffamily hyperef} 巨集套件就是為此而寫的,這樣就可以讓 \LaTeX\ 排版的結果去轉換成 PDF/HTML 格式的時候,也有超連結的功能。
83 |
84 | 廣義的來說,包括目錄的參照、文獻參照、註解的參照及外部檔案的參照(例如,參照某個外部檔案的某個章節)都是屬於交互參照的一部份,但這些議題我們另外單獨討論,因為他不在 \LaTeX\ 所提供的三個基本參照的指令範圍內。
85 |
86 | \subsection{一般的交互參照}
87 |
88 | \LaTeX\ 提供了三組基本參照的指令:
89 |
90 | \begin{quote}
91 | \begin{verbatim}
92 | \label{名稱} % 置放於要被引用之處,以一個名稱來標記他
93 | \ref{名稱} % 引用 \label 所標記處的章節
94 | \pageref{名稱} % 引用 \label 所標記處的頁數
95 | \end{verbatim}
96 | \end{quote}
97 |
98 | 這裡頭的名稱都是自行取名的,但為了避免重複,個人使用上一般使用上會加入章節或圖表的代號,例如:
99 |
100 | \begin{quote}
101 | \begin{verbatim}
102 | ...
103 | \section{\LaTeX\ 的文稿結構}
104 | \label{sec:struct}
105 | ...
106 | \begin{figure}
107 | \includesgrapics{fontstruct}
108 | \caption{字型的結構}
109 | \label{fig:struct}
110 | \end{figure}
111 | ...
112 | 請參考第 \ref{sec:struct} 節,頁 \pageref{sec:struct}。
113 | 請參考圖 \ref{fig:struct},頁 \pageref{fig:struct}。
114 | ...
115 | \end{verbatim}
116 | \end{quote}
117 |
118 | 這兩個 {\ttfamily struct} 代表不同的參照處,當然,盡量避免這種情形發生,可加入 {\ttfamily fontstruct} 之類的來區別,但前面冠上章節、圖表的簡名,有助於看文稿時清楚區別。請注意,其中 {\ttfamily sec:}、{\ttfamily fig:} 都不是必要的,只是這樣比較容易辨識,而且不容易名稱重複。
119 |
120 | 要非常注意的的幾個重點是:
121 | \begin{quote}
122 | \begin{enumerate}
123 | \item 有參照的文稿一定要編譯兩次才能正常顯示。
124 | \item 能編號的章節、圖表、列舉項目、數學式、定理才能參照,雖然他們不一定要編號。
125 | \item 圖表的參照 \verb|\label| 一定要在 \verb|\caption| 之後,不能在前。
126 | \end{enumerate}
127 | \end{quote}
128 |
129 | \subsection{超連結交互參照(hyperlink)}
130 |
131 | 這當然是要像 PDF/HTML 格式的檔案才有超連結交互參照的可能,像 {\ttfamily *.dvi}、{\ttfamily *.ps} 這類格式的檔案,先天上並沒有這種設計。而 \LaTeX\ 本身並沒有內建這種功能,我們可以使用 {\sffamily hyperref}\index{hyperref@\textsf{hyperref}} 巨集套件來達成這個目的。現在一般的 \TeX\ 發行版本應該都會附上這個巨集,如果沒有話,可以在以下網站下載、安裝:
132 |
133 | \begin{quote}
134 | \url{ftp://ftp.tug.org/pub/tex/hyperref/}
135 | \end{quote}
136 |
137 | 這個套件會讓原本 \LaTeX\ 有交互參照的地方,在製作成 PDF 格式時也會有超連結的功能。他的設定檔是 {\ttfamily hyperref.cfg},為了各種文稿使用上的彈性,可以把這個檔在工作目錄上建立一個,這樣會依這個設定檔來執行,可參考本文文稿的原始碼,裡頭會有一個設定檔供參考。當然也是可以在 preamble\index{preamble} 區來設定,但這就只能使用在特殊的文稿上了。
138 |
139 | 他的使用方法,這裡不多做說明,可以參考本文的原始碼裡頭的使用方法,或參考〈由 \TeX/\LaTeX 製作中文 PDF 檔〉一文:
140 |
141 | \begin{quote}
142 | \url{http://www.study-area.org/tips/latex/chpdf.html}\\
143 | \url{http://www.study-area.org/tips/latex/chpdf.pdf}
144 | \end{quote}
145 |
146 | 及 {\sffamily hyperref} 所附的使用手冊。
147 |
148 | \section{索引(index)}
149 | \label{sec:index}\index{索引}\index{index}
150 |
151 | 索引的排版方法上並不算困難,困難的是要選出哪個字詞需要索引,及把各個字詞加入索引指令。我們引用 \LaTeX\ 的標準巨集 \textsf{makeidx}\index{makeidx@\textsf{makeidx}},並在其他加上一個 \texttt{makeindex}\index{makeindex@\texttt{makeindex}} 指令,然後在文稿結束前印出索引,下 {\ttfamily printindex}\index{printindex@\texttt{printindex}} 就可以了。我們在需要編入索引的名詞後加上 \verb|\index{名詞}|\index{index@\verb+\index+} 經過編譯後就會自動把索引及其相對的頁數計算出來。
152 |
153 | \subsection{索引的結構及編譯}
154 |
155 | 我們來看看文稿裡頭要加入什麼要件:
156 |
157 | \begin{quote}
158 | \begin{verbatim}
159 | ...
160 | \usepackage{makeidx}
161 | \makeindex
162 | ...
163 | 要索引的名詞\index{要索引的名詞}
164 | ...
165 | \printindex % 一定要有這個指令才會印出索引
166 | \addcontentsline{toc}{chapter}{索引} % 把他加入目錄
167 | ...
168 | \end{verbatim}
169 | \end{quote}
170 |
171 | 編譯的的程序如下:
172 |
173 | \begin{quote}
174 | \begin{verbatim}
175 | latex your.tex
176 | makeindex your.idx
177 | latex your.tex
178 | \end{verbatim}
179 | \end{quote}
180 |
181 | \subsection{索引值的製作}
182 |
183 | 索引值(key)\index{索引!索引值}裡頭 \verb+|+、\verb|@| 及 \verb|!| 有特殊的意義,要索引他們時前面要加 {\ttfamily "} 來 escape 他。我們來看這些符號實際上有什麼作用:
184 |
185 | \begin{quote}
186 | \begin{tabular}{ll}
187 | \verb|abc\index{abc}| & 這是一般正常的索引 \\
188 | \verb|xyz\index{abc!xyz}| & 表示 xyz 是 abc 下的一個子索引 \\
189 | \verb+abc\index{abc|textit}+ & 表示這個索引值的頁數使用 italic 斜體排版 \\
190 | \verb|abc\index{abc@\textbf{abc}| & 表示索引值是 abc,但使用粗體排版 \\
191 | \verb|\'abc\index{abc@\'abc}| & 表示依 abc 來排序索引,而不是後面的 \'abc
192 | \end{tabular}
193 | \end{quote}
194 |
195 | 製作索引是需要細心與耐心的,這方面更詳細的資料可以參考系統上的 {\ttfamily makeindex.dvi} 及 {\ttfamily manpages.dvi}。要注意的是 \verb|\index{}| 最理想是緊接在要索引的名詞後,前後都不留空白,有多個 \verb|\index{}| 相連時亦同,這會讓文件維護增加困難,因此,視每個人的習慣,可以考慮索引在整篇文稿最後才加進去。這份文件也製作了簡單的索引,但這只是當個例子供參考,在製作上有點粗糙,因此,實際上可能會漏掉很多,而且,中文的處理仍有待加強。
196 |
197 | 製作索引的時候,他的表示法要細心的注意一下,前後相同索引值的表示法要一樣,例如 \verb|\index{abc@\textbf{abc}| 和 \verb|\index{abc@{\bf abc}| 這會造成兩個不同的索引,雖然印出來的是一樣。而且,\verb=\verb|abc|= 這種方式就行不通,因為 \verb=|= 這個符號在索引指令內有他的特殊作用,要改用其他的符號代替。如果是和 {\sffamily hyperref} 配合的話,\verb+abc\index{abc|textit}+ 也會行不通,因為 {\sffamily hyperref}\index{hyperref@\textsf{hyperref}} 對超連結的索引是自動加上 \verb=|hyperpage=,如果已經有 \verb=|textit= 了的話,就不會加上去了,這樣一來超連結的部份會被忽略,解決的方法只能去重定義索引方法,或在編譯出來的 {\ttfamily *.idx} 或 {\ttfamily *.ind} 上做另外處理。例如:
198 |
199 | \begin{quote}
200 | \begin{verbatim}
201 | abc\index{abc|textit}
202 | latex 編譯後的情形是:
203 | \indexentry{abc|textit}{143} % *.idx 檔
204 | 經 makeindex 編譯後的情形是:
205 | \item abc, \textit{143} % *.ind 檔
206 | 這樣只編號改變字體,並沒有超連結。而我們要的是:
207 | \item abc, \textit{\hyperpage{143}} % 這樣才能又變更編號字體又能超連結
208 | \end{verbatim}
209 | \end{quote}
210 |
211 | 這個議題比較深入一點,解決的方式可能需要大家一同來研究、研究,不是不能解決,而是方式在使用上是否方便的問題。
212 |
213 | 索引的處理,他的資訊實際上是產生在編譯後的 \texttt{*.idx} 檔裡頭,然後經由 \texttt{makeindex} 外部程式編譯後,轉換成 \texttt{*.ind},然後 {\ttfamily latex} 再次編譯的時候,才把這個 \texttt{*.ind} 引進來,這個 \texttt{*.ind} 其實就是一個 \LaTeX\ 的文稿,他把所有的索引值及頁數,包在一個 {\ttfamily theindex}\index{theindex@{\ttfamily theindex}} 環境中來引入排版的。
214 |
215 | 說明這些的用意就是暗示,我們可以由外部處理程式去動手腳,把索引的部份再「加工」,包括中文資料的處理也是一樣,下一節要談到的參考文獻的處理機制也是類似的情形,而這也就是為什麼 {\ttfamily latex} 要執行好幾次的原因,也正因為這樣,我們才有動手腳的機會,例如 {\ttfamily makeindex} 就有 {\ttfamily -s} 參數,可以接受外部的 style 檔,或者,如果工作目錄上有 {\ttfamily *.mst}(makeindex style)這個檔,也會優先去參考錈,這樣就可以產生不同形式的索引結果。當然,參考文獻可以另單獨的一個文獻外部檔,索引的話,目前則沒有辦法這樣做,是否可以比照參考文獻的做法,由外部檔案來處理呢?就請大家腦筋急轉彎一下了,這樣也可以讓文稿更容易維護。
216 |
217 | \subsection{更改索引標題}
218 |
219 | 預設的索引標題\index{索引!標題}是 \textbf{Index}\index{Index@\textbf{Index}},我們可以在 preamble\index{preamble} 區來更改他(中文的話,請放在本文區 \texttt{CJK} 環境內),例如,設要中文名稱的話,可更改為中文:
220 |
221 | \begin{quote}
222 | \begin{verbatim}
223 | \renewcommand\indexname{索~引}
224 | \end{verbatim}
225 | \end{quote}
226 |
227 |
228 | \section{參考文獻(Bibliography)}
229 | \label{sec:biob}\index{Bibliography}\index{參考文獻}
230 |
231 | 參考文獻可以經由 \LaTeX\ 內建的 \texttt{thebibliography}\index{thebibliography@\texttt{thebibliography}} 環境來製作。長篇文稿,也可以使用 Bib\TeX\index{BibTeX@Bib\TeX} 由外部檔案來製作。至於參考文獻的格式,就要符合邀稿單位的規格了,這裡不多做說明。
232 |
233 | \subsection{\texttt{thebibliography} 環境}
234 | \label{subsec:thebibliography}\index{thebibliography@\texttt{thebibliography}}
235 |
236 | 在進入 \texttt{thebibliography},編譯後他會自成一個獨立的章節,如果是 \texttt{article} 類別的文稿,他會自動印出 \textbf{Referrences}\index{Referrences@\textbf{Referrences}} 的字樣為標題,如果是 \texttt{report} 或 \texttt{book} 類別的文稿,他會印出 \textbf{Bibliography}\index{Bibliography@\textbf{Bibliography}} 的字樣為標題。
237 |
238 | 在 \texttt{thebibliography} 環境裡頭,他是由 \verb+\bibitem+\index{bibitem@\verb+\bibitem+} 指令來列出資料的,我們來看一下他的語法:
239 |
240 | \begin{quote}
241 | \begin{verbatim}
242 | \begin{thebibliography}{99} % 參考文獻印出之編號最寬為兩個字母寬
243 | \bibitem[標記一]{鍵值一} 參考資料一
244 | \bibitem[標記二]{鍵值二} 參考資料二
245 | ...
246 | \edn{thebibliography}
247 | \end{verbatim}
248 | \end{quote}
249 |
250 | 所謂的「標記」這是選項參數,如果沒有的話,則正常引用後會在甲用處使用阿拉伯數字外加方括號來顯示;如果有加入的話,引用後會使用所加入的標記來顯示。那個「鍵值」指的就是引用時的關鍵字,後面所接的「參考資料」就是書籍、論文等資訊。其中的 \verb+{99}+ 只表示在最後的參考文獻印出來的時候,最開始的編號統一在兩個字母寬,如果都沒有使用「標記」,那麼就是兩個數目字寬,如果有使用「標記」,那麼要設在最長標記的字母寬,否則印出時會無法對齊。
251 |
252 | 我們引用的時候是使用 \verb+\cite{鍵值}+\index{cite@\verb+\cite+} 這個指令,他會顯示參考資料中的編號值,且以方括號括起來。我們來看看一些設定及引用的例子,:
253 |
254 | \begin{quote}
255 | \begin{verbatim}
256 | \begin{thebibliography}{KDE} % 參考文獻中印出的編號最寬為三個字母寬
257 | \bibitem{KDEt} Knuth, D.E., \textit{The \TeX{}book},
258 | Reading, Massachusetts: Addison-Wesley, 1989.
259 | \bibitem[KDE]{KDEm} Knuth, D.E., \textit{The \MF{}book},
260 | Reading, Massachusetts: Addison-Wesley, 1986.
261 | ...
262 | \end{thebibliography}
263 | \end{verbatim}
264 | \end{quote}
265 |
266 | 參考文獻印出的結果請參考本文件後面關於參考資料的部份。至於引用方式及其引用情形如下(顏色的部份是因為使用 {\sffamily hyperref} 套件的超連結):
267 |
268 | \begin{quote}
269 | \begin{tabular}{ll}
270 | 引用方式 & 引用結果 \\
271 | \hline
272 | 請參考 \verb+\cite{KDEt}+ & 請參考 \cite{KDEt} \\
273 | 請參考 \verb+\cite[1989]{KDEt}+ & 請參考 \cite[1989]{KDEt} \\
274 | 請參考 \verb+\cite{KDEm}+ & 請參考 \cite{KDEm} \\
275 | 請參考 \verb+\cite[1986]{KDEm}+ & 請參考 \cite[1986]{KDEm} \\
276 | 請參考 \verb+\cite{KDEt,KDEm}+ & 請參考 \cite{KDEt,KDEm}
277 | \end{tabular}
278 | \end{quote}
279 |
280 | 如果你現在是在觀看 PDF 格式的檔案,那在 {\sffamily Xpdf}\index{Xpdf@\textsf{Xpdf}} 或 \textsf{Adobe Acrobat Reader}\index{Adobe Acrobat Reader@\textsf{Adobe Acrobat Reader}} 都可以使用滑鼠來點一下,看看真正在後面印出時是什麼樣子。再次強調,參考文獻的規格請依邀稿單位的要求,這裡所列出來的不是「標準」。
281 |
282 | \subsection{更改標題名稱}
283 |
284 | 前面已提到過更改目錄及索引的標題,同樣的方法,我們也可以更改參考資料的標題,只是要注意引用的文稿類別是什麼。
285 |
286 | \begin{quote}
287 | \begin{verbatim}
288 | \renewcommand\refname{參~考~資~料} % article 類別文稿
289 | \renewcommand\bibname{參~考~文~獻} % report/book 類別文稿
290 | \end{verbatim}
291 | \end{quote}
292 |
293 | \subsection{Bib\TeX\ 簡介}
294 | \label{subsec:bibtex}\index{BibTeX@Bib\TeX}
295 |
296 | 如果常常有寫論文的機會,整理出自己的一份參考文獻資料庫可以節省許多時間,正常情況下,使用 \texttt{bibtex} 來處理外部文獻檔案的情形,只有引用到的文獻才會印出來,這樣也就不必擔心印出一堆不相關的文獻了。另外一個好處是,這個參考文獻資料庫可以另外獨立維護,所有的文章都用這一份資料庫,這在維護上會很方便,也減少錯誤的機會。
297 |
298 | Bib\TeX\ 本身提供一個外部的 \texttt{bibtex}\index{bibtex@\texttt{bibtex}} 工具程式,在 \texttt{latex} 編譯過文稿後,再利用 \texttt{bibtex} 編譯一次文稿,最後再使用 \texttt{latex} 重編譯過。而參考文獻資料庫是按一定的格式寫於 \texttt{*.bib} 檔案裡頭,在文稿中則以 \verb+\bibliogrphy+ 指令來引入,編譯過程中自然會去參考這個外部考文獻資料庫。他的使用情形如下(以 \texttt{your.bib} 為例):
299 |
300 | \begin{quote}
301 | \begin{verbatim}
302 | ...
303 | \begin{document}
304 | \bibliogrphiystyle{plain} % 指定 style 檔
305 | ...
306 | \bibliography{your.bib} % *.bib 延伸檔名可以省略
307 | ...
308 | \end{document}
309 | 編譯過程:
310 | latex example
311 | bibtex example
312 | latex example
313 | \end{verbatim}
314 | \end{quote}
315 |
316 | \subsubsection{\texttt{*.bib} 檔的格式}
317 |
318 | \texttt{*.bib} 檔的格式自成一格,和寫在原來文稿裡頭的不同,視資料的性質,要把他標明出來,例如書籍類是 \verb|@book| 來開頭,期刊文章使用 \verb|@article| 來起頭,我們來看一個例子:
319 |
320 | \begin{quote}
321 | \begin{alltt}
322 | @book\{ KDEt,
323 | \textcolor{red}{author} = "Knuth, Donald E.",
324 | \textcolor{red}{year} = "1989",
325 | \textcolor{red}{title} = "The \verb|{\TeX}|book",
326 | \textcolor{red}{publisher} = "Addison-Wesley",
327 | address = "Reading, Massachusetts",
328 | volumn = " ",
329 | edition = " ",
330 | month = " ",
331 | series = " ",
332 | note = " ",
333 | \}
334 | @article\{ somekey,
335 | \textcolor{red}{author} = "Someone",
336 | \textcolor{red}{year} = "2004",
337 | \textcolor{red}{title} = "The \verb|{\TeX}| Journal",
338 | \textcolor{red}{journal} = "SayYa-Publisher",
339 | volumn = " ",
340 | number = " ",
341 | pages = " ",
342 | month = " ",
343 | note = " ",
344 | \}
345 | \end{alltt}
346 | \end{quote}
347 |
348 | 每行後的逗點是必要的,名字的話 \texttt{Knuth, Donald E.} 或 \texttt{Donald E. Knuth} 這兩種方式,\texttt{bibtex} 都能認得,但姓擺在前面的時候其後要加個逗點,如果是兩位以上的作者時要以 \texttt{and} 來連接。雖然可以使用 \LaTeX\ 的語法,這時他整個要由大括號括起來,而且,註解符號 \texttt{\%} 不被接受。紅色的項目是必要的項目,其他項目可以列進去,也可以省略,要加進去的話,則以 \texttt{" "} 空出來,這樣以後有這方面的資料時再填進去。
349 |
350 | 顯現的形式是受 \text{*.bst} 格式檔在控制的,所以,不必要的標點符號不要自行加進去,書名的字體顯示也無需加進去。
351 |
352 | 引用的方式同樣是使用 \verb|\cite| 指令,一般只要要引用到的資料才會印出來,如果要全部 \texttt{*.bib} 裡頭的資料都印出來的話,可以加個 \verb|\nocite{*}| 指令。
353 |
354 | 在使用中文的情形下,\texttt{bibtex} 程式認不得中文,在 \texttt{CJK}\index{CJK@\texttt{CJK}} 環境下編譯會出問題,我們可以先編輯一個 \texttt{*.cbib} 檔,然後再使用 \texttt{bg5conv} 來把他轉成 \texttt{*.bib} 檔:
355 |
356 | \begin{quote}
357 | \begin{verbatim}
358 | bg5conv < some.cbib > some.bib
359 | \end{verbatim}
360 | \end{quote}
361 |
362 | 這樣,在文稿裡頭引入 \texttt{some.bib} 就可以了。
363 |
364 | \subsubsection{格式檔}
365 |
366 | Bib\TeX\ 的格式檔是 \texttt{*.bst}(bibliography style),我們上面所引用的是 \texttt{plain} 其實就是引用 \texttt{plain.bst} 這個格式檔,這是最基本的格式,在編譯時期會依這個格式檔來印出參考文獻的顯現形式。其他尚有:
367 |
368 | \begin{quote}
369 | \begin{tabular}{>{\ttfamily }ll}
370 | plain & 依字母的順序印出,比較順序為 author, year, title \\
371 | unsrt & 依引用的先後次序印出 \\
372 | abbrv & 與 \texttt{plain} 相同,但 first name, month, title, journal 以縮寫印出 \\
373 | alpha & 引用處顯示 [作者年份] 來取代數目字。
374 | \end{tabular}
375 | \end{quote}
376 |
377 | 已經有許多人發表過特定的格式檔,但這些對於中文則無法完全合乎我們的使用習慣,例如標點符號及書名號,但我們可以去更改他們的格式,這方面的資料請參考系統上的 \texttt{btxdoc.dvi} 及 \texttt{btxhak.dvi} 這兩個說明檔。
378 |
379 | 這也算是目前的一個值得去研究的空間,尤其是中文及 Unciode 編碼文件索引、排序及排版的問題,這在英文語系算是比較容易解決,都有現成的格式範例可以運用,但中文就比較缺乏這方面的範例。在吳聰敏教授的《\texttt{cw}\TeX\ 排版系統》\cite{cwtex} 一書裡頭,有對這方面做過努力,使用的是外部程式工具 \texttt{cwbibtex},再和 \texttt{cw.bst} 格式檔配合的話,有不錯的結果。
380 |
381 | \section{附錄(Appendix)}
382 |
383 | 排版附錄使用的是 \verb|\appendix| 指令,這個指令以後和正常一般編輯即可,不同的附錄以 \verb|\chapter| 來區隔,但印出來的時候會標上大寫字母,而不是原來的 \textbf{Chapter} 字樣。也是可以有 \verb|\section| 指令,這資了大寫英文字母外,會緊接著附上阿拉伯數字,例如 \textbf{A.1}、\textbf{B.2} 等等。
384 |
385 | \subsection{改變附錄的標題}
386 |
387 | 在英文環境,附錄是以 \textbf{Appendix} 為標題來開始的,在中文環境下我們要把他改成中文:
388 |
389 | \begin{quote}
390 | \begin{verbatim}
391 | \renewcommand\appendixname{附~錄}
392 | \end{verbatim}
393 | \end{quote}
394 |
395 | \texttt{article} 類別的文稿並不印出 \textbf{Appendix} 字樣,因此也就沒有 \texttt{appendixname} 來更改。
396 |
397 | \section{大型文稿的維護}
398 | \label{sec:largefile}
399 |
400 | 通常我們寫一篇文章,大概都是一個文稿寫到底,但如果超過一百頁的文稿的時候,維護起來會比較困難,所以 \LaTeX\ 提供了 \verb|\input| 及 \verb|\include| 指令來將外部檔案引進來,當做是文稿的一部份來編譯,這樣就可以按章節來把文稿分開處理、維護。
401 |
402 | 他們的使用方法很簡單,一個是含主要正常結構的主檔,其他的則沒有 preamble 區,只有本文區,就是按照一般文稿中的章節的部份來書寫就可以了。以這一篇文件的例子來說,他的主檔是 \texttt{latex123.tex},主要的內容如下:
403 |
404 | \begin{quote}
405 | \begin{verbatim}
406 | \documentclass[12pt,a4paper]{report}
407 | ...
408 | 這裡是 preamble 區的內容
409 | ...
410 | \begin{document}
411 | \begin{CJK}{Bg5}{hwmm}
412 | ...
413 | %begin{latexonly}
414 | \input{story.cjk}
415 | \input{preparation.cjk}
416 | \input{syntax.cjk}
417 | \input{start.cjk}
418 | \input{space.cjk}
419 | \input{class.cjk}
420 | \input{package.cjk}
421 | \input{table.cjk}
422 | \input{graphic.cjk}
423 | \input{math.cjk}
424 | \input{abook.cjk}
425 | \input{theend.cjk}
426 | \input{fdl.cjk}
427 | %end{latexonly}
428 | \begin{htmlonly}
429 | \input{story}
430 | \input{preparation}
431 | \input{syntax}
432 | \input{start}
433 | \input{space}
434 | \input{class}
435 | \input{package}
436 | \input{table}
437 | \input{graphic}
438 | \input{math}
439 | \input{abook}
440 | \input{theend}
441 | \input{fdl}
442 | \end{htmlonly}
443 | ...
444 | \end{CJK}
445 | \end{document}
446 | \end{verbatim}
447 | \end{quote}
448 |
449 | 這裡分成兩段來處理是因為要使用 \texttt{bg5latex} 來編譯文稿,但 \texttt{latex2html} 本身已經可以處理未經前置處理的 \LaTeX\ 中文文稿,所以分成兩個部份來分別處理。\verb|\input{}| 裡頭的案名,如果沒有加附檔名的話,預設他的延伸檔名是 \texttt{*.tex}。\textsf{CJK}\index{CJK@\textsf{CJK}} package 另外提供了 \verb|\CJKinput| 及 \verb|\CJKinclude| 兩個指令,也可以用來引入中文文稿。
450 |
451 | \subsection{\texttt{input} 和 \texttt{include} 的差異}
452 |
453 | 這兩個指令都可以用來引進外部文稿,但有一些細節不一樣。\verb|\input| 的情形,他可以另外指定延伸檔名,\verb|\include| 則不行,他一定要是 \texttt{*.tex} 的延伸檔名。在引入的時候 \verb|\include| 會起新頁,\verb|\input| 則不一定,要視文稿類別而定。最重要的差異在於 \verb|\include| 可以在 preamble 區和 \verb|\includeonly{}| 指令配合,這樣就不必每次都要編譯整份文稿,只編譯新文稿就可以了,頁數、參照還是會正確顯示,這在排版大型書籍的時候就很好用了。
454 |
455 | \section{裁切記號(crop marks)}
456 | \label{sec:crop}\index{裁切記號(crop marks)}
457 |
458 | 裁切記號是用在排版完成,送印後會有個標記符號,讓印刷廠可以跟據這些標記符號來做截切、剪裁的工作。\LaTeX\ 本身並沒有內建這種功能,這得和 \textsf{crop}\index{crop@\textsf{crop}} package 來配合。
459 |
460 | 由於個人也並沒有這方面的實際經驗,因此這裡不多做說明,請自行參考 \textsf{crop} 巨集套件的說明。
461 |
--------------------------------------------------------------------------------
/contents/chapter12.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{後記}
4 |
5 | 大概簡單介紹了 \LaTeX{} 的使用,這樣夠用了嗎?很可能是不夠的,尤其是想變動風格的時候,但一般使用,不講求花俏,應該可以用了,剩下的只是熟練的問題。當然,許多細節可能並沒有說明清楚,但方向知道了,其他的自行查閱就行了。真碰到問題時,可以到 bbs/news 上詢問。
6 |
7 | 有許多沒有提及的東西,在這一章交代一下,有些是可以自行查閱的,有些則是尚未成熟,可能還不到真正實用的階段(也可能是我自己也不會用啦!:)。
8 |
9 | \begin{enumerate}
10 |
11 | \item 微調 \\
12 | 由於微調牽涉到對 \LaTeX{} macro 的一定程度的認識,因此並沒有說明得很清楚,理想的話應該先把 \TeX{}/\LaTeX{} 巨集的寫法先做簡單的介紹,這個部份可能另外專文介紹較妥,畢竟這篇文件是定位在入門級教材。
13 |
14 | \item 中文的處理 \\
15 | 中文的處理還有很多模糊地帶,例如,索引、參考文獻及中文直排。目前的其他中文 \TeX{}/\LaTeX{} 也沒有介紹,例如 Chi\TeX{}、\texttt{cw}\TeX{} 及 PU\TeX{} 等等。
16 |
17 | \TeX{}/\LaTeX{} 系統的字型機制算是較複雜,安裝字型更是一般使用者的夢魘,英文寫作比較容易解決,通常系統上都會安裝好,中文的話就比較麻煩,除了詳細去介紹外,我們使用中文字型應該有個大家認同的規格才行,否則我這份文件拿到其他的中文 \TeX{}/\LaTeX{} 系統上的時候,就必須修改一下,至少換個字型名稱才能順利編譯。
18 |
19 | \item 實例嫌不夠完整 \\
20 | 尤其是表格、圖形處理及數理排版的部份,並沒有交待得很完整。這裡頭當然牽涉到許多的背景知識的問題,不單純在排版本身,這在其他的排版系統一樣會碰到同樣的情況。當然,有很大的部份是我個人經驗不足的關係啦!:-)
21 |
22 | \item 各種檔案格式的介紹 \\
23 | \TeX{}/\LaTeX{} 系統中的檔案格式多如牛毛,包括一些中間產生的檔案都有他特定的目的,但我們並沒有多做介紹。原因是,這些檔案都牽涉到他的運作機制,這麼一來連運作機制也要說明才行,這樣會使篇幅大增,而且也會擾亂了初學者的學習步調,因此,只能留待往後有機會再來介紹。
24 |
25 | \item 現有巨集庫的整理 \\
26 | \LaTeX{} 的巨集實在是太多了,現有資料大多是英文的,是有必要整理出一份有系統的中文速查表,以免重複去製造輪子。
27 |
28 | \item 重音符號、歐洲字元 \\
29 | 這些都沒有真正接觸到。這些內容,個人不敢造次,因為並不很熟悉,因此,得要有懂歐洲語系的朋友來個完整的介紹才行。
30 |
31 | \item Unicode 編碼文件的處理 \\
32 | 這方面也沒介紹,但由於這是一篇入門級的 \LaTeX{} 教學文件,這方面的內容應該是由另外的專文來介紹可能會比較恰當。
33 |
34 | \item 投影片的製作 \\
35 | 投影片、幻燈片的議題目前很流行,\LaTeX{} 也是可以製作精美的投影片,這方面的文件可以參考:
36 |
37 | \begin{quote}
38 | \url{http://www.miwie.org/presentations/presentations.html}
39 | \end{quote}
40 |
41 | 當然,以上的資料是使用在英文語系,中文的話,我們得另做介紹。
42 |
43 | \item 和 XML/SGML/HTML 的配合 \\
44 | 這個完全沒有提到,一方面 XML/SGML 的內容沒有想像中簡單,他們的應用範圍實在是太廣了,這方面的內容得慢慢來補充。
45 |
46 | \item 和資料庫系統的配合 \\
47 | 這方面在目前 seaching 掛帥的 Internet 是相當重要的課題,這當然是不適合放在這份文件,得另外在進階的文件做更進一步的介紹。\TeX{} 系統的生命力、可塑性相當強,因此和其他的文件系統的結合能力也就比較容易達成。
48 |
49 | \item GUI 圖形界面 \\
50 | 這個部份也沒有深入介紹,最重要是卡在中文的問題上,這方面需要有興趣的朋友共同來研究,雖然命令列環境的生產效率很高,但為了顧及一般使用者的習慣,方便入門的 GUI 圖形界面的確有其需要。
51 |
52 | \end{enumerate}
53 |
54 | 這份文件,感謝行政院研考會委辦,朝陽大學洪朝貴授與輔仁大學毛慶禎教授共同主持的「政府機關資料文件交換之電子檔案格式應用研究」計畫做部份的補助,很高興他們都能認同自由文件、自由軟體,在目前社會體制下的存在價值。
55 |
56 | 這份文件的 PDF 格式所嵌入的中文字型,採用的是王漢宗博士所捐贈的三十幾套的 TTF 向量字型,王博士以前就曾捐贈過十三套的 TTF 向量字型,再加上這次的三十幾套,我們自由軟體社群的中文字型就更充實了。更難得的是,這些字型都是採用 GNU GPL 的授權,和這份 GNU FDL 自由文件配合起來,相得益彰,感謝王漢宗博士的慷慨無私及對自由軟體、自由文件的認同。
57 |
58 | 這份文件採用的是 PDF 及 HTML 格式,這當然得需要網路資源才能呈現在各位面前,感謝 kenduest 及交大數學和 ctshieh 及淡江數學提供這方面的資源,沒有他們的幫忙,文件就無法呈現在各位眼前了!
59 |
60 | 也希望大家能對這份文件多多的指正及建議。寫作期間,已經接到許多朋友的來信指正,很感謝他們。這份文件的 HTML/PDF 格式及原始文稿,可以在以下網站取得:
61 |
62 | \begin{quote}
63 | \url{http://edt1023.sayya.org/tex/latex123/index.html} \\
64 | \url{http://edt1023.sayya.org/tex/latex123/latex123.pdf} \\
65 | \url{http://edt1023.sayya.org/tex/latex123/latex123-v1.0-src.tar.gz} \\
66 | \url{http://MathNet.math.tku.edu.tw/~edt1023/tex/latex123/index.html} \\
67 | \url{http://MathNet.math.tku.edu.tw/~edt1023/tex/latex123/latex123.pdf} \\
68 | \url{http://MathNet.math.tku.edu.tw/~edt1023/tex/latex123/latex123-v1.0-src.tar.gz}
69 | \end{quote}
70 |
--------------------------------------------------------------------------------
/contents/chapter13.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter{GNU 自由文件許可證原文}
4 |
5 | \bigskip
6 | \centerline{\Large\textbf{GNU Free Documentation License}}
7 | \centerline{Version 1.2, November 2002}
8 | \bigskip
9 |
10 |
11 | \linespread{1.0}\selectfont
12 |
13 | \begin{center}
14 | Copyright \copyright{} 2000,2001,2002 Free Software Foundation, Inc.\\
15 | \bigskip
16 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\\
17 | \bigskip
18 | Everyone is permitted to copy and distribute verbatim copies
19 | of this license document, but changing it is not allowed.
20 | \end{center}
21 |
22 | \section*{0. PREAMBLE}
23 |
24 | The purpose of this License is to make a manual, textbook, or other functional and useful document ``free'' in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
25 |
26 | This License is a kind of ``copyleft'', which means that derivative
27 | works of the document must themselves be free in the same sense. It
28 | complements the GNU General Public License, which is a copyleft
29 | license designed for free software.
30 |
31 | We have designed this License in order to use it for manuals for free
32 | software, because free software needs free documentation: a free
33 | program should come with manuals providing the same freedoms that the
34 | software does. But this License is not limited to software manuals;
35 | it can be used for any textual work, regardless of subject matter or
36 | whether it is published as a printed book. We recommend this License
37 | principally for works whose purpose is instruction or reference.
38 |
39 |
40 | \section*{1. APPLICABILITY AND DEFINITIONS}
41 |
42 | This License applies to any manual or other work, in any medium, that
43 | contains a notice placed by the copyright holder saying it can be
44 | distributed under the terms of this License. Such a notice grants a
45 | world-wide, royalty-free license, unlimited in duration, to use that
46 | work under the conditions stated herein. The ``Document'', below,
47 | refers to any such manual or work. Any member of the public is a
48 | licensee, and is addressed as ``you''. You accept the license if you
49 | copy, modify or distribute the work in a way requiring permission
50 | under copyright law.
51 |
52 | A ``Modified Version'' of the Document means any work containing the
53 | Document or a portion of it, either copied verbatim, or with
54 | modifications and/or translated into another language.
55 |
56 | A ``Secondary Section'' is a named appendix or a front-matter section of
57 | the Document that deals exclusively with the relationship of the
58 | publishers or authors of the Document to the Document's overall subject
59 | (or to related matters) and contains nothing that could fall directly
60 | within that overall subject. (Thus, if the Document is in part a
61 | textbook of mathematics, a Secondary Section may not explain any
62 | mathematics.) The relationship could be a matter of historical
63 | connection with the subject or with related matters, or of legal,
64 | commercial, philosophical, ethical or political position regarding
65 | them.
66 |
67 | The ``Invariant Sections'' are certain Secondary Sections whose titles
68 | are designated, as being those of Invariant Sections, in the notice
69 | that says that the Document is released under this License. If a
70 | section does not fit the above definition of Secondary then it is not
71 | allowed to be designated as Invariant. The Document may contain zero
72 | Invariant Sections. If the Document does not identify any Invariant
73 | Sections then there are none.
74 |
75 | The ``Cover Texts'' are certain short passages of text that are listed,
76 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that
77 | the Document is released under this License. A Front-Cover Text may
78 | be at most 5 words, and a Back-Cover Text may be at most 25 words.
79 |
80 | A ``Transparent'' copy of the Document means a machine-readable copy,
81 | represented in a format whose specification is available to the
82 | general public, that is suitable for revising the document
83 | straightforwardly with generic text editors or (for images composed of
84 | pixels) generic paint programs or (for drawings) some widely available
85 | drawing editor, and that is suitable for input to text formatters or
86 | for automatic translation to a variety of formats suitable for input
87 | to text formatters. A copy made in an otherwise Transparent file
88 | format whose markup, or absence of markup, has been arranged to thwart
89 | or discourage subsequent modification by readers is not Transparent.
90 | An image format is not Transparent if used for any substantial amount
91 | of text. A copy that is not ``Transparent'' is called ``Opaque''.
92 |
93 | Examples of suitable formats for Transparent copies include plain
94 | ASCII without markup, Texinfo input format, \LaTeX\ input format, SGML
95 | or XML using a publicly available DTD, and standard-conforming simple
96 | HTML, PostScript or PDF designed for human modification. Examples of
97 | transparent image formats include PNG, XCF and JPG. Opaque formats
98 | include proprietary formats that can be read and edited only by
99 | proprietary word processors, SGML or XML for which the DTD and/or
100 | processing tools are not generally available, and the
101 | machine-generated HTML, PostScript or PDF produced by some word
102 | processors for output purposes only.
103 |
104 | The ``Title Page'' means, for a printed book, the title page itself,
105 | plus such following pages as are needed to hold, legibly, the material
106 | this License requires to appear in the title page. For works in
107 | formats which do not have any title page as such, ``Title Page'' means
108 | the text near the most prominent appearance of the work's title,
109 | preceding the beginning of the body of the text.
110 |
111 | A section ``Entitled XYZ'' means a named subunit of the Document whose
112 | title either is precisely XYZ or contains XYZ in parentheses following
113 | text that translates XYZ in another language. (Here XYZ stands for a
114 | specific section name mentioned below, such as ``Acknowledgements'',
115 | ``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
116 | of such a section when you modify the Document means that it remains a
117 | section ``Entitled XYZ'' according to this definition.
118 |
119 | The Document may include Warranty Disclaimers next to the notice which
120 | states that this License applies to the Document. These Warranty
121 | Disclaimers are considered to be included by reference in this
122 | License, but only as regards disclaiming warranties: any other
123 | implication that these Warranty Disclaimers may have is void and has
124 | no effect on the meaning of this License.
125 |
126 |
127 | \section*{2. VERBATIM COPYING}
128 |
129 | You may copy and distribute the Document in any medium, either
130 | commercially or noncommercially, provided that this License, the
131 | copyright notices, and the license notice saying this License applies
132 | to the Document are reproduced in all copies, and that you add no other
133 | conditions whatsoever to those of this License. You may not use
134 | technical measures to obstruct or control the reading or further
135 | copying of the copies you make or distribute. However, you may accept
136 | compensation in exchange for copies. If you distribute a large enough
137 | number of copies you must also follow the conditions in section 3.
138 |
139 | You may also lend copies, under the same conditions stated above, and
140 | you may publicly display copies.
141 |
142 |
143 | \section*{3. COPYING IN QUANTITY}
144 |
145 | If you publish printed copies (or copies in media that commonly have
146 | printed covers) of the Document, numbering more than 100, and the
147 | Document's license notice requires Cover Texts, you must enclose the
148 | copies in covers that carry, clearly and legibly, all these Cover
149 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
150 | the back cover. Both covers must also clearly and legibly identify
151 | you as the publisher of these copies. The front cover must present
152 | the full title with all words of the title equally prominent and
153 | visible. You may add other material on the covers in addition.
154 | Copying with changes limited to the covers, as long as they preserve
155 | the title of the Document and satisfy these conditions, can be treated
156 | as verbatim copying in other respects.
157 |
158 | If the required texts for either cover are too voluminous to fit
159 | legibly, you should put the first ones listed (as many as fit
160 | reasonably) on the actual cover, and continue the rest onto adjacent
161 | pages.
162 |
163 | If you publish or distribute Opaque copies of the Document numbering
164 | more than 100, you must either include a machine-readable Transparent
165 | copy along with each Opaque copy, or state in or with each Opaque copy
166 | a computer-network location from which the general network-using
167 | public has access to download using public-standard network protocols
168 | a complete Transparent copy of the Document, free of added material.
169 | If you use the latter option, you must take reasonably prudent steps,
170 | when you begin distribution of Opaque copies in quantity, to ensure
171 | that this Transparent copy will remain thus accessible at the stated
172 | location until at least one year after the last time you distribute an
173 | Opaque copy (directly or through your agents or retailers) of that
174 | edition to the public.
175 |
176 | It is requested, but not required, that you contact the authors of the
177 | Document well before redistributing any large number of copies, to give
178 | them a chance to provide you with an updated version of the Document.
179 |
180 |
181 | \section*{4. MODIFICATIONS}
182 |
183 | You may copy and distribute a Modified Version of the Document under
184 | the conditions of sections 2 and 3 above, provided that you release
185 | the Modified Version under precisely this License, with the Modified
186 | Version filling the role of the Document, thus licensing distribution
187 | and modification of the Modified Version to whoever possesses a copy
188 | of it. In addition, you must do these things in the Modified Version:
189 |
190 | \begin{itemize}
191 |
192 | \item[{\bf A.}] Use in the Title Page (and on the covers, if any) a title distinct.
193 | from that of the Document, and from those of previous versions
194 | (which should, if there were any, be listed in the History section
195 | of the Document). You may use the same title as a previous version
196 | if the original publisher of that version gives permission.
197 |
198 | \item[{\bf B.}] List on the Title Page, as authors, one or more persons or entities
199 | responsible for authorship of the modifications in the Modified
200 | Version, together with at least five of the principal authors of the
201 | Document (all of its principal authors, if it has fewer than five),
202 | unless they release you from this requirement.
203 |
204 | \item[{\bf C.}] State on the Title page the name of the publisher of the
205 | Modified Version, as the publisher.
206 |
207 | \item[{\bf D.}] Preserve all the copyright notices of the Document.
208 |
209 | \item[{\bf E.}] Add an appropriate copyright notice for your modifications
210 | adjacent to the other copyright notices.
211 |
212 | \item[{\bf F.}] Include, immediately after the copyright notices, a license notice
213 | giving the public permission to use the Modified Version under the
214 | terms of this License, in the form shown in the Addendum below.
215 |
216 | \item[{\bf G.}] Preserve in that license notice the full lists of Invariant Sections
217 | and required Cover Texts given in the Document's license notice.
218 |
219 | \item[{\bf H.}] Include an unaltered copy of this License.
220 |
221 | \item[{\bf I.}] Preserve the section Entitled ``History'', Preserve its Title, and add
222 | to it an item stating at least the title, year, new authors, and
223 | publisher of the Modified Version as given on the Title Page. If
224 | there is no section Entitled ``History'' in the Document, create one
225 | stating the title, year, authors, and publisher of the Document as
226 | given on its Title Page, then add an item describing the Modified
227 | Version as stated in the previous sentence.
228 |
229 | \item[{\bf J.}] Preserve the network location, if any, given in the Document for
230 | public access to a Transparent copy of the Document, and likewise
231 | the network locations given in the Document for previous versions
232 | it was based on. These may be placed in the ``History'' section.
233 | You may omit a network location for a work that was published at
234 | least four years before the Document itself, or if the original
235 | publisher of the version it refers to gives permission.
236 |
237 | \item[{\bf K.}] For any section Entitled ``Acknowledgements'' or ``Dedications'',
238 | Preserve the Title of the section, and preserve in the section all
239 | the substance and tone of each of the contributor acknowledgements
240 | and/or dedications given therein.
241 |
242 | \item[{\bf L.}] Preserve all the Invariant Sections of the Document,
243 | unaltered in their text and in their titles. Section numbers
244 | or the equivalent are not considered part of the section titles.
245 |
246 | \item[{\bf M.}] Delete any section Entitled ``Endorsements''. Such a section
247 | may not be included in the Modified Version.
248 |
249 | \item[{\bf N.}] Do not retitle any existing section to be Entitled ``Endorsements''
250 | or to conflict in title with any Invariant Section.
251 |
252 | \item[{\bf O.}] Preserve any Warranty Disclaimers.
253 |
254 | \end{itemize}
255 |
256 | If the Modified Version includes new front-matter sections or
257 | appendices that qualify as Secondary Sections and contain no material
258 | copied from the Document, you may at your option designate some or all
259 | of these sections as invariant. To do this, add their titles to the
260 | list of Invariant Sections in the Modified Version's license notice.
261 | These titles must be distinct from any other section titles.
262 |
263 | You may add a section Entitled ``Endorsements'', provided it contains
264 | nothing but endorsements of your Modified Version by various
265 | parties--for example, statements of peer review or that the text has
266 | been approved by an organization as the authoritative definition of a
267 | standard.
268 |
269 | You may add a passage of up to five words as a Front-Cover Text, and a
270 | passage of up to 25 words as a Back-Cover Text, to the end of the list
271 | of Cover Texts in the Modified Version. Only one passage of
272 | Front-Cover Text and one of Back-Cover Text may be added by (or
273 | through arrangements made by) any one entity. If the Document already
274 | includes a cover text for the same cover, previously added by you or
275 | by arrangement made by the same entity you are acting on behalf of,
276 | you may not add another; but you may replace the old one, on explicit
277 | permission from the previous publisher that added the old one.
278 |
279 | The author(s) and publisher(s) of the Document do not by this License
280 | give permission to use their names for publicity for or to assert or
281 | imply endorsement of any Modified Version.
282 |
283 |
284 | \section*{5. COMBINING DOCUMENTS}
285 |
286 | You may combine the Document with other documents released under this
287 | License, under the terms defined in section 4 above for modified
288 | versions, provided that you include in the combination all of the
289 | Invariant Sections of all of the original documents, unmodified, and
290 | list them all as Invariant Sections of your combined work in its
291 | license notice, and that you preserve all their Warranty Disclaimers.
292 |
293 | The combined work need only contain one copy of this License, and
294 | multiple identical Invariant Sections may be replaced with a single
295 | copy. If there are multiple Invariant Sections with the same name but
296 | different contents, make the title of each such section unique by
297 | adding at the end of it, in parentheses, the name of the original
298 | author or publisher of that section if known, or else a unique number.
299 | Make the same adjustment to the section titles in the list of
300 | Invariant Sections in the license notice of the combined work.
301 |
302 | In the combination, you must combine any sections Entitled ``History''
303 | in the various original documents, forming one section Entitled
304 | ``History''; likewise combine any sections Entitled ``Acknowledgements'',
305 | and any sections Entitled ``Dedications''. You must delete all sections
306 | Entitled ``Endorsements''.
307 |
308 |
309 | \section*{6. COLLECTIONS OF DOCUMENTS}
310 |
311 | You may make a collection consisting of the Document and other documents
312 | released under this License, and replace the individual copies of this
313 | License in the various documents with a single copy that is included in
314 | the collection, provided that you follow the rules of this License for
315 | verbatim copying of each of the documents in all other respects.
316 |
317 | You may extract a single document from such a collection, and distribute
318 | it individually under this License, provided you insert a copy of this
319 | License into the extracted document, and follow this License in all
320 | other respects regarding verbatim copying of that document.
321 |
322 |
323 | \section*{7. AGGREGATION WITH INDEPENDENT WORKS}
324 |
325 | A compilation of the Document or its derivatives with other separate
326 | and independent documents or works, in or on a volume of a storage or
327 | distribution medium, is called an ``aggregate'' if the copyright
328 | resulting from the compilation is not used to limit the legal rights
329 | of the compilation's users beyond what the individual works permit.
330 | When the Document is included in an aggregate, this License does not
331 | apply to the other works in the aggregate which are not themselves
332 | derivative works of the Document.
333 |
334 | If the Cover Text requirement of section 3 is applicable to these
335 | copies of the Document, then if the Document is less than one half of
336 | the entire aggregate, the Document's Cover Texts may be placed on
337 | covers that bracket the Document within the aggregate, or the
338 | electronic equivalent of covers if the Document is in electronic form.
339 | Otherwise they must appear on printed covers that bracket the whole
340 | aggregate.
341 |
342 |
343 | \section*{8. TRANSLATION}
344 |
345 | Translation is considered a kind of modification, so you may
346 | distribute translations of the Document under the terms of section 4.
347 | Replacing Invariant Sections with translations requires special
348 | permission from their copyright holders, but you may include
349 | translations of some or all Invariant Sections in addition to the
350 | original versions of these Invariant Sections. You may include a
351 | translation of this License, and all the license notices in the
352 | Document, and any Warranty Disclaimers, provided that you also include
353 | the original English version of this License and the original versions
354 | of those notices and disclaimers. In case of a disagreement between
355 | the translation and the original version of this License or a notice
356 | or disclaimer, the original version will prevail.
357 |
358 | If a section in the Document is Entitled ``Acknowledgements'',
359 | ``Dedications'', or ``History'', the requirement (section 4) to Preserve
360 | its Title (section 1) will typically require changing the actual
361 | title.
362 |
363 |
364 | \section*{9. TERMINATION}
365 |
366 | You may not copy, modify, sublicense, or distribute the Document except
367 | as expressly provided for under this License. Any other attempt to
368 | copy, modify, sublicense or distribute the Document is void, and will
369 | automatically terminate your rights under this License. However,
370 | parties who have received copies, or rights, from you under this
371 | License will not have their licenses terminated so long as such
372 | parties remain in full compliance.
373 |
374 |
375 | \section*{10. FUTURE REVISIONS OF THIS LICENSE}
376 |
377 | The Free Software Foundation may publish new, revised versions
378 | of the GNU Free Documentation License from time to time. Such new
379 | versions will be similar in spirit to the present version, but may
380 | differ in detail to address new problems or concerns. See
381 | {\ttfamily http://www.gnu.org/copyleft/}.
382 |
383 | Each version of the License is given a distinguishing version number.
384 | If the Document specifies that a particular numbered version of this
385 | License ``or any later version'' applies to it, you have the option of
386 | following the terms and conditions either of that specified version or
387 | of any later version that has been published (not as a draft) by the
388 | Free Software Foundation. If the Document does not specify a version
389 | number of this License, you may choose any version ever published (not
390 | as a draft) by the Free Software Foundation.
391 |
392 |
393 | \section*{ADDENDUM: How to use this License for your documents}
394 |
395 | To use this License in a document you have written, include a copy of
396 | the License in the document and put the following copyright and
397 | license notices just after the title page:
398 |
399 | \begin{quote}
400 | Copyright {\copyright} YEAR YOUR NAME.
401 | Permission is granted to copy, distribute and/or modify this document
402 | under the terms of the GNU Free Documentation License, Version 1.2
403 | or any later version published by the Free Software Foundation;
404 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
405 | A copy of the license is included in the section entitled ``GNU
406 | Free Documentation License''.
407 | \end{quote}
408 |
409 | If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
410 | replace the ``with\dots Texts.'' line with this:
411 |
412 | \begin{quote}
413 | with the Invariant Sections being LIST THEIR TITLES, with the
414 | Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
415 | \end{quote}
416 |
417 | If you have Invariant Sections without Cover Texts, or some other
418 | combination of the three, merge those two alternatives to suit the
419 | situation.
420 |
421 | If your document contains nontrivial examples of program code, we
422 | recommend releasing these examples in parallel under your choice of
423 | free software license, such as the GNU General Public License,
424 | to permit their use in free software.
425 |
--------------------------------------------------------------------------------
/contents/license.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \chapter*{使用許可證聲明}
4 | \addcontentsline{toc}{chapter}{使用許可證聲明}
5 |
6 | \linespread{1.2}\selectfont
7 |
8 | \colorbox{mygray}{
9 | % 沒有 minipage 的話,不會自動 word wrap
10 | \begin{minipage}{1.0\textwidth}
11 |
12 | Copyright \copyright~ 2004 李果正 \href{mailto:edt1023@info.sayya.org}{Edward G.J.\ Lee} \\
13 | 最後修訂日期:\today \\
14 | 本文件為自由文件(GNU FDL \url{http://www.gnu.org/copyleft/fdl.html}),不明示或暗示有任何的保證。本文件可自由複製、修改、散佈,但請保留使用許可證聲明,文章內所附之 GNU Free Documentation License 一章全文則不可修改其內容。程式碼的部份依其所宣告的 license,不受 GNU FDL 的規範。PDF 格式文件內所嵌入的向量字型資料,為王漢宗博士(Dr. Hann-Tzong Wang)所捐贈,字型 Copyright 屬王漢宗博士,其使用授權為 GNU GPL。因此,此部份的字型資料,亦不屬 FDL 規範範圍。文件內所提及的商標皆屬其合法註冊公司所有。
15 |
16 | \end{minipage}
17 | }
18 |
--------------------------------------------------------------------------------
/contents/references.tex:
--------------------------------------------------------------------------------
1 | % !TeX root = ../main.tex
2 |
3 | \cleardoublepage
4 |
5 | \begin{thebibliography}{KDE}
6 | \label{bib:bib}
7 | \addcontentsline{toc}{chapter}{參考資料}
8 |
9 | \bibitem{KDEt} Knuth, Donald E., \textit{The \TeX{}book},
10 | Reading, Massachusetts: Addison-Wesley, 1989.
11 |
12 | \bibitem[KDE]{KDEm} Knuth, Donald E., \textit{The \MF{}book},
13 | Reading, Massachusetts: Addison-Wesley, 1986.
14 |
15 | \bibitem{topic} Clark, Malcolm, \textit{\TeX\ by Topic},
16 | Reading, Massachusetts: Addison-Wesley, 1992.
17 |
18 | \bibitem{Impatient} Abrahams, Paul W., Berry, Karl and Hargreaves, Kathryn A.,
19 | \textit{\TeX\ for the Impatient},
20 | Reading, Massachusetts: Addison-Wesley, 1990.
21 |
22 | \bibitem{comp} Goossens, Michel, Mittelbach, Frank, and Samarin, Alexander,
23 | \textit{The \LaTeX\ Companion},
24 | Reading, Massachusetts: Addison-Wesley, 1993.
25 |
26 | \bibitem{cwtex} 吳聰敏、吳聰慧,《\texttt{cw}\TeX\ 排版系統》,台北:吳聰敏,2002。
27 |
28 | \bibitem{clatex} 鄭郁耀、郭雅思,《\LaTeX\ 數理排版:由入門到應用》,台北:全華,1995。
29 |
30 | \bibitem{clinux} 王佑中,《Linux 中文應用手冊》,台北:第三波,1995。
31 |
32 | \bibitem{paper1} 朱浤源,《撰寫博碩士論文實戰手冊》,台北:正中,1999。
33 |
34 | \bibitem{paper2} 傅袓慧,《科學論文的寫作審查及發表》,台北:中華農學會,1980。
35 |
36 | \end{thebibliography}
37 |
38 | \cleardoublepage
--------------------------------------------------------------------------------
/docsetup.tex:
--------------------------------------------------------------------------------
1 | % --------------------------------------------------
2 | % 加載套件(Include Packages)
3 | % --------------------------------------------------
4 |
5 | \usepackage[CJKbookmarks, plainpages=false, hyperindex]{hyperref}
6 | \usepackage{mflogo}
7 | \usepackage{amsmath, amsthm, amssymb}
8 | \usepackage{array}
9 | \usepackage{alltt}
10 | \usepackage{fancyvrb}
11 | \usepackage{makeidx}
12 | % \usepackage{imakeidx}
13 | % \usepackage[pagecolor={none}]{pagecolor}
14 |
15 | % --------------------------------------------------
16 | % 套件設定(Packages Settings)
17 | % --------------------------------------------------
18 |
19 | % \appendgraphicspath{{./figures/chapter01/}}
20 | % \appendgraphicspath{{./figures/chapter02/}}
21 | \appendgraphicspath{{./figures/chapter03/}}
22 | \appendgraphicspath{{./figures/chapter04/}}
23 | \appendgraphicspath{{./figures/chapter05/}}
24 | \appendgraphicspath{{./figures/chapter10/}}
25 |
26 | % --------------------------------------------------
27 | % 自訂命令(Packages Settings)
28 | % --------------------------------------------------
29 |
30 | \hypersetup{
31 | colorlinks = true,
32 | linkcolor = blue,
33 | pdfauthor = {李果正 Edward G.J. Lee},
34 | pdftitle = {大家來學 LaTeX Version 1.0},
35 | pdfsubject = {大家來學 LaTeX Version 1.0},
36 | pdfkeywords = {大家來學 LaTeX, CJK, LaTeX, latex123}
37 | }
38 |
39 | % 設定小節深度
40 | \setcounter{secnumdepth}{3}
41 |
42 | % 啟用頁眉格式
43 | \pagestyle{fancy}
44 |
45 | % 繪製線段長度
46 | \newcommand{\drawwidth}[1]{\rule{0.3pt}{1.3ex}\rule[1mm]{#1}{0.3pt}\rule{0.3pt}{1.3ex}}
47 |
48 | % 中文顯示日期
49 | \renewcommand{\today}{\number\year~年~\number\month~月~\number\day~日}
50 |
51 | % 中文刪節符號
52 | \newcommand{\chdots}{$\cdots\cdots$}
53 | \newtheorem{defi}{Definition}
54 |
55 | % 設置中文標題
56 | \renewcommand\contentsname{目~錄~}
57 | \renewcommand\bibname{參~考~資~料}
58 | \renewcommand\indexname{索~引}
59 | \renewcommand\chaptermark[1]{\markboth{第\ \thechapter\ 章\ #1}{}}
60 |
61 | % 創建索引頁面
62 | \let\oldprintindex\printindex
63 | \renewcommand{\printindex}{
64 | \addcontentsline{toc}{chapter}{索引}
65 | \oldprintindex
66 | }
67 | \makeindex
--------------------------------------------------------------------------------
/figures/chapter03/baseline.mp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter03/baseline.mp
--------------------------------------------------------------------------------
/figures/chapter03/baseline.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter03/baseline.pdf
--------------------------------------------------------------------------------
/figures/chapter03/latex-flow.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter03/latex-flow.pdf
--------------------------------------------------------------------------------
/figures/chapter03/latex-flow.tex:
--------------------------------------------------------------------------------
1 | % \documentclass[12pt]{article}
2 | \documentclass[crop=true]{standalone}
3 | \usepackage{xeCJK}
4 | \usepackage{fontspec}
5 | \usepackage{pstricks}
6 | \usepackage{pst-node}
7 | \definecolor{Pink}{rgb}{1.00, 0.75, 0.80}
8 | \pagestyle{empty}
9 |
10 | \setCJKmainfont{HanWangMingMedium}[
11 | Path = ../../fonts/chinese/ ,
12 | Extension = .ttf ,
13 | BoldFont = HanWangMingHeavy , ]
14 |
15 | \begin{document}
16 | \begin{psmatrix}[rowsep=0.5cm, colsep=0.8cm]
17 | \psovalbox[fillstyle=solid, fillcolor=yellow]{開始} \\
18 | \psframebox{{\ttfamily latex} 可能不只一次} \\
19 | \psdiabox[fillstyle=solid, fillcolor=Pink]{\ttfamily your.tex} &
20 | \psframebox{\ttfamily dvips} & \psframebox{\ttfamily ps2pdf} \\
21 | \psframebox{\ttfamily dvipdfm[x] 或 pdflatex} \\
22 | \psovalbox[fillstyle=solid, fillcolor=yellow]{完成}
23 | \ncline{1,1}{2,1}
24 | \ncline{2,1}{3,1}
25 | \ncline{3,1}{4,1}<{\textcolor{red}{pdf 檔}}
26 | \ncline{4,1}{5,1}
27 | \ncline{->}{3,1}{3,2}^{\textcolor{red}{ps 檔}}
28 | \ncline{->}{3,2}{3,3}
29 | \ncbar[angleA=-90, armB=0, nodesepB=2.5mm]{->}{3,3}{4,1}
30 | \end{psmatrix}
31 | \end{document}
--------------------------------------------------------------------------------
/figures/chapter04/fntsize.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter04/fntsize.pdf
--------------------------------------------------------------------------------
/figures/chapter04/fntsize.tex:
--------------------------------------------------------------------------------
1 | % fntsize.tex font size relative command and examples.
2 | \documentclass[crop=true]{standalone}
3 | \usepackage{xeCJK}
4 | \usepackage{fontspec}
5 | \usepackage{array}
6 | \pagestyle{empty}
7 |
8 | \setCJKmainfont{HanWangMingMedium}[
9 | Path = ../../fonts/chinese/ ,
10 | Extension = .ttf ,
11 | BoldFont = HanWangMingHeavy , ]
12 |
13 | \begin{document}
14 |
15 | \begin{tabular}{lll>{\tt}l}
16 | 指令 & 實際例子 & 效果 & 實際的大小(點數)\\
17 | \hline
18 | \verb|\tiny| & \verb|{\tiny tiny}| & {\tiny tiny} & 5pt \\
19 | \verb|\scriptsize| & \verb|{\scriptsize scriptsize}| & {\scriptsize scriptsize} & 7pt \\
20 | \verb|\footnotesize| & \verb|{\footnotesize footnotesize}| & {\footnotesize footnotesize} & 8pt \\
21 | \verb|\small| & \verb|{\small small}| & {\small small} & 9pt \\
22 | \verb|\normalsize| & \verb|{\normalsize normalsize}| & {\normalsize normalsize} & 10pt \\
23 | \verb|\large| & \verb|{\large large}| & {\large large} & 12pt \\
24 | \verb|\Large| & \verb|{\Large Large}| & {\Large Large} & 14.4pt \\[.7ex]
25 | \verb|\LARGE| & \verb|{\LARGE LARGE}| & {\LARGE LARGE} & 17.28pt \\
26 | \verb|\huge| & \verb|{\huge huge}| & {\huge huge} & 20.74pt \\
27 | \verb|\Huge| & \verb|{\Huge Huge}| & {\Huge Huge} & 24.88pt \\
28 | \end{tabular}
29 |
30 | \end{document}
--------------------------------------------------------------------------------
/figures/chapter05/layout-r.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter05/layout-r.pdf
--------------------------------------------------------------------------------
/figures/chapter05/layout-r.tex:
--------------------------------------------------------------------------------
1 | \documentclass{report}
2 | \usepackage{layout}
3 | \pagestyle{empty}
4 |
5 | \begin{document}
6 | \layout
7 | \end{document}
--------------------------------------------------------------------------------
/figures/chapter10/cmath01.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter10/cmath01.pdf
--------------------------------------------------------------------------------
/figures/chapter10/cmath01.tex:
--------------------------------------------------------------------------------
1 | % cmath01.tex
2 | \documentclass[12pt]{article}
3 | \usepackage{xeCJK}
4 | \usepackage{fontspec}
5 | \usepackage{amssymb, amsmath,amsthm}
6 | \pagestyle{empty}
7 |
8 | \setCJKmainfont{HanWangMingMedium}[
9 | Path = ../../fonts/chinese/ ,
10 | Extension = .ttf ,
11 | BoldFont = HanWangMingHeavy , ]
12 |
13 | \theoremstyle{remark}
14 | \newtheorem{cdefi}{\bfseries 定義}
15 | \renewcommand\CJKglue{\hskip -0.3pt plus 0.08\baselineskip}
16 |
17 | \begin{document}
18 |
19 | \begin{cdefi}
20 | 設函數 $f:[a,b]\rightarrow{\mathbb R}$ 為可微分,且 $(f')^2$ 為可積,則稱
21 | \[
22 | L(s)=\int^b_a\sqrt{1+(f'(x))^2}dx
23 | \]
24 | 為 $f$ 之圖形自點 $(a,f(a))$ 至點 $(b,f(b))$ 之弧 $s$ 的弧長。
25 | \end{cdefi}
26 |
27 | \end{document}
--------------------------------------------------------------------------------
/figures/chapter10/cmath02.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/chapter10/cmath02.pdf
--------------------------------------------------------------------------------
/figures/chapter10/cmath02.tex:
--------------------------------------------------------------------------------
1 | % cmath1.tex
2 | \documentclass[12pt]{article}
3 | \usepackage{xeCJK}
4 | \usepackage{fontspec}
5 | \usepackage{amssymb, amsmath, amsthm}
6 | \pagestyle{empty}
7 |
8 | \setCJKmainfont{HanWangMingMedium}[
9 | Path = ../../fonts/chinese/ ,
10 | Extension = .ttf ,
11 | BoldFont = HanWangMingHeavy , ]
12 |
13 | \theoremstyle{remark}
14 | \newtheorem{cdefi}{\bfseries 定義}
15 | \renewcommand\CJKglue{\hskip -0.3pt plus 0.08\baselineskip}
16 |
17 | \begin{document}
18 |
19 | \begin{cdefi}
20 | 設函數 $f:[a,b]\rightarrow{\mathbb R}$ 為可微分,且 $(f')^2$ 為可積,則稱
21 | \[
22 | L(s)=\int^b_a\!\sqrt{1+(f'(x))^2}\,dx
23 | \]
24 | 為 $f$ 之圖形自點 $(a,f(a))$ 至點 $(b,f(b))$ 之弧 $s$ 的弧長。
25 | \end{cdefi}
26 |
27 | \end{document}
--------------------------------------------------------------------------------
/figures/cover.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/figures/cover.pdf
--------------------------------------------------------------------------------
/fonts/chinese/HanWangMingHeavy.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/fonts/chinese/HanWangMingHeavy.ttf
--------------------------------------------------------------------------------
/fonts/chinese/HanWangMingMedium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/fonts/chinese/HanWangMingMedium.ttf
--------------------------------------------------------------------------------
/fonts/chinese/HanWangYanKai.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/fonts/chinese/HanWangYanKai.ttf
--------------------------------------------------------------------------------
/latex123.cls:
--------------------------------------------------------------------------------
1 | % --------------------------------------------------
2 | % 01 類別宣告(Class Declaration)
3 | % --------------------------------------------------
4 |
5 | % 告知編譯器當前的 LaTeX 版本
6 | % Must indicate what's the release of LaTeX we are using.
7 | \NeedsTeXFormat{LaTeX2e}
8 |
9 | % 定義類別名稱與敘述
10 | % Define the name and description of class.
11 | \ProvidesClass{latex123}[2020/12/01 v2.0 LaTeX123]
12 |
13 | % --------------------------------------------------
14 | % 02 基礎設定(Basic Settings)
15 | % --------------------------------------------------
16 |
17 | % [引入套件]
18 | % Include required packages for basic settings.
19 |
20 | \RequirePackage{kvdefinekeys, kvsetkeys, kvoptions}
21 | \RequirePackage{iftex}
22 | \RequirePackage{ifthen}
23 |
24 | % [定義變數]
25 | % Define essential variables.
26 |
27 | % 變數: 路徑
28 | % Variables: Path
29 | \newcommand{\cls@path@font}{./fonts/english/}
30 | \newcommand{\cls@path@cjkfont}{./fonts/chinese/}
31 |
32 | % --------------------------------------------------
33 | % 03 選項設定(Options Settings)
34 | % --------------------------------------------------
35 |
36 | % 繼承類別選項(將未定義的傳給基礎文檔)
37 | % Option Declaration (pass tundefined options to father class)
38 | \DeclareDefaultOption{
39 | \PassOptionsToClass{\CurrentOption}{report}
40 | }
41 |
42 | % 處理選項並載入基礎文檔
43 | % Terminates the options processing and loads the basic class.
44 | \LoadClass[a4paper, 12pt]{report}
45 |
46 | % --------------------------------------------------
47 | % 04 載入套件 (Include Packages)
48 | % --------------------------------------------------
49 |
50 | % [載入套件]
51 |
52 | \RequirePackage[BoldFont,SlantFont]{xeCJK}
53 | \RequirePackage{fontspec}
54 | \RequirePackage[dvipsnames]{xcolor}
55 | \RequirePackage[sf]{titlesec}
56 | \RequirePackage{titletoc}
57 | \RequirePackage{fancyhdr}
58 | \RequirePackage{graphicx}
59 | \RequirePackage{tikz}
60 |
61 | % [定義顏色]
62 |
63 | \definecolor{steelblue}{rgb}{0.275, 0.510, 0.710}
64 | \definecolor{lightpink}{rgb}{0.991, 0.711, 0.754}
65 | \definecolor{darkblue}{rgb}{0.000, 0.000, 0.500}
66 | \definecolor{darkgreen}{rgb}{0.000, 0.390, 0.000}
67 | \definecolor{mygray}{gray}{0.92}
68 | \definecolor{heavygray}{gray}{0.50}
69 | \definecolor{lightgray}{gray}{0.80}
70 |
71 | % --------------------------------------------------
72 | % 05 自訂命令(Custom Commands)
73 | % --------------------------------------------------
74 |
75 | % [添加路徑]
76 | \newcommand\appendgraphicspath[1]{
77 | \g@addto@macro\Ginput@path{#1}
78 | }
79 |
80 | % [標題格式]
81 | % Header Format
82 | \newcommand{\myheader}[1]{
83 | \textcolor{darkblue}{#1}
84 | }
85 |
86 | % [生成封面]
87 | % Generate the cover page
88 | %
89 | \newcommand{\makecover}{
90 | \begin{titlepage}
91 | % 標題資訊
92 | \vfill
93 | \begin{flushright}
94 | \textcolor{steelblue}{
95 | \fontsize{36}{20pt}\selectfont
96 | \hwyk 大家來學 \textbf{{\LaTeX}}
97 | }
98 | \end{flushright}
99 |
100 | % 版本資訊
101 | \textcolor{lightpink}{\rule{\textwidth}{.256ex}}
102 | \begin{flushleft}
103 | Version 1.0 \\
104 | \today
105 | \end{flushleft}
106 |
107 | % 封面圖片
108 | \vfill
109 | \hspace*{3em}\includegraphics[scale=.75]{cover}
110 | \vfill
111 |
112 | % 作者資訊
113 | \begin{flushright}
114 | By Edward G.J.\ Lee 李果正 \\
115 | Email : \href{mailto:edt1023@info.sayya.org}{\ttfamily edt1023@info.sayya.org} \\
116 | 本教學文件之製作,部份接受下列計劃補助: \\
117 | 行政院研考會委辦 「政府機關資料文件交換之電子檔案格式應用研究」
118 | \end{flushright}
119 | \end{titlepage}
120 | }
121 |
122 | % [生成目錄]
123 | % Generate table of contents page.
124 | %
125 | \renewcommand{\contentsname}{目錄}
126 | \newcommand{\maketableofcontents}{
127 | % 目錄部份頁碼以羅馬數字計數
128 | % \cleardoublepage
129 | % \phantomsection
130 | \pagenumbering{roman}
131 | \setcounter{page}{1}
132 | \tableofcontents
133 | \newpage
134 | }
135 |
136 | % [正文開始]
137 | % \mainmatter
138 | %
139 | \newcommand{\mainmatter}{
140 | % 正文部分頁碼以阿拉伯數字計數
141 | \cleardoublepage
142 | \pagenumbering{arabic}
143 | \setcounter{page}{1}
144 | % 調整段落間距離,置於 preamble 區會影響目錄行距,
145 | % 因此置於正文區
146 | \parskip=1.618ex
147 | }
148 |
149 | % --------------------------------------------------
150 | % 06 套件設定 (Package Settings)
151 | % --------------------------------------------------
152 |
153 | % [圖表目錄]
154 | \graphicspath{{./figures/}}
155 |
156 | % [字體設定]
157 | % - \setmainfont{} 襯線字體
158 | % - \setsansfont{} 非襯字體
159 | % - \setmonofont{} 等寬字體
160 | % - \setCJKmainfont{} 中文襯線字體
161 | % - \setCJKsansfont{} 中文非襯字體
162 | % - \setCJKmonofont{} 中文等寬字體
163 | %
164 |
165 | % \setmainfont{Times New Roman}[
166 | % Path = \latex123@path@font ,
167 | % Extension = .ttf ,
168 | % BoldFont = *-Bold ,
169 | % ItalicFont = *-Italic ,
170 | % BoldItalicFont = *-BoldItalic, ]
171 |
172 | % 設定主要字體
173 | \setCJKmainfont{HanWangMingMedium}[
174 | Path = \cls@path@cjkfont ,
175 | Extension = .ttf ,
176 | BoldFont = HanWangMingHeavy , ]
177 |
178 | % 王漢宗中明體 \hwmm
179 | \newCJKfontfamily{\hwmm}[
180 | Path = \cls@path@cjkfont ,
181 | Extension = .ttf , ]{HanWangMingMedium}
182 |
183 | % 王漢宗特明體 \hwmh
184 | \newCJKfontfamily{\hwmh}[
185 | Path = \cls@path@cjkfont ,
186 | Extension = .ttf , ]{HanWangMingHeavy}
187 |
188 | % 王漢宗顏楷體 \hwyk
189 | \newCJKfontfamily{\hwyk}[
190 | Path = \cls@path@cjkfont ,
191 | Extension = .ttf , ]{HanWangYanKai}
192 |
193 | % [頁眉格式]
194 | % 左章右節,每一頁皆相同。不使用 twoside 選項,則每一頁皆視為右頁。
195 | \fancyhead[R]{\textsl{\footnotesize\textcolor{heavygray}\rightmark}}
196 | \fancyhead[L]{\textsl{\footnotesize\textcolor{heavygray}\leftmark}}
197 |
198 | % [標題格式]
199 | % \titleformat{command}[shape]{format}{label}{sep}{before}[after]
200 | % - command: 代表欲重新定義之標題階層,包含 \part, \chapter, \section, \paragraph
201 | % - shape: 設定段落形狀,可選參數有 hang, block, display
202 | % - format: 定義標題外觀,如:位置、字體大小粗細…
203 | % - label: 定義標籤前綴標號
204 | % - sep: 定義標號與標題內容間隔距離
205 | % - before: 標題內容前增加文字
206 | % - after: 標題內容後增加文字
207 | \titlespacing{\chapter}{0pt}{0pt}{7ex}
208 |
209 | % chapter
210 | \titleformat
211 | {\chapter}[display]
212 | {\normalfont\LARGE\sffamily\hwyk}
213 | {\filleft\LARGE \myheader{第\ \thechapter\ 章}}
214 | {1ex}
215 | {\titlerule\vspace{.5ex}\filright\LARGE\myheader}
216 | [\vspace{.5ex} \titlerule]
217 |
218 | % section
219 | \titleformat
220 | {\section}[hang]
221 | {\Large\sf\hwyk}
222 | {\myheader\thesection}
223 | {1em}
224 | {\myheader}
225 |
226 | % subsection
227 | \titleformat
228 | {\subsection}[hang]
229 | {\large\sffamily\hwyk}
230 | {\myheader\thesubsection}
231 | {1em}
232 | {\myheader}
233 |
234 | % subsubsection
235 | \titleformat
236 | {\subsubsection}[hang]
237 | {\normalsize\sffamily\hwyk}
238 | {\myheader\thesubsubsection}
239 | {1em}
240 | {\myheader}
241 |
242 | % [目錄格式]
243 | %
244 | \titlecontents
245 | {chapter}[2em]
246 | {\large\sf\hwyk\addvspace{-0.1em}}
247 | {\contentslabel{2em}}
248 | {}
249 | {\titlerule*[0.8pc]{.}\contentspage}
250 |
251 | \titlecontents
252 | {section}[4em]
253 | {\small\addvspace{-0.2em}}
254 | {\contentslabel{3em}}
255 | {}
256 | {\titlerule*[0.8pc]{.}\contentspage}
257 |
258 | \titlecontents
259 | {subsection}[6em]
260 | {\small\addvspace{-0.2em}}
261 | {\contentslabel{3em}}
262 | {}
263 | {\titlerule*[0.8pc]{.}\contentspage}
264 |
265 | % --------------------------------------------------
266 | % 07 其他設定 (Others)
267 | % --------------------------------------------------
268 |
269 | % [背景顏色]
270 | \special{ pdf: bgcolor [ 1.00 0.98 0.95 ] }
271 |
272 | % [調整字距]
273 | \renewcommand{\CJKglue}{\hskip -0.3pt plus 0.08\baselineskip}
274 |
275 | % [調整行距]
276 | \linespread{1.382}
277 |
278 | % [表格行距]
279 | \renewcommand{\arraystretch}{1.2}
280 |
281 | % [段落縮排]
282 | \parindent=0pt % 設置為 0 表示不縮排
283 |
284 | %% 縮小 quote 為正常行距,並使用較小字體
285 | \renewenvironment{quote}{
286 | \list{}{\topsep 0ex\parsep 0ex\setlength\leftmargin{1.5em}%
287 | \rightmargin\leftmargin}\item\relax\linespread{1.0}\small
288 | }%
289 | {\endlist}
290 |
291 | % [腳注行距]
292 | % 由於把行距加大,要把腳注的行距縮成預設值,此設定採自
293 | % 吳聰敏教授的《cwTeX 排版系統》修訂二版一書,頁 143
294 | \let\oldfootnote\footnote
295 | \renewcommand\footnote[1]{\oldfootnote{\renewcommand\baselinestretch{1.0}%
296 | \large\footnotesize\ignorespaces#1}}
297 | \addtolength{\footnotesep}{3pt}
298 |
299 | % [版面調整]
300 | \addtolength{\textwidth}{1in}
301 | \addtolength{\oddsidemargin}{-.5in}
302 | \addtolength{\textheight}{1in}
303 | \addtolength{\topmargin}{-.5in}
--------------------------------------------------------------------------------
/main.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TeXtw/LaTeX123/ea2946802e7f15dd9eac64ffe0dada2f5b8507e9/main.pdf
--------------------------------------------------------------------------------
/main.tex:
--------------------------------------------------------------------------------
1 | % --------------------------------------------------
2 | % 《大家來學 LaTeX》版權聲明
3 | % --------------------------------------------------
4 | % Copyright (c) 2004 Edward G.J. Lee
5 | %
6 | % 在不違反 GNU Free Documentation License 1.2 或以後的版本規範之下,
7 | % 允許拷貝、散佈或修改。但原版權、授權聲明不得移除。
8 | %
9 | % 本散佈版本,含有 fdl.tex,內容為 GNU FDL 的規範原文。如果遺失,可由
10 | % http://www.gnu.org 取得,或寫信至自由軟體基金會(Free Software Fundation)
11 | % 索取。
12 | %
13 | \documentclass{latex123}
14 |
15 | \input{docsetup}
16 |
17 | \begin{document}
18 |
19 | % 封面
20 | % Cover
21 | \makecover
22 |
23 | % 目錄
24 | % Contents of Tables
25 | \maketableofcontents
26 |
27 | % 正文
28 | % Contents
29 | \mainmatter
30 | \input{contents/chapter01} % story.tex
31 | \input{contents/chapter02} % preparation.tex
32 | \input{contents/chapter03} % syntax.tex
33 | \input{contents/chapter04} % start.tex
34 | \input{contents/chapter05} % space.tex
35 | \input{contents/chapter06} % class.tex
36 | \input{contents/chapter07} % package.tex
37 | \input{contents/chapter08} % table.tex
38 | \input{contents/chapter09} % graphic.tex
39 | \input{contents/chapter10} % math.tex
40 | \input{contents/chapter11} % abook.tex
41 | \input{contents/chapter12} % theend.tex
42 | \input{contents/chapter13} % fdl.tex
43 | \input{contents/references}
44 | \input{contents/license}
45 |
46 | % 索引
47 | % Index
48 | \printindex
49 |
50 | \end{document}
--------------------------------------------------------------------------------