顯示具有 Programs-LaTeX 標籤的文章。 顯示所有文章
顯示具有 Programs-LaTeX 標籤的文章。 顯示所有文章

2015年12月4日 星期五

寫一個 Script 產生 Reference 格式(網頁資料)

寫一個 Shell Script → refCreate.sh
#!/bin/bash
#
# latex reference create

if [ -z $1 ]; then
        echo ======== refCreate_latex.sh [ref.txt] ============
        exit
fi

DATE=`date +%Y-%m-%d`
FILE=$1
COUNT=`cat $FILE | wc -l`

for i in `seq 1 ${COUNT}`
do
RN=ref${i}
TITLE=`cat $FILE | cut -d '|' -f 1 | sed -n ${i}p`
URL=`cat $FILE | cut -d '|' -f 2 | sed -n ${i}p`

echo "
@misc{${RN},
        title={${TITLE}},
        howpublished={\url{${URL}}},
        note={Accessed:${DATE}}
}"
done

echo ============ Latex nocite create ===========
echo -n "\\nocite{"
for i in `seq 1 $COUNT`
do
        if [ $i != $COUNT ]; then
        echo -n "ref${i},"
        else
        echo -n "ref${i}}"
        fi
done
echo
echo

---
寫一個 ref.txt 整理需要放上的資料,格式為: Title|URL
(※注意中間使用管線 | 來分隔 Title 及 URL,並用 enter 換行分隔參考資料) 
例 --
Java Gossip: 實作 Runnable 介面|http://openhome.cc/Gossip/JavaGossip-V2/RunnableInterface.htm
Generate a random point within a circle (uniformly)|http://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly
Animation_2D Graphics GUI_Java|http://www.java2s.com/Code/Java/2D-Graphics-GUI/Animation.htm
Animation|http://zetcode.com/tutorials/javagamestutorial/animation/
(swing)輸入帳密視窗|http://blog.xuite.net/ray00000test/blog/21526707-(swing)%E8%BC%B8%E5%85%A5%E5%B8%B3%E5%AF%86%E8%A6%96%E7%AA%97
給初學 Android 的你|http://kenji-chao.blogspot.tw/2013/02/android.html
---
用法:
chmod +x refCreate.sh
./refCreate.sh ref.txt
---
輸出:
@misc{ref1,
        title={Java Gossip: 實作 Runnable 介面},
        howpublished={\url{http://openhome.cc/Gossip/JavaGossip-V2/RunnableInterface.htm}},
        note={Accessed:2015-12-04}
}

@misc{ref2,
        title={Generate a random point within a circle (uniformly)},
        howpublished={\url{http://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly}},
        note={Accessed:2015-12-04}
}

@misc{ref3,
        title={Animation_2D Graphics GUI_Java},
        howpublished={\url{http://www.java2s.com/Code/Java/2D-Graphics-GUI/Animation.htm}},
        note={Accessed:2015-12-04}
}

@misc{ref4,
        title={Animation},
        howpublished={\url{http://zetcode.com/tutorials/javagamestutorial/animation/}},
        note={Accessed:2015-12-04}
}

@misc{ref5,
        title={(swing)輸入帳密視窗},
        howpublished={\url{http://blog.xuite.net/ray00000test/blog/21526707-(swing)%E8%BC%B8%E5%85%A5%E5%B8%B3%E5%AF%86%E8%A6%96%E7%AA%97}},
        note={Accessed:2015-12-04}
}

@misc{ref6,
        title={給初學 Android 的你},
        howpublished={\url{http://kenji-chao.blogspot.tw/2013/02/android.html}},
        note={Accessed:2015-12-04}
}
============ Latex nocite create ===========
\nocite{ref1,ref2,ref3,ref4,ref5,ref6}
---

於所要編寫的 .tex 檔內,加入參考資料語法:
\begin{filecontents}{\jobname.bib}
@misc{ref1,
        title={Java Gossip: 實作 Runnable 介面},
        howpublished={\url{http://openhome.cc/Gossip/JavaGossip-V2/RunnableInterface.htm}},
        note={Accessed:2015-12-03}
}

@misc{ref2,
        title={Generate a random point within a circle (uniformly)},
        howpublished={\url{http://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly}},
        note={Accessed:2015-12-03}
}

@misc{ref3,
        title={Animation\_2D Graphics GUI\_Java},
        howpublished={\url{http://www.java2s.com/Code/Java/2D-Graphics-GUI/Animation.htm}},
        note={Accessed:2015-12-03}
}

@misc{ref4,
        title={Animation},
        howpublished={\url{http://zetcode.com/tutorials/javagamestutorial/animation/}},
        note={Accessed:2015-12-03}
}

@misc{ref5,
        title={(swing)輸入帳密視窗},
        howpublished={\url{http://blog.xuite.net/ray00000test/blog/21526707-(swing)%E8%BC%B8%E5%85%A5%E5%B8%B3%E5%AF%86%E8%A6%96%E7%AA%97}},
        note={Accessed:2015-12-03}
}

@misc{ref6,
        title={給初學 Android 的你},
        howpublished={\url{http://kenji-chao.blogspot.tw/2013/02/android.html}},
        note={Accessed:2015-12-03}
}
\end{filecontents}
---
並加到所要顯示的頁面,以 \nocite 來加入:
\section{Reference}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}[allowframebreaks]
        \frametitle{Reference}
        \nocite{ref1,ref2,ref3,ref4,ref5,ref6}
        \tiny{\bibliographystyle{abbrv} }       % 文獻標號
        \bibliography{\jobname}                 % 文獻來源
\end{frame}


2015年6月15日 星期一

Beamer 範本2:專題研討課程 PPT


檢視:USB_Joystick.pdf
下載:USB_Joystick.tex

編譯方式 (若有 .bib 檔可能需要先 rm 刪除掉):
xelatex USB_Joystick
bibtex USB_Joystick
xelatex USB_Joystick
xelatex USB_Joystick

evince USB_Joystick.pdf

% Latex Beamer - USB Joystick 
% 2015/06/17
%===============================================================
% LaTeX Beamer environment setting
\documentclass[xetex,mathserif,serif,xcolor=dvipsnames]{beamer}

% 解決 XeTeX 中文的斷行問題
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt

\usepackage{color, colortbl}
\usepackage{caption}
\usepackage{url, hyperref}
\captionsetup{skip=0pt,belowskip=0pt}
%===============================================================
%% 字型 Fonts Setting
%% Reference: http://hyperrate.com/thread.php?tid=23544
% 預設英文字體
\usepackage{arevmath}
\usepackage[no-math]{fontspec}
\setmainfont[Scale=0.9]{DejaVuSansMono}

% 預設中文字體
\usepackage[CJKchecksingle, normalindentfirst, SlantFont, BoldFont]{xeCJK}
\setCJKmainfont{金梅新中楷國際碼}

% 自定義字體切換指令
% 中文
\newfontfamily{\J}{金梅新中楷國際碼}
\newfontfamily{\B}{華康中黑體}

% 英文
\newfontfamily{\D}[Scale=0.9]{DejaVuSansMono}
\newfontfamily{\T}{Times New Roman}
\newfontfamily{\A}{Arial}

% 粗體字
% \textbf{內容}
%===============================================================
%% Theme 設定主題樣式
\usetheme{Madrid}
%===============================================================
%% Color Theme設定投影片顏色
\usecolortheme{beaver}
%===============================================================
% 設定列表樣式
% 可以選擇:ball, circle, rectangle, default
\setbeamertemplate{items}[ball]
\setbeamertemplate{caption}[numbered]
%===============================================================
%隱藏 beamer 底部小工具列
\setbeamertemplate{navigation symbols}{}
%====================================================================
% 重設 frametitle 的預設為置中,上方的 usetheme 要改為 [height=0]
\setbeamertemplate{frametitle}[default][center]
%==============================================================================
%% Reference Table
% https://zh.wikipedia.org/wiki/BibTeX
% http://tex.stackexchange.com/questions/68080/beamer-bibliography-icon
\begin{filecontents}{\jobname.bib}
@article{ref1,
        author={林永昌},
        title={USB規格與技術},
        journal={CCL TECHNICAL JOURNAL},
        pages={26--32},
        volume={103期},
        year={2003-03-25}
}

% http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5776968
@article{ref2,
        author={Yung-Hoh Sheua, Tsun-Hsiang Fu, Chun-Ming Ku},
        title={The Design of FlexRay/CAN/LIN Protocol Analyzer},
        pages={5466--5469},
        year={2011},
        journal={Electric Information and Control Engineering (ICEICE)}
}

% http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6287165
@article{ref3,
        author={Nurul Fatihah Jusoh, Muhammad Adib Haron, Fuziah Sulaiman },
        title={An FPGA Implementation of Shift Converter Block
Technique on FIFO for RS232 to Universal Serial
Bus Converter},
        pages={219--224},
        year={2012},
        journal={Control and System Graduate Research Colloquium (ICSGRC)}
}

% http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6168758
@article{ref4,
        author={Nurul Fatihah Jusoh, Azlina Ibrahim, Muhamad Adib Haron and Fuziah Sulaiman},
        title={An FPGA Implementation of Shift Converter Block
Technique on FIFO for UART},
        pages={320--324},
        year={2011},
        journal={RF and Microwave Conference (RFM)}
}

@book{b1,
    title={USB 2.0 系統開發實例精解},
    author={廖濟林},
    isbn={9789861990040},
    year={2007},
    publisher={城邦文化事業股份有限公司},
    keywords = {USB}
}

@book{b2,
    title={USB 2.0 原理與研發技術},
    author={王成儒、李英偉},
    isbn={9572152688},
    year={2006},
    publisher={全華科技圖書股份有限公司},
    keywords = {USB}
}

@book{b3,
    title={微處理機與 USB 主從介面之設計與應用},
    author={許永和},
    isbn={9574997677},
    year={2006},
    publisher={儒林圖書有限公司},
    keywords = {USB}
}

@book{b4,
    title={USB 規格與理論剖析},
    author={許永和},
    isbn={9789574998692},
    year={2009},
    publisher={儒林圖書有限公司},
    keywords = {USB}
}

@book{b5,
    title={USB 應用開發技術大全},
    author={薛園園},
    isbn={9789862041529},
    year={2008},
    publisher={文魁資訊股份有限公司},
    keywords = {USB}
}

@online{arduino,
        author={Circuits@Home},
        title={USB Host Shield 2.0 for Arduino},
        howpublished={\url{https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino}},
        note={Accessed:2015-06-08}
}

@misc{p1,
        title={USB Protocol Analyzer},
        yesr={2013},
        howpublished={\url{http://goods.ruten.com.tw/item/show?21303303948219}},
        note={Accessed:2015-06-08}
}

@misc{p2,
        title={Beagle USB 12 Protocol Analyzer},
        howpublished={\url{http://www.totalphase.com/products/beagle-usb12/}},
        note={Accessed:2015-06-08}
}

@misc{p3,
        title={MQP Electronics Packet-Master USB 12},
        howpublished={\url{http://www.mqp.com/usbdev_buy.htm}},
        note={Accessed:2015-06-08}
}

@misc{p4,
        title={ITIC 1480A USB 2.0 Protocol Analyzer},
        howpublished={\url{http://www.internationaltestinstruments.com/products/97-1480a-usb-20-protocol-analyzer.aspx}},
        note={Accessed:2015-06-09}
}

@misc{p5,
        title={Elisys USB Explorer 200 Basic},
        howpublished={\url{http://www.ellisys.com/products/usbex200/}},
        note={Accessed:2015-06-09}
}

@misc{p6,
        title={LeCroy Conquest Standard},
        howpublished={\url{http://teledynelecroy.com/protocolanalyzer/}},
        note={Accessed:2015-06-09}
}

@misc{mcp2200,
        title={MCP2200},
        howpublished={\url{http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en546923}},
        note={Accessed:2015-06-06}
}

@misc(ncku,
        title={USB (Universal Serial Bus)},
        author={成大資工},
        howpublished={\url{http://wiki.csie.ncku.edu.tw/embedded/USB}},
        note={Accessed:2015-06-13}
}

@misc{zeroplus,
        title={USB2.0信號分析技巧},
        author={ZEROPLUS},
        howpublished={\url{http://www.zeroplus.com.tw/E-paper/201112/images/201112-USB20ProtocolAnalyzer.pdf}},
        note={Accessed:2015-06-13}
}
\end{filecontents}
%==============================================================================
%% Reference Setting 參考文獻環境設定
%% https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM
%% http://tex.stackexchange.com/questions/147279/references-at-the-end-of-beamer-slides
\usepackage{cite}
\usepackage{natbib}

%\usepackage{natbib}
%\usepackage{bibtex}
%\usepackage{bibentry}
%\usepackage{chngcntr}
%\bibliographystyle{apalike}
%%%\bibliographystyle{stylename}
%
%\setbeamercolor*{bibliography entry title}{fg=black}
%\setbeamercolor*{bibliography entry author}{fg=black}
%\setbeamercolor*{bibliography entry location}{fg=black}
%\setbeamercolor*{bibliography entry note}{fg=black}
%\setbeamertemplate{bibliography item}{}
%%\setbeamertemplate{bibliography item}{\insertbiblabel}
%\setbeamertemplate{frametitle continuation}[from second]
%
%\counterwithin*{footnote}{page}
%\newcommand\fcite[1]{\footnote{\tiny \bibentry{#1}}\label{\thepage:#1}}
%\newcommand\scite[1]{\textsuperscript{\ref{\thepage:#1}}}
%
%\nobibliography{\jobname}
%==============================================================================
\begin{document}
%==============================================================================
\title[\tiny USB sniffer with the Arduino]{\huge USB sniffer with the Arduino}
\author[\tiny MA330101 廖凱霖]{\\MA330101 廖凱霖}
\date[\tiny 2015/06/17]{2015/06/17}
%==============================================================================
%%% 投影片開始 Frame Start

% Title
\frame{\titlepage}

% Outline
\frame{ \frametitle{Outline}
        \tableofcontents}

% Abstract
% 做什麼東西,用什麼方法,得到什麼結果
\section{摘要}
\frame{ \frametitle{摘要}
\begin{itemize}[<+->]
        \item 做 USB (Universal Serial Bus) 訊號封包解析儀。
        \item 自動解碼,直接得到封包、資料。
        \begin{figure}
                \centering
                \includegraphics[width=0.6\textwidth]{analyzer.jpeg}
                \caption{USB 解析儀架構圖}
        \end{figure}
\end{itemize}
}

%Action 
\section{研究動機}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{研究動機 1/2}
\begin{itemize}[<+->]
        \item 產學合作:「做 PlayStation 4 格鬥搖桿台」。
        \item 實驗室舊型號邏輯分析儀不支援 USB 解析。
        \item 封包做解碼及列表整理需花大量時間。
\end{itemize}
}

%
\frame{ \frametitle{研究動機 2/2}
\begin{itemize}
        \item 市場調查:
        \begin{itemize}
                \item 市面上 USB 封包解析儀,價格昂貴 (至少壹萬元起跳)。
                \item 整合太多功能,操作複雜。
        \end{itemize}
\end{itemize}
% -------------
\captionof{table}{USB 分析儀市場調查表}
\begin{table}[h]
\begin{tabular}{|l|r|}
\hline
\rowcolor[HTML]{000000}
\multicolumn{1}{|c|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} 產品名稱}} & \multicolumn{1}{c|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} 市售價格}} \\ \hline
USB Protocol Analyzer                                                     & NT\$10,500                                                               \\ \hline
Beagle USB 12 Protocol Analyzer                                           & NT\$14,777                                                               \\ \hline
MQP Electronics Packet-Master USB 12                                      & NT\$15,698                                                               \\ \hline
ITIC 1480A USB 2.0 Protocol Analyzer                                      & NT\$21,621                                                               \\ \hline
Elisys USB Explorer 200 Basic                                             & NT\$24,856                                                               \\ \hline
LeCroy Conquest Standard                                                  & NT\$37,300                                                               \\ \hline
\end{tabular}
\end{table}
\nocite{p1,p2,p3,p4,p5,p6}
%-------------
}

%background 
\section{研究背景及知識}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{研究背景及知識 1/5}
\nocite{b1,b2,b5,b3,b4,ref1}
\begin{itemize}[<+->]
        \item 無時脈訊號 (Clock Signal)。
        \item 使用兩條差動訊號 D+/D- 做資料傳遞。
        \item 定義訊號 `1':(D+) - (D-) > 200mV \\
                定義訊號 `0':(D+) - (D-) < -200mV
\end{itemize}
}

%background 
\frame{ \frametitle{研究背景及知識 2/5}
\begin{itemize}[<+->]
        \item 使用 NRZI(Non-Return to Zero Inverted) 編碼:\\
                設起始狀態 H,資料 `0' 狀態反向;`1' 狀態保持原來。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{NRZI.jpeg}
        \caption{NRZI 編碼流程圖}
\end{figure}
}
%
\frame{ \frametitle{研究背景及知識 3/5}
\begin{itemize}
        \item USB 一個完整的傳輸單位:資訊交易 (Transaction)。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.9\textwidth]{transation.jpeg}
        \caption{單個 Transation 架構圖}
\end{figure}
}
%
\frame{ \frametitle{研究背景及知識 4/5}
\begin{itemize}
        \item 封包組成格式\cite{zeroplus}:
\begin{itemize}
        \item 同步序列:取代 Clock 來同步資料。
        \item PID:定義封包類型。
        \item 封包具體資訊:封包資料內容(依 PID 而有所不同)。
        \item CRC:檢查錯誤。
        \item EOP:結束封包 (回到 idle ) 狀態。
\end{itemize}
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.9\textwidth]{packet.jpeg}
        \caption{封包 Padket 基本格式}
\end{figure}
}
%
\frame{ \frametitle{研究背景及知識 5/5}
\begin{itemize}
        \item 資料型態辨別:PID (Packet ID)。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[height=0.72\textheight]{0015.jpg}
        \caption{PID Types\cite{ncku}}
\end{figure}
}

%% 
\section{文獻回顧及探討}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{文獻回顧及探討}
\begin{itemize}
        \item 參考文獻 \cite{ref3,ref4},以 FPGA 實作 UART to USB 訊號轉換器。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{uarttousb.jpg}
        \caption{FIFO 轉換圖框}
\end{figure}
}

% 
\section{研究方法及步驟}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{研究方法及步驟 1/4}
\begin{itemize}
        \item 使用現有設備量測原廠 PS4 搖桿,建立資料庫。
\end{itemize}
\begin{figure}
        \begin{columns}
        \column{0.5\textwidth}
                \includegraphics[width=\textwidth]{agilent.jpg}
                \caption{Agilent 示波器}
        \column{0.5\textwidth}
                \includegraphics[width=\textwidth]{zp.jpg}
                \caption{Zeroplus 邏輯分析儀}
        \end{columns}
\end{figure}
}
%
\frame{ \frametitle{研究方法及步驟 2/4}
\begin{itemize}
        \item 實作的方法:Arduino UNO + MCP2200 \cite{mcp2200}
\end{itemize}
        \begin{figure}
        \centering
        \only<1>{\includegraphics[width=0.6\textwidth]{arch1.jpeg}}\only<2>{\includegraphics[width=0.6\textwidth]{arch2.jpeg}}\only<3>{\includegraphics[width=0.6\textwidth]{arch3.jpeg}}
                \caption{實作方法架構圖}
        \end{figure}
}
%
\frame{ \frametitle{研究方法及步驟 3/4}
\begin{itemize}
        \item 使用 Arduino UNO 開發板 (ClockSpeed 16MHz)。
        \item USB Device (1.5 MBps, Low-speed) 訊號分析不需要高速運算。
        \item 價格低。
\end{itemize}
%figure
\begin{figure}
        \centering
        \includegraphics[width=0.5\textwidth]{uno.png}
        \caption{Arduino UNO 開發板}
\end{figure}

}
%
\frame{ \frametitle{研究方法及步驟 4/4}
\begin{itemize}
        \item 使用晶片:MCP2200 (USB to UART)。
        \item 讓 USB D+/D- 與 Arduino Tx/Rx 能夠互相溝通。
\end{itemize}
%figure
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{mcp2200_arch.jpg}
        \caption{MCP2200 晶片架構}
\end{figure}

}

% 
\section{預期研究成果}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{預期研究成果}
\begin{itemize}
        \item 對多種主機平台(例如:PS3, PS4, XBOX, PC...等),\\
              解析其 USB 週邊裝置之封包訊號。
        \item 不要太多設定,一插即分析並整理好封包資料。
\end{itemize}
%figure
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{analyzer_2.jpeg}
        \caption{多平台分析示意圖}
\end{figure}

}

% 
\section{結論}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{結論}
\begin{itemize}[<+->]
        \item USB 為現在及未來之人機介面的主流趨勢。
        \item 封包解析變得更簡易更省成本。
        \item 仍要依循 USB-IF 制定的規則及標準。
        \item 未來進一步的發展方向為`藍芽裝置'的解析。
\end{itemize}
}

% 
\section{參考文獻}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{參考文獻}
        \tiny{\bibliographystyle{abbrv} }
        \bibliography{\jobname} }
\end{document}

2015年6月12日 星期五

Beamer 範本:每週進度報告

以下為我個人使用的範本:

檢視:mybeamer.pdf
下載:mybeamer.tex

編譯方式 (若有 .bib 檔可能需要先 rm 刪除掉):
xelatex mybeamer
bibtex mybeamer
xelatex mybeamer
xelatex mybeamer

evince mybeamer.pdf



vi mybeamer.tex

% version 2015/06/06
%===============================================================
% LaTeX Beamer environment setting
\documentclass[xetex,mathserif,serif,xcolor=dvipsnames]{beamer}
%\usepackage{fontspec,xunicode,xltxtra} %可自定義 fonts 的套件
%\usepackage[nodayofweek]{datetime}% 設定 \today 套件
\usepackage{listings} %% 程式語言 demo 套件

%自訂一個 \myday 時間格式
%\newdateformat{mydate}{\twodigit{\THEDAY}{ }\shortmonthname[\THEMONTH], \THEYEAR}

%\usepackage{datenumber}%時間計數器
%\usepackage[top=2cm,botton=2cm,left=2cm,right=2cm]{geometry}

% 解決 XeTeX 中文的斷行問題
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
%\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

% WebLink
\usepackage{url, hyperref}

% Table Setting
\usepackage{color, colortbl}
\usepackage{caption}
\captionsetup{skip=0pt,belowskip=0pt}
%===============================================================
%% 字型 Fonts Setting
%% http://hyperrate.com/thread.php?tid=23544

% 預設英文字體
\usepackage{arevmath}
\usepackage[no-math]{fontspec}
\setmainfont[Scale=0.9]{DejaVuSansMono}
%\setmainfont[Mapping=tex-text,LetterSpace=-1.25]{DejaVu Sans}
%\setsansfont[Mapping=tex-text,LetterSpace=-1.25]{DejaVu Sans}
%\setmonofont[Color=00663300]{DejaVu Sans Mono}

% 預設中文字體
\usepackage[CJKchecksingle, normalindentfirst, SlantFont, BoldFont]{xeCJK}
\setCJKmainfont{金梅新中楷國際碼}
%\setCJKmainfont[Scale=1.2,BoldFeatures={FakeBold=1.8}]{金梅新中楷國際碼}
%\setCJKmonofont[Scale=1.2,BoldFeatures={FakeBold=1.8},FakeStretch=1.11686,Color=00663300]{金梅新中楷國際碼}

% 自定義字體切換指令
% 中文
\newfontfamily{\J}{金梅新中楷國際碼}
\newfontfamily{\B}{華康中黑體}

% 英文
\newfontfamily{\D}[Scale=0.9]{DejaVuSansMono}
\newfontfamily{\T}{Times New Roman}
\newfontfamily{\A}{Arial}

% 粗體字 / 斜體字
% \textbf{粗體內容}
% \textit{斜體內容} 
%===============================================================
%% Theme 設定主題樣式
%%底部可以加上標題,要注意的是一定要在選定主題 \usetheme 之前就使用
%\useoutertheme{infolines}

%% 參考樣式 https://www.hartwork.org/beamer-theme-matrix/
%% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme_and_color.html
%% 內設的主題 http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%% AnnArbor, Antibes, Bergen, Berkeley, Berlin,
%% Boadilla, CambridgeUS, Copenhagen, Darmstadt, Dresden, Frank-
%% furt, Goettingen, Hannover, Ilmenau, JuanLesPins, Luebeck,
%% Madrid, Malmoe, Marburg, Montpellier, PaloAlto, Pittsburgh,
%% Rochester, Singapore, Szeged, Warsaw, boxes
% 較 OK 的:
%Rochester, Copenhagen, Frankfurt, Copenhagen, Luebeck, Warsaw, Boadilla
%\usetheme{Madrid}
\usetheme[height=0mm]{Rochester}%這邊設定投影片標題高度,0 是因為下方設定
%\usetheme{Boadilla}
%===============================================================
%% Color Theme設定投影片顏色
% http://en.wikibooks.org/wiki/LaTeX/Presentations
% 內設顏色: red, magenta, green, blue, cyan, yellow, black, darkgray, gray, lightgray, orange, violet, purple, brown, SeaGreen
\usecolortheme[named=SeaGreen]{structure}

% 內設主題顏色:default, albatross, beaver, beetle, crane, dolphin, dove, fly, lily, orchid, rose, seagull, seahorse, whale, wolverine
%\usecolortheme{beaver}

%============================================================
% 設定投影標題樣式
% 感覺不太出來
%\setbeamertemplate{blocks}[rounded][shadow=true]

% 設定列表樣式
% 可以選擇:ball, circle, rectangle, default
\setbeamertemplate{items}[ball]

% 設定圖片標號
\setbeamertemplate{caption}[numbered]
%============================================================
%隱藏 beamer 底部小工具列
\setbeamertemplate{navigation symbols}{}

%============================================================
% 自訂 footline
%\setbeamerfont{footline}{size=\fontsize{9}{11}  \selectfont}
%\setbeamerfont{footline}{size=\fontsize{5}{5} \D \selectfont}

%%% 自訂 Page Number
%\setbeamertemplate{footline}[frame number]

\setbeamercolor{footline_blue}{fg=blue}
\setbeamercolor{footline_black}{fg=black}
\setbeamerfont{footline}{series=\bfseries}
\addtobeamertemplate{navigation symbols}{}{%
        \usebeamerfont{footline}%
%       \usebeamercolor[fg]{footline}%
        \hspace{1em}%
        {
        \usebeamercolor[fg]{footline_blue}\insertframenumber
        \usebeamercolor[fg]{footline_black}/\inserttotalframenumber
        }
}

%======================================================================
%% Reference Table 參考文獻建表 
% https://www.sharelatex.com/learn/Bibliography_management_in_LaTeX#The_bibliography_file
% http://tex.stackexchange.com/questions/3587/how-can-i-use-bibtex-to-cite-a-web-page
% http://tex.stackexchange.com/questions/68080/beamer-bibliography-icon
% https://zh.wikipedia.org/wiki/BibTeX

\begin{filecontents}{\jobname.bib}
@book{b1,
    title={USB 2.0 系統開發實例精解},
    author={廖濟林},
    isbn={9789861990040},
    year={2007},
    publisher={城邦文化事業股份有限公司},
    keywords = {USB}
}
@misc{WinNT,
  title = {{MS Windows NT} Kernel Description},
  howpublished = {\url{http://web.archive.org/web/20080207010024/http://www.808multimedia.com/winnt/kernel.htm}},
  note = {Accessed: 2010-09-30}
}

@misc{mcp2200,
        title={MCP2200},
        howpublished={\url{http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en546923}},
        note={Accessed:2015-06-06}
}

\end{filecontents}
%======================================================================
%% Reference Setting 參考文獻環境設定
%% http://tex.stackexchange.com/questions/147279/references-at-the-end-of-beamer-slides
%% https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM
%% http://tex.stackexchange.com/questions/147279/references-at-the-end-of-beamer-slides

\usepackage{cite}
\usepackage{natbib}

%\usepackage{natbib}
%\usepackage{bibentry}
%\usepackage{chngcntr}
%\bibliographystyle{apalike}
%
%\setbeamercolor*{bibliography entry title}{fg=black}
%\setbeamercolor*{bibliography entry author}{fg=black}
%\setbeamercolor*{bibliography entry location}{fg=black}
%\setbeamercolor*{bibliography entry note}{fg=black}
%\setbeamertemplate{bibliography item}{}
%%\setbeamertemplate{bibliography item}{\insertbiblabel}
%\setbeamertemplate{frametitle continuation}[from second]
%
%\counterwithin*{footnote}{page}
%\newcommand\fcite[1]{\footnote{\tiny \bibentry{#1}}\label{\thepage:#1}}
%\newcommand\scite[1]{\textsuperscript{\ref{\thepage:#1}}}
%
%\nobibliography{\jobname}
%=======================================================================
\begin{document}
%======================================================================%% 標題設定 Title Setting
% 重設 frametitle 的預設為置中,上方的 usetheme 要改為 [height=0]
\setbeamertemplate{frametitle}[default][center]

% 自定義 title 格式
%\usepackage{titlesec}
%\titleformat{\section}{\Large\xbsong}{\thesection}{1em}{}

%%% Title Setting 1 自訂亂設法
% 指令 \datedate 可以設定為 \date 加減幾天
%\setdatetoday
%\addtocounter{datenumber}{-7}
%\setdatebynumber{\thedatenumber}
%\date{\large 2015/03/26}

%\begin{frame}
%       \begin{titlepage}
%               \begin{center}
%               {\Huge 每週進度報告}\\% 標題內容
%               \vspace{.5cm}% 空 0.5cm 垂直空間
%               \rule{\textwidth}{3pt}\\% 粗分隔線
%               \vspace{.5cm}% 空 0.5cm 垂直空間
%               {\LARGE 指導教授:李博明\\
%               MA330101 廖凱霖}
%               \end{center}
%       \end{titlepage}
%\end{frame}
%----------------------------------------------------------------------------
%%% Title Setting 2 正規設法
%% http://tex.stackexchange.com/questions/26848/beamer-font-size-for-footer

%\title[footline title]{\Huge Real Title}
\title[每週進度報告]{\huge 每週進度報告}
%\title[每週進度報告]{\fontsize{20}{25} \selectfont 每週進度報告}

\author{MA330101 廖凱霖}
%\author{ MA330101 廖凱霖}
%\author{{\large 指導教授:李博明\\
%        {\D MA330101} 廖凱霖}}

%\institute{機構}

%\date{\D \number\year/\number\month/\number\day}% 自排格式
\date{2015/06/11}
%======================================================================
%% 投影片開始 Frame Start
% 印出標題
\begin{frame}[fragile]
        \titlepage
\end{frame}

% Outline
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents        % 插入目錄
\end{frame}

% TEST Test test page
\section{Test Page}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}
        \frametitle{Test Page}
        \begin{itemize}[<+->]
                \item \textbf{正規粗體法 English 0oO}
                \item \textit{測試斜體字 the word 0Oo}
                \item Is it socially\nocite{WinNT} stratified?\cite{b1}
                \item Sauss\cite{mcp2200} said some stuff
        \end{itemize}
\end{frame}

% Road map
\section{Road map}
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents[currentsection]        %% 插入所在目錄
\end{frame}
\begin{frame}[fragile]
        \frametitle{行程規劃 (Road Map)}
        \begin{itemize}
                \item date word
        \end{itemize}
\end{frame}

% Last Week Issue
\section{Last Week Issue}
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents[currentsection]        %% 插入所在目錄
\end{frame}
\begin{frame}[fragile]
        \frametitle{上週 lastweek 遭遇問題及後續}
\end{frame}
% This week progress rate
\section{Progress Rate}
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents[currentsection]        %% 插入所在目錄
\end{frame}
\begin{frame}[fragile]
        \frametitle{本週 thisweek 進度}
        \begin{itemize}
                \item first
                \item second
                \item three
        \end{itemize}
\end{frame}

% This week issue
\section{This Week Issue}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}[fragile]
        \frametitle{本週所遭遇問題及可能解法}
        \begin{block}{問題:這邊輸入問題}
                可能的解法:這邊輸入可能的解法...
        \end{block}
\end{frame}

% Next week progress plan
\section{Next Week Plane}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}[fragile]
        \frametitle{下週 {Nextweek} 預計進度}
\end{frame}

%% 範例10: 參考文獻
\section{Reference}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{Reference}
        \tiny{\bibliographystyle{abbrv} }       % 文獻標號
        \bibliography{\jobname} }               % 文獻來源
%======================================================================
%% 範本 1
%\begin{frame}
%       \frametitle{投影片標題}
%       \begin{block}{小重點}
%               試試 block 的使用方式
%       \end{block}
%       \begin{alertblock}{大重點}
%       特別重要的東西
%       \end{alertblock}
%       \alert{這一點重要}\\
%       \alert<2>{第二張才重要}\\
%       \color<4>{green}{第四張時是綠色}\\
%       \color<6>{brown}{第四張時是棕色}\\
%\end{frame}

%% 範本2: 插入圖片,pdf, .png, 或 .jpg
%\begin{frame}
%       \begin{figure}
%       \centering
%       \includegraphics[scale=.5]{foo.png}
%       %\includegraphics[width=0.5\textwidth]{foo.png}
%       \end{figure}
%\end{frame}

%% 範本3: 條列式
%\begin{frame}
%       我們先說明...
%%% itemize, enumerate, description
%       \begin{itemize}% 指定頁顯示
%               \item<1-> 第一項
%               \item<2-> 第二項
%               \item<6-> 第三項
%       \end{itemize}
%       \begin{itemize}[<+->]% 逐頁顯示
%               \item 第一項
%               \item 第二項
%               \item 第三項
%       \end{itemize}
%       % 暫時跳脫去下面說明
%       \pause
%       然後可以發現...
%       \pause
%       % 指定該 frame 後第幾個投影片出現
%       我們知道「\only<6->{第二張以後才會出現}」°\\
%       我們知道「\uncover<6->{第二張以後才會出現}」°
%       % 直接跳到投影片 here label 位置
%       \hyperlink{here}{\beamerbutton{去這篇投影片}}
%\end{frame}
%
%% 範本4: 投影片標籤 here
%\begin{frame}[label=here]
%       過來這裡
%\end{frame}

%% 範本5: 原文照例 \verb 用法
%\begin{frame}
%\begin{frame}[fragile]% 重點要記得加入 fragile
%\begin{verbatim}
%       輸入原文
%\end{verbatim}
%\end{frame}

%% 範本6: Web Link
%\href{http://tex.stackexchange.com/q/20800/5701}{\beamergotobutton{Link}}

%% 範本7: Table
% http://www.tablesgenerator.com/
% https://www.sharelatex.com/learn/Tables

%% 範例8: outline, current section
%\section{第一點}
%\frame{\frametitle{Outline}\tableofcontents[currentsection]}

%% 範例9: Coding
%% https://www.sharelatex.com/learn/Code_listing#Supported_languages
%% language support: bash, Java, C++, PHP, Python, Latex, HTML... 
%\begin{frame}[fragile]
%       \lstset{language=C++, keywordstyle=\color{blue}, stringstyle=\color{red}, commentstyle=\color{green}, morecomment=[l][\color{magenta}]{\#}}
%       \begin{lstlisting}
%       void make_set(int X) {
%               parent[X] = X;
%       }
%       \end{lstlisting}
%\end{frame}

%%% 範例10: 參考文獻
%\section{Reference}
%\frame{\frametitle{Outline}\tableofcontents[currentsection]}
%\frame{ \frametitle{Reference}
%        \tiny{\bibliographystyle{abbrv} }       % 文獻標號
%        \bibliography{\jobname} }               % 文獻來源

%%% 範例11: 表格 Table
% http://www.tablesgenerator.com/latex_tables#
% \captionof{table}{USB 分析儀市場調查表}
% \begin{table}[h]
% \begin{tabular}{|l|r|}
% ...
% \end{tabular}
% \end{table}

\end{document}

LaTeX 環境建置



一、安裝
sudo apt-get install texlive-full latex-cjk-all

二、設定字型

1. 查看目前系統字型支援
fc-list

2. 字型檔路徑
/home/$USER/.fonts

我的字型檔(不要公開):https://drive.google.com/file/d/0BxEiZ5gd9umbeDgwWWJydk9pWE0/view?usp=sharing

3. 其他免費字體:
sudo apt-get install xfonts-wqy ttf-wqy-microhei ttf-wqy-zenhei