文件的組成架構中有個像寫C程式般的框架,然後處理程式根據框架來處理。 其實一份文件就是我們以前說的八股文, 要寫好八股文也不是簡單事,主要是有內容的八股文,通常要有起承轉合, 一份LaTeX或SGML文件,像這樣子
LaTeX框架
\documentclass{article} (\documentstyle是\LaTeX 2.09版的寫法)
\usepackage{CJK}
\begin{document}
......
\end{document}
|
SGML 框架
<!doctype book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" []> <book> ...... </book> |
一份文件的屬性是什麼 決定了這個輸出應該要有什麼樣的樣子, 例如最常見到的兩種型態book 與article, 一本書(book) 通常有目錄(table of content) 有章節 有索引(index), 相對的文章(article)可能就不需要目錄了。 其他的可能像信件(Letter)或備忘錄(MEMO)等等都算是一種文件屬性, 不同文章屬性有不同的格式需求,所以要寫作前,要先設定文章的屬性為何, 讓處理程式有辦法往下處理。
在LaTeX的例子裡 我們用
\documentclass{book}
\documentclass{article}
\documentclass{report}
|
在sgml裡 我們用
<!doctype book xxxx> <book> xxxxx </book> <!doctype article xxxxx> <article> xxxx </article> |
通常一本書或一篇文章除了內容外還有其它資訊, 例如書名作者出版商等資訊還有像ISBN編號等, 這些資訊叫metadata,也就是說不屬於正式內容但是很重要的資訊, 所以緊跟著框架與文件屬性後通常就是metadata。
LaTeX
\title{Test Plan for Automation System}
\author{
Cyril Huang\\
Veritas Software
\and
HaiShan Chen\\
Alcatel Systems}
\maketitle
也可以用
\beign{title}
xxxx
\end{title}
|
SGML
<author>
<firstname>Cyril</firstname>
<surname>Huang</surname>
<affiliation>
<orgname>Veritas Software</orgname>
</affiliation>
</author>
<author>
<firstname>HaiShan</firstname>
<surname>Chen</surname>
<affiliation>
<orgname>Alcatel Systems</orgname>
</affiliation>
</author>
<revhistory>
<revision>
<revnumber>0.1</revnumber>
<date>13 Mar 2001</date>
<authorinitials>C.H</authorinitials>
<revremark>first draft</revremark>
</revision>
<revision>
<revnumber>0.2</revnumber>
<date>25 Apr 2001</date>
<authorinitials>C.H</authorinitials>
<revremark>Second draft</revremark>
</revision>
</revhistory>
|
其中LaTeX是由\maketitle來完成,所以叫\maketitle前, 要先把\title \author寫好, \\在\LaTeX中代表newline換行, 日期會自己印出來, 在article中只會印成像論文般的header, 如果想另成一個page,要寫成 \documentclass[titlepage]{article}。
sgml的metadata如果是在book時要夾在<bookinfo></bookinfo>, article是在<artheader></artheader>, SGML裡不只這些還有更多的標籤可以用。
正式文件裡有些元素是需要的, 例如論文中我們通常都要有個摘要(abstract)來貫穿整個文章, 另外文件裡其它的常聽到的元素就是章節段落了。
LaTeX
\begin{abstract}
xxxx
\end{abstract}
|
SGML
<abstract> xxxx </abstract> |
LaTeX
\chapter{This is Chapter 1 Title}
|
SGML
<chapter> <title>This is Chapter 1 Title</title> </chapter> |
LaTeX
\section{The Section 1 title}
\subsection{The Section 1.1 title}
\subsubsection{The Section 1.1.1 title }
|
SGML
<sect1> <title> The Section 1 title </title> <sect2> <title> The Section 1.1 title </title> <sect3> <title> The Section 1.1.1 title </title> |
1 The Section 1 title 1.1 The Section 1.1 title 1.1.1 The Section 1.1.1 title |
LaTeX
\\\\ \par |
SGML
<para> xxxx </para> |
SGML比較囉唆一點的是很多文字部份有時一定要para這個標籤, 不過如果少了也沒關係,有時還是可以轉成我們想要的格式檔出來。
LaTeX
\begin{itemize}
\item item1
\item item2
\end{itemize}
|
SGML
<itemizedlist>
<listitem>
<para>
item1
</para>
</listitem>
<listitem>
<para>
item2
</para>
</listitem>
</itemizedlist>
|
LaTeX
\begin{enumerate}
\item item1
\item item2
\end{enumerate}
|
SGML
<orderedlist>
<listitem>
<para>
item1
</para>
</listitem>
<listitem>
<para>
item2
</para>
</listitem>
</orderedlist>
|
表格是比較複雜的元素之一
LaTeX
\begin{table}
\caption{Test Cases}
\begin{tabular}{r|p{6cm}|l|c}\hline
Test Case ID & Test Case Descriptions & (pass/fail) & Comment \\ \hline
1 &
Installation Test: This test is for the Solaris pkgtools
test, give the command pkgadd -d /pkg/dir to test if the installation
is correct & & \\ \hline\hline
2 & Another test & \multicolumn{2}{|c|}{}\\ \cline{1-2}
\multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{}\\ \hline
\multicolumn{4}{|c||}{This is foot of Table} \\ \hline
\end{tabular}
\end{table}
|
\begin{tabular}開始做表格
|
{r|p{6cm}|l|c}
|
第一欄內文字向右對齊 第二欄位寬6公分,不這樣定會一欄只有一個很長的行的文字 第三欄向左對齊 第四欄向中對齊 |表示要畫垂直格線||表示畫兩道 |
\hline表示要畫橫格線 \hline\hline就會畫兩條橫線 |
\cline{1-2}表示從第一欄畫橫線到第二欄,
\multicolumn{4}{|c||}{This is foot of Table}
表示接下來的4個欄位看成一欄,裡面文字(This is foot of Table)置中對齊
三個中括號是這個命令的參數,一定要有
|
SGML
<table frame='all'>
<title>Test Cases</title>
<tgroup cols='4'>
<colspec colname=c1 colwidth="1*">
<colspec colname=c2 colwidth="7*">
<colspec colname=c3 colwidth="2*">
<colspec colname=c4 colwidth="2*">
<spanspec spanname=hspan0 namest=c1 nameend=c4 align=left>
<spanspec spanname=hspan1 namest=c1 nameend=c2 align=left>
<spanspec spanname=hspan2 namest=c3 nameend=c4 align=center>
<thead>
<row>
<entry>TC ID</entry>
<entry>Test Case Description</entry>
<entry>(pass/fail)</entry>
<entry>Comment</entry>
</row>
</thead>
<tfoot>
<row>
<entry spanname=hspan0>This is foot of Table</entry>
</row>
</tfoot>
<tbody>
<row>
<entry>1</entry>
<entry>
Installation Test
This test try to check if the installation of pkg.
give the command pkgadd -d /pkg/dir to test if
the installation is correct
</entry>
<entry> </entry>
<entry> </entry>
</row>
<row>
<entry>2</entry>
<entry>Another Test</entry>
<entry spanname=hspan2 morerows=1> </entry>
</row>
</tbody>
</tgroup>
</table>
|
<table> frame=all表示要格線 <tgroup> <colspec> 欄位名字定義,欄位寬度,1*表示一個單位,所以第一欄佔了1/12總寬度 <spanspec> 把多欄看成一欄的定義 名字 起始與結束欄位名 <thead> 表格的頭 <tfoot> 腳 <tbody> 身體 |
還有很多命令與標籤 可以隨心所欲的製作出想要的表格來, 不過基本上這已經很好用了。