開始之前
你看過「從零開始的 LaTeX 急速入門」嗎?
沒有?
那你知道如何編譯一個LaTeX檔案嗎?
知道。
OK , 本文將提及關於如何使用LaTeX編輯出一篇簡單的文章,不涉及複雜的排版,以及LaTeX基本使用方法。
讓我開始吧~~
編輯文章
一般來說,你應該在寫「結構性文章」時才使用LaTeX。LaTeX不適合用來編寫非常靈活的雜誌、新聞類文章。
段落與空行
LaTeX有一個很大特性就是會無視空白。會是多個空白為一個。舉例來說:
This is a book.
This is a book.
是完全相同的,他們會輸出一模一樣的 "This is a book." 如下圖:
沒有錯,他還會無視換行。
這讓編輯文章,變得比較輕鬆,因為你可以比較靈活的在筆記本軟體當中編輯文章。
舉例來說:
超級長句子:
A wiki (Listeni/ˈwɪki/ wik-ee) is a website that provides collaborative modification of its content and structure directly from the web browser. In a typical wiki, a text is written using a simplified markup language (known as "wiki markup") and often edited with the help of a rich-text editor.
排版的容易閱讀
A wiki (Listeni/ˈwɪki/ wik-ee) is a website that provides collaborative modification of its content and structure directly from the web browser.
In a typical wiki, text is written using a simplified markup language (known as "wiki markup")
and often edited with the help of a rich-text editor.
我們將這樣連續的區塊稱為「段落」
而我們用一行的「空行」表示段落與段落的區隔,參考這段代碼:
Hello, this is an article about \LaTeX.
It will help you to make a high-quality printable document.
When writing, you use plain text as opposed to formatted text, like Word.
\LaTeX is a programming language, too.
so you can writ a program in \LaTeX
一般來說$\LaTeX$會有預設的段落縮排。所以上面這段代碼就可以獲得以下的成果。
那麼,如果說要在特定的位置換行,而且不縮排呢?一般來說,使用的是強迫換行\\
如果不希望有首行縮進則可以用\noindent
或是設定縮進為0\setlength{\parindent}{0pt}
看一下一個複雜的段落控制:
指令 | 功能 |
---|---|
\\ |
強迫換行 |
\\[5pt] |
強迫換行與下一行相距5pt |
\noindent |
不要縮進 |
\setlength{\parindent}{2em} |
設置段落縮進長度 |
文章結構
在討論文章結構之前,我必須解釋$\LaTeX$的基本結構。也就是:
\documentclass[12pt,a4papaer]{article}
%set format of document
\begin{document}
%write something
\end{document}
一般來說:學習電腦程式軟體,這些基本結構都不是非常重要,也不太需要特別去改變。所以,重點請參看下表:
功能 | 解釋 | |
---|---|---|
\documentclass | 樣式設定指令 | 永遠都在第一行 |
[12pt, | 設定本文字級 | 預設11pt or 12pt不會錯 |
,a4paper] | 設定本文尺寸 | BJ4 還有 b5paper可以選 |
{article} | 設定本文樣式 | 套用現成範本的概念 |
\begin{document} | 本文開始 | 從這裡開始的內容才會顯示 |
\end{document} | 文章結束 | 後面不能有任何文字 |
樣式設定的部分預設可以選的有以下幾種:
樣式 | 說明 |
---|---|
article | 一般文章,分小節(section)與子小節(subsection) |
IEEEtran | IEEE用的可以裝一下逼 |
report | 跟article類似,但是可以有章節(Chapter) |
book | 寫書的範本 |
beamer | 用LaTeX做簡報的範本 |
接下來,就是「章節指令」。將文章邏輯性的分割對於科學文章頗為重要。
因此,章節的稱為為$\LaTeX$最核心的指令也不為過。原則上,就是\section
\subsection
\subsubsection
這些章節指令,會將文章的斷若切割,然而實際上,這些指令都只是生成一個適當樣式的標題而已歐,所以適當的縮進,可以讓你看得更清楚。
\documentclass[12pt,a4paper][article]
\begin{document}
\section{title 1}
Hello this is a book.
\subsection{subtitle 1}
Hello, here is a subsection.
\subsection{subtitle 2}
Hello, here is a subsection 2.
\end{document}