Created
January 12, 2012 04:12
-
-
Save lyhcode/1598651 to your computer and use it in GitHub Desktop.
XeTeX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass[12pt,a4paper]{article} | |
| \usepackage[cm-default]{fontspec} | |
| \usepackage{xunicode} | |
| \usepackage{xltxtra} | |
| \usepackage{fontspec} %設定字型 | |
| \usepackage[slantfont,boldfont]{xeCJK} | |
| %\usepackage{xeCJK} %中英文分開設定 | |
| \usepackage{color} | |
| \usepackage{xcolor} | |
| \usepackage{listings} | |
| \usepackage{caption} | |
| %程式碼區塊 | |
| \DeclareCaptionFont{white}{\color{white}} | |
| \DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}} | |
| \captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white} | |
| %程式碼區塊 | |
| \newenvironment{mylisting} | |
| {\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries} | |
| {\end{list}} | |
| \newenvironment{mytinylisting} | |
| {\begin{list}{}{\setlength{\leftmargin}{1em}}\item\tiny\bfseries} | |
| {\end{list}} | |
| %中文自動換行 | |
| \XeTeXlinebreaklocale "zh" | |
| \XeTeXlinebreakskip = 0pt plus 1pt | |
| %\setromanfont{LiHei Pro} % 儷黑Pro | |
| %\setmonofont{Courier New} % 等寬字型 | |
| \setromanfont{Apple LiSung Light} | |
| \setmonofont{Courier New} | |
| %\setCJKmainfont{標楷體} | |
| %\setromanfont{DejaVu Sans} | |
| %\setromanfont{AR PL UMing TW} %細明體 | |
| %\font\ming="新細明體" at 12pt | |
| \begin{document} | |
| \title{啟動程式設計思考力} | |
| \author{tungsh} | |
| \maketitle | |
| \section{Java物件導向程式設計} | |
| Java 是一個\textbf{物件導向}程式語言。物件導向的基本觀念是讓程式可以描述、建構及處理真實世界中所看到的物件並設計它們之間的層次關係。例如:\textit{Exam 可以有 EnglishExam、ChineseExam 兩個副屬的種類}。而一次 EnglishExam 又可以有任意數量的考生應考,其中每一份考卷中都可以有考生姓名與成績的資料。這時 Exam、EnglishExam 及 ChineseExam 便很適合設計成類別,而一份英文考試的考卷便可以用 EnglishExam 這個類別所生成的實例(instance or object)來代表。 | |
| 一個類別可以使用 new 指令來產生實例。一個 Java 的程式可以由許多個有層次關係的類別構成,這個層次關係描述這些類別間的繼承關係。這一類的例子在真實世界中不勝枚舉,舉例來說:如果「哺乳類」是一個類別,那麼「人類」則可以是「哺乳類」的一個「子類別」(subclass or subtype),相對的「哺乳類」也可以是「人類」的「父類別」(superclass or supertype)。而某一個人「張三」便是「人類」的一個「實例」。 | |
| 以「張三」這個實例來說,他的身高、體重、性別等資料都可以存放在這個實例的「實例變數」中,而「張三」能「跑」能「跳」,則可以是它的「實例方法」。簡單的說:「類別(class)」可以用 new 來產生「實例(instance)」,而「實例」可以包含「實例變數」與「實例方法」。其中「實例變數」負責資料的儲存,而「實例方法」則負責資料的處理: | |
| \begin{math} | |
| \begin{array}{ *{3} {c @{+}} c @{=} c} | |
| a_{11}x_1 & a_{21}x_1 & \cdots & a_{1n}x_n & b_1 \\ | |
| a_{12}x_1 & a_{22}x_1 & \cdots & a_{2n}x_n & b_2 \\ | |
| \multicolumn{5}{c}{\dotfill} \\ | |
| a_{m1}x_1 & a_{m2}x_1 & \cdots & a_{mn}x_n & b_m \\ | |
| \end{array} | |
| \end{math} | |
| \subsection{source code sample 1} | |
| \begin{mylisting} | |
| \begin{verbatim} | |
| class Book { | |
| String name = "Sun"; | |
| String getName() { | |
| return name; | |
| } | |
| } | |
| public class Ex2 { | |
| public static void main(String argv[]) { | |
| Book b1 = new Book(); | |
| Book b2 = new Book(); | |
| System.out.println("Name of b1:" + b1.getName()); | |
| System.out.println("Name of b2:" + b2.getName()); | |
| } | |
| } | |
| \end{verbatim} | |
| \end{mylisting} | |
| \subsection{source code sample 2} | |
| \begin{lstlisting}[label=some-code,caption=Some Code] | |
| public void here() { | |
| goes().the().code() | |
| } | |
| \end{lstlisting} | |
| \end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment