2014年8月28日 星期四

Latex重點筆記

新手安裝Latex編輯器請參照此文章
http://leavedcorn.pixnet.net/blog/post/24773932


Latex的指令大小寫有別,' \ ' 開頭到第一個非字母符號(包括數字)為止,{}括住不可省略之參數,[]括住選擇性參數

Environment

起於\begin{環境名稱} 止於\end{環境名稱}
ex. abstract(序言)文字會左右縮排,行距較開

格式

\documentclass{article} 告訴Latex使用哪一種格式
這裡放preamble

\title{my first work of Latex}
\author{Andy Tsai\footnote{you can add some footnote}}
\date{\today}

\begin{document}
\maketitle
這裡才是本文區


\end{document}

標準格式有article, report, book, slides, letter等

document class parameter: 10pt, 11pt, 12pt, letterpaper(標準信紙隔式), a4paper, twocolumn(將本文分為兩欄表示)


換行

" // "可以換行,後面可加上參數控制換行間隔(ex. \\[1cm])

字型

\it for italic(斜花體)
\sl for slant(斜體)
\bf for boldface

若你只希望其中幾個字變換字體(default Roman)請用\textit{context} \textsl{context} \textbf{context}


在book的documentclass裡有chapter和section的子environment,但以我們學生寫報告而言較少使用,故忽略

條列

條列時可以切換到別種environment

itemize
\begin{itemize}
\item 第一大項,這裡是第一大項。
\item 第二大項,這裡是第二大項。
\begin{itemize} 
\item 第一小項,這裡是第一小項。
\item 第二小項,這裡是第二小項。
\end{itemize} 
\item 第三大項,這裡是第三大項。
\end{itemize} 

enumerate(枚舉)
\begin{enumerate}
\item 第一大項,這裡是第一大項。
\item 第二大項,這裡是第二大項。
\begin{enumerate} 
\item 第一小項,這裡是第一小項。
\item 第二小項,這裡是第二小項。
\end{enumerate} 
\item 第三大項,這裡是第三大項。
\end{enumerate} 

description(以名稱做為項目item)
\begin{description}
\item[第一大項]這裡是第一大項。
\item[第二大項]這裡是第二大項。
\begin{description} 
\item[第一小項]這裡是第一小項。
\item[第二小項]這裡是第二小項。
\end{description} 
\item[第三大項]這裡是第三大項。
\end{description}

MATH



  • math inline mode 數學試的頭尾用一對$夾住,若試子很長還是想要隨文式(不換行)可用begin{math}, end{math}
  • math display mode \[ math sentence \] 或 \begin{equation} \end{equation}
  • _表示下標 ^表式上標
  • math display mode(aligned) => \begin{aligned} \end{aligned} =>幫忙把行間的數學式子排整齊

  • \sinsine function
    \coscosine funciton
    \sumsummation(sigma)
    \intintegration
    \fracfraction
    \limlimit
    \pipi
    \alphaalpha
    \sqrtsquare root

  • array的表示: 以&代表空格,\\ 換行
\[ % begin math mode
    A = 
    \left(
    \begin{array}{clr} 
        t_{11} & t_{12} & t_{13} \\
        t_{21} & t_{22} & t_{23} \\
        t_{31} & t_{32} & t_{33} 
    \end{array}
    \right) 
\] % end math mode

%clr表示center left right, 因為現在有3個column所以第一個column置中對齊,第二欄靠左第三欄靠右,若有似個column則參數可能為{lccr}之類的

要表達array也可以用套件幫忙(amsmath)較簡單
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
\[
    \begin{pmatrix}
        7 & -2 & 1 & 2 \\
        2 & 8 & 3 & 1 \\
        -1 & 0 & 5 & 2 \\
        0 & 2 & -1 & 4
    \end{pmatrix}
    \begin{pmatrix}
        x_1 \\
        x_2 \\
        x_3 \\
        x_4
    \end{pmatrix}
    = 
    \begin{pmatrix}
        3 \\
       -2 \\
        5 \\
        4
    \end{pmatrix}
\]
\end{document}

Table


table是寫論文非常常出現的格式,老實說google blog的table功能做的蠻差的,我記得google site有table的功能,還可以用CSS讓它變漂亮,可是google blog完全沒有建構table的GUI,只好硬著頭皮用HTML慢慢code(上面那張表就是用HTML直接code出來的,已經沒心情改CSS了XD)

\begin{tabular}[t]{lll}
\hline
column1 & column2 & column3 \\
\hline
item1 & item2 & item3 \\
itemA & itemB & itemC \\
\hline
\end{tabular}

其中的[t]代表表格"頂部"和前後文字對齊,也可以填[b]or[c]來用表格"底部"或"中間"來和前後文排版(latex把表格視為一個可以和文字一起排版的物件)
\hline是畫一條水平線
{lll}(英文字母l)是三個column都靠左對齊,可以在{}內加上|(符號,shift+\)來加上縱線






to see more: 參考網址http://www.cs.nthu.edu.tw/~cherung/teaching/2009cs5321/link/latex.pdf

沒有留言:

張貼留言