LaTeX與SGML的範例

LaTeX的範例

底下先來看一個例子大概30分鐘後就會寫LaTeX SGML文件了。
\documentclass[]{article}
\usepackage{CJK}
\begin{document}

	\title{Test Plan for Automation System}
	\author{
	Cyril Huang\\
	Veritas Software
	\and 
	HaiShan Chen \\
	Alcatel Systems}
	\maketitle

	\begin{abstract}
	Text for abstract: This is a demostration of what a document 
	should be. We
	don't need to care about what the document looks like, but the 
	content itself
	\end{abstract}

	\section{Introduction}
	If this is a book, then it must be a book.
	\\\\
	This is the second paragrph, we try to see what's going on
	here and try to make it multiple paragraphs.
	The following is a literal text, that is all text between
	\verb=\begin{verbatim}= and \verb=\end{verbatim}=
	are not be intepreted by TeX system
	\\\\
	And this is \emph{emphasize text}, not bad.

	\section{Real Meat}
	The following contents is a demo of list and table
	
	\begin{itemize}
	\item
	This is item 1, try to make the item length to a long length that will
	oversize a normal line to see what happen.
	\item
	This is item 2
	\end{itemize}
	
	%\begin{table}
	  %\caption{test case}
	  \begin{tabular}{|r|p{6cm}||c|r|}\hline
	  Test Case ID & TC Description & (Pass/Fail) & Comments\\ \hline
	  1	       & 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 
			                &             &         \\ \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{CJK}{Bg5}{kai}
	  \subsection{中文使用}
	  說中文也通喔
	\end{CJK}

	\section{Mathmatical Game}
	We know the math is the most beautiful language in the world,
	therefore, we need a beautiful tool to write such language.
	\LaTeX is no doubt the best one.
	\\\\
	Here is the example of math in the same text line 
	$\sum_{i=1}^n a_i \int_a^b \alpha_i(x)\beta_i(x)\,\mathrm{d}x$\\
	example of math in a seperate line
	\[\sum_{i=1}^n a_i \int_a^b \alpha_i(x)\beta_i(x)\;\mathrm{d}x\]
	    
\end{document}
	

SGML的範例

<!doctype article PUBLIC "-//OASIS//DTD DocBook V3.1//EN" []>
<article>
  <title>Test Plan for Automation Test</title>
  <artheader>
    <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>H.C</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>
  </artheader>

  <abstract>
    <para>
      Text for abstract: This is a demostration of what a document 
      should be. We
      don't need to care about what the document looks like, but the 
      content itself
    </para>
  </abstract>

  <sect1 id=intro>
    <title>Introduction</title>
    <para>
      If this is a book, then it must be a book.
    </para>
    <para>
      This is the second paragrph, we try to see what's going on
      here and try to make it multiple paragraphs.
      The following is a literal text, that is all text between
      <literal>&lt;literal> and &lt;/literal> </literal>
      are not be intepreted by SGML system
    </para>
    <para>
      And this is <emphasis>emphsized text</emphasis>, not bad.
    </para>
  </sect1>
  <sect1>
    <title>Real Meat</title>
    <para>
      The following contents is a demo of list and table
      <itemizedlist>
	<listitem>
	  <para>
	    This is item 1, try to make the item length to a long 
	    length that will oversize a normal line to see what happen.
	  </para>
	</listitem>
	<listitem>
	  <para>
	    This is item 2
	  </para>
	</listitem>
      </itemizedlist>

      <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=center>
	  <spanspec spanname=hspan1 namest=c1 nameend=c2 align=left>
	  <spanspec spanname=hspan2 namest=c3 nameend=c4 align=left>

	  <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>
	    
	    <row>
	      <entry spanname=hspan1> </entry>
	    </row>
	  </tbody>
	</tgroup>
      </table>
    </para>
  </sect1>
</article>
	

範例結果

pdf file from SGML

ps file from SGML

HTML file from SGML

rtf file from SGML

sgml source

pdf file from TeX

ps from TeX

HTML file from TeX

TeX source