效果展示
下載和安裝
總結:
1. 選擇 TeX 發行版(windows下有MiKTeX or proTeXt or TeX Live等選擇)
2. 選擇LaTeX 編輯器(有Texpad、TexStudio、ShareLatex、WinEdit等)
√ Getting MiKTeX
√ TeXstudio
Getting LaTeX
Install MiKTeX on Windows
Manage your TeX installation with MiKTeX Console
快速入門
LaTeX introduction / Quick-start guide
在線LaTex范例對照
Sandbox
一個最簡單的例子
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc} % Unicode support (Umlauts etc.)
\begin{document}
\title{Example}
\author{HJ}
\date{\today{}}
\maketitle
\section{title}
content...
\end{document}
解讀:
documentclass 有article,report,letter,book,slides,proc,exam,leaflet等等類型
What are the available “documentclass” types and their uses?
usepackage 有amsmath,inputenc,hyperref,graphicx,listings等等選擇
WikiBooks: LaTeX/Package Reference
preamble A document in LaTeX consists of two parts, the preamble and the main document.\begin{document}
marks the end of the preamble and the beginning of the actual document. 簡言之,preamble就是設置documentclass的類型和packages的部分。\begin{document}
是main document和preamble的分界線。
LaTeX Wiki:LaTeX preamble
Best practice on organising your preamble
command command可以有arguments,放在curly braces或者square brackets中
\command[optional argument]{argument}
Arguments in curly braces are mandatory, while in square brackets are optional.
LaTeX environment An environment begins with the begin command, and ends with the end command.
LaTex Wiki: LaTeX environment
ShareLaTex:Environments
LaTex Wiki: List of LaTeX environments
Latex Standard Environments
LaTex中environments舉例
復雜一點的例子
\documentclass[a4paper,11pt]{article}
\usepackage{amsmath} % align環境需要導入該包
\usepackage{listings} % Source code formatting and highlighting
\usepackage{xeCJK} % 用來顯示中文的package,在TexStudio中要把build模式改成XeLaTex方式,否則會報錯
\begin{document}
\title{LaTex學習記錄:基礎入門}
\author{離枝}
\date{\today{}}
\maketitle
\tableofcontents
\section{Section1}
\subsection{Subsection1}
content... \LaTeX
It contains two paragraphs.% Here's a comment.
\begin{align}
f(x) &= x^2\\
f'(x) &= 2x\\
F(x) &= \int f(x)dx\\
F(x) &= \frac{1}{3}x^3
\end{align}
\section{Section2}
\subsection{Subsection2}
\begin{lstlisting}[language={java},caption=,breaklines=true,frame=single]
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello,World");
}
}
\end{lstlisting}
\end{document}
此例中比第一個例子增加以下內容
- 中文顯示
\usepackage{xeCJK}
- 目錄顯示
\tableofcontents
- 數學公式顯示及對齊
\usepackage{amsmath}
\begin{align}
f(x) &= x^2\\
f'(x) &= 2x\\
F(x) &= \int f(x)dx\\
F(x) &= \frac{1}{3}x^3
\end{align}
- 代碼顯示
\usepackage{listings}
\begin{lstlisting}[language={java},caption=,breaklines=true,frame=single]
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello,World");
}
}
\end{lstlisting}
其中目錄顯示是通過\tableofcontents
command自動生成的。數學公式的對齊,以及
編號是通過導入amsmath
package并且使用align
environment生成的。代碼塊的生成是通過導入listing
package并且使用 lstlisting
生成的。如果需要生成高亮的代碼塊,則可以使用minted來實現。需要注意的是,在TexStudio中,如果導入xeCJK
package,應當設置build環境為XeLaTex,否則會報錯(默認為PdfLaTex)。
教程
知乎:手把手教你在Mac/Windows下搭建實用的LaTex編譯環境以及其使用初步
從零開始 LaTeX 快速入門
學術寫作利器——LaTeX入門筆記整理(不定期更新,附加使用心得)
A simple guide to LaTeX - Step by Step
一份其實很短的 LaTeX 入門文檔
資源
清華大學開源軟件鏡像站
清華大學 LaTeX 模板
知乎:有哪些美觀實用的或者有創意的 LaTeX 模板?
latextemplates
overleaf: templates
The Listings Package Manual
相關疑問及比較
知乎:有哪些好的 LaTeX 編輯器?
stackexchange:What are the advantages of TeX Live over MiKTeX?
TeX on Windows: TeX Live versus MiKTeX revisited
stackexchange:LaTeX Editors/IDEs
知乎:如何配置 Sublime Text 的 LaTeXTools?
stackoverflow:LaTeX package to do syntax highlighting of code in various languages
簡書:Latex插入代碼塊
知乎:如何在texstudio中保留原格式粘貼?
PDF:在LaTex中輸入中文
LaTex Sheet
如何在Latex中輸入中文