latex學習筆記

latex學習筆記

一.操做LaTeX

1.1軟件的安裝

軟件:texstudioide

1.2cmd實現對LateX文檔的編寫

  1. 新建一個tex文檔
notepad test.tex
  1. 使用notepad編寫

由於有自動補全功能比記事本好不少函數

\documentclass{article}

\begin{document}
Hello \LaTeX

\end{document}
  1. cmd編譯tex

1.2.1使用latex

latex test.tex

  1. 操做.dvi文件,轉換爲pdf文件
dvipdfmx test.dvi
  1. 生成了pdf文件

1.2.2使用xelatex

xelatex test.tex

1.2.3打包命令爲bat文件?

  1. 新建一個bat文件
cd.>build_pdf.bat
  1. 編寫dat

del是刪除學習

2.3.1latex

cd F
cd F:\file\latex_file\ex\Latex_learn_cmd
latex test.tex
dvipdfmx test.dvi
del *.aux *.dvi *.log

2.3.2xelatex

F:\file\latex_file\ex\Latex_learn_cmd
cd F
cd F:\file\latex_file\ex\Latex_learn_cmd
xelatex test.tex
del *.aux *.dvi *.log

1.2.4使用不了中文?

  1. 使用utf-8編碼

(1) 使用記事本的另存爲改變爲uft-8編碼字體

(2)在tex裏面設置ui

\documentclass[11pt,UTF8,twoside,a4paper]{article}
  1. 引入宏包與文件類型
\documentclass[11pt,UTF8,twoside,a4paper]{article}
\usepackage{ctex}   %中文

1.3texstudio

1.3.1快捷鍵

F5到F9編碼

二.LaTeX基礎

2.1源文件的基本結構

%註釋的內容
%導言區
\documentclass[11pt,UTF8,a4paper]{article}
%book,report,letter


\usepackage{ctex}%中文包

%標題頁
\title{My First Document}%標題
\author{lim}%做者
\date{\today}%日期


%正文區
\begin{document}
	\maketitle 	%輸出標題  
	
	你好,\LaTeX
	
	Let $f(x)$ be defined by the formula $f(x)=3x^2+2x-1$
	
	$$y=1$$
\end{document}

2.2中文和數學公式

2.2.1設置中文

  1. 設置默認編譯器
    spa

  2. 設置utf-8模式code

  1. texstudio設置utf-8

這個是源文件的格式orm

  1. 引入宏包
\usepackage{ctex}%中文包

2.2.2打開Ctex宏包手冊

2.2.3設置文檔類宏包

%使用文檔類宏包
\documentclass[11pt,UTF8,a4paper]{ctexart}
%ctexart,ctexrep,ctexbook
%就不用如下
%\usepackage{ctex}%中文包
%\documentclass[11pt,UTF8,a4paper]{article}

2.3字體和字號設置

2.3.1字體屬性

2.3.2字體族

%字體族的設置
%羅馬數字,無襯線字體,打印機字體
%兩種格式
%\textrm{文字}
%\rmfamily   後面的文字都是這個字體
%羅馬字體
	 \textrm{Roman Family}
	 
	 \rmfamily Roman Family
%無襯線字體

	 \textsf{Sans Serif Family}
	 
	 \sffamily Sans Serif Family
%打印機字體

	 \texttt{Typewriter Family}
	 
	\ttfamily Typewriter Family

2.3.3粗細寬度

%字體系列設置
%粗細,寬度

\textmd{Medium Series}
{\mdseries Medium Series}

\textbf{Boldface Series}
{\bfseries Boldface Series}

2.3.4字體形狀

%字體形狀設置
%直立,斜體,僞斜體,小型大寫
%直立

\textup{Upright Shape}
{\upshape Upright Shape}

%斜體
\textit{Italic Shape}
{\itshape Italic Shape}

%僞斜體
\textsl{Slanted Shape}
{\slshape Slanted Shape}

%小型大寫
\textsc{Small Caps Shape}
{\scshape Small Caps Shape}

2.3.5中文字體

%中文字體設置
%宋體
{\songti 宋體}

%黑體
{\heiti 黑體}

%仿宋體
{\fangsong 仿宋}

%楷書
{\kaishu 楷書}

2.3.6中文的粗體斜體

%中文的粗體和斜體
%粗體
\textbf{粗體}

%斜體
\textit{斜體}

2.3.7字體大小

%字體大小設置
%這是相對的大小
%在文檔的導言區設置字體大小,10磅
%只有10,11,12磅
%\documentclass[10pt]{article}

{\tiny Hello}\\
{\scriptsize Hello}\\
{\footnotesize Hello}\\
{\small Hello}\\
{\normalsize Hello}\\
{\large Hello}\\
{\Large Hello}\\
{\LARGE Hello}\\
{\huge Hello}\\
{\Huge Hello}\\

2.3.8中文字號

%中文字號
%-表示是小
%-4表示小四號
%能夠定義一個命令
%\newcommand{\myfont}{\textif{\textbf{\textsf{Fancy Text}}}}
\zihao{-0} 你好!

\zihao{-4} 你好!

\myfont

三.文章結構

3.1基礎文檔結構

%文章的基本結構
%帶章節的大綱
%\chapter{緒論}
\section{引言}
\subsection{子小節}
\subsubsection{下下小節}
\subsection{子小節}
%\chapter{結果}
\section{方法}
\subsection{子小節}
\subsubsection{下下小節}

%進行換行
%\\
%\par
%空行

3.2設置目錄與標題

%輸出標題	
	\maketitle 
%輸出目錄
\tableofcontents

3.3設置標題的格式

%設置標題的格式
\CTEXsetup[
format+={\zihao{1}\heiti      \raggedbottom},
name = {,、},
number = \chinese{section},
beforeskip = 1.0ex plus 
	0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = \hspace{0pt}	
]{section}


\CTEXsetup[
format+={\zihao{5}         \heiti      \raggedbottom},
name = {,.},
number = \arabic{section} 
\arabic  {subsection},
beforeskip = 1.0ex plus 
0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = \hspace{0pt}	
]{subsection}

四.特殊字符

4.1空格

  1. 空行分段,多個空行就是1個
  2. 自動縮進,不能使用空格代替
  3. 英文中多個空格處理爲1個空格,中文中的空格將被忽略
  4. 漢字與其餘字符的間距會自動由Xelatex處理
  5. 禁止使用中文的全角空格
% 1.空格

% 1em,當前字體M的寬度
a\quad b

% 2em
a\qquad b

% 約1/6各em
a\,b    a\thinspace b

%0.5個em
a\enspace b

%空格
a\ b

%硬空格
a~b

% 1pc=12pt=4.218mm
a\kern 1pc b

a\kern -1em b

a\hskip 1em b

%佔位寬度
a\hphantom{xyz}b

% 彈性寬度
a\hfill b

4.2控制符

%2. 控制符
\# \$  \% \{   \}   

\~{} \_{}  \^{} \&

%這是反斜槓/
\textbackslash

4.3標誌和特殊符號

%3. \Tex 標誌符號
\TeX{}   \LaTeX{}    \LaTeXe{}

%4.排版特殊符號?
\S \P  \dag \ddag  \copyright \pounds

4.4引號

% 5.引號
` ' `` '' ``你好''
    ``雙引號''
`單引號'

五.圖片

5.1插入宏包

%語法
%\includegraphics[<選項>]{<文件名>}
%格式
%EPS,PDF,PNG,JPEG,BMP
%插入圖片的宏包
\usepackage{graphicx}
%圖片在當前目錄下的figures文件夾
\graphicspath{{figures/}}

5.2代碼實現

%使用圖片
%指定縮放因子
\includegraphics[scale=0.3]{Screenshot1}

%指定高度
\includegraphics[height=10cm]{Screenshot1}

\includegraphics[height=0.1\textheight]{Screenshot1}


%指定寬度
\includegraphics[width=10cm]{Screenshot1}

\includegraphics[width=0.1\textwidth]{Screenshot1}


%指定旋轉角度
\includegraphics[
angle=-45,
width=0.1\textwidth
]{Screenshot1}

\includegraphics[
angle=85,
width=0.1\textwidth
]{Screenshot1}

六.表格

6.1基礎表格

%表格
%對齊方式   
%l 左對齊   
%c 居中對齊
%r 右對齊
%p{1.5cm}  指定寬度的格子
% |是表格的豎線
% \hline 是表格的橫線
% \hline \hline 是雙橫線
% || 是雙豎線
\begin{tabular}{|l|| c |c| c| p{1.5cm}|}
	\hline
	姓名&語文&數學&外語&備註\\
	\hline  \hline
	劉津志&105&150&135&666\\
	\hline
\end{tabular}

七.浮動體

7.1導入包

%浮動體禁止浮動
%避免浮動體跨過 \section
\usepackage[section]{placeins}
%禁止浮動
\usepackage{float}

7.2代碼分析

%浮動體

%設置相對引用,跳到這個圖
見圖\ref{fig-圖1}
\begin{figure}[htbp]%浮動體的排版對值
	\centering %居中
	\includegraphics[scale=0.3]{Screenshot1}
	\caption{圖1}%標題
	\label{fig-圖1}%設置標籤
\end{figure}

見表\ref{tab-表1}
\begin{table}[H]
	\centering %居中
	\caption{表1}%標題
	\label{tab-表1}
	\begin{tabular}{|l|| c |c| c| p{1.5cm}|}
		\hline
		姓名&語文&數學&外語&備註\\
		\hline  \hline
		劉津志&105&150&135&666\\
		\hline
	\end{tabular}
\end{table}

八.數學公式

8.1基本

%數學公式
%格式1
$a+b=b+a$

%格式2,行內公式
\(a+b=b+a\)

%格式3
\begin{math}
	a+b=b+a
\end{math}

%格式4和上下標
$$3x^{20}_{11}-x_{11}+2=0$$


%格式5,行間公式
\[x+1=2\]

%格式6 ,行間公式

\begin{displaymath}
	x+1=2 \label{eq:eq1}
\end{displaymath}


% 這兩個是爲了按章節編號
\usepackage{amsmath}
\numberwithin{equation}{section}


% 格式7	帶編號的數學環境,行間公式
見公式\ref{eq:eq1}
\begin{equation}
x+1=2 \label{eq:eq1}
\end{equation}

%格式8,不帶編號

見公式\ref{eq:eq2}
\begin{equation*}
x+1=2 \label{eq:eq2}
\end{equation*}

%希臘字母
$\alpha$
$\beta$
$\gamma$
$\epsilon$
$\pi$
$\omega$
$\Gamma$
$\Delta$
$\Theta$
$\Pi$
$\Omega$

%數學函數
$\log$
$\sin$
$\cos x$
$\arcsin$
$\arccos$
$\ln x$
$\log_2 x$
$\sqrt{2}$
$\sqrt[4]{x}$%指定開方的次數
$\frac{2}{x}$

8.2矩陣

%矩陣

%無括號
\[
	\begin{matrix}
	0 & 1\\
	1& 0 
	\end{matrix}\qquad
%小括號
\begin{pmatrix}
0 & 1\\
1& 0 
\end{pmatrix}	\qquad
%中括號
\begin{bmatrix}
0 & 1\\
1& 0 
\end{bmatrix}\qquad
%大括號
\begin{Bmatrix}
0 & 1\\
1& 0 
\end{Bmatrix}\qquad
%單豎線
\begin{vmatrix}
0 & 1\\
1& 0 
\end{vmatrix}\qquad
%雙豎線
\begin{Vmatrix}
0 & 1\\
1& 0 
\end{Vmatrix}
\]

%經常使用的省略號
%\dots \vdots \ddots
%矩陣的下標
%_{n \times n}
\[
	A = \begin{bmatrix}
	a_{11}&\dots &a_{1n}\\
	\vdots&\ddots &\vdots \\
	0  & \dots &a_{nn} 
	\end{bmatrix}_{n \times n}
\]
相關文章
相關標籤/搜索