首先感謝我的師兄 HJ衍菱,我的所有資源赶么,學(xué)習(xí)方式以及薅 Google/Github的羊毛都是在師兄的指導(dǎo)下完成的。
同時為了幫助師弟脊串,師妹辫呻,我的同學(xué)們快速的使用 latex 寫作,決定寫下這個基礎(chǔ)教程琼锋,也把從師兄那里學(xué)來的東西分享給大家放闺。
我使用過 latex線上編譯 overleaf 以及 本地編譯 TexStudio,希望我的經(jīng)驗(yàn)?zāi)軌驅(qū)Υ蠹矣兴鶐椭?/p>
overleaf
overleaf 的方便在于能夠顯示編譯缕坎,只有有網(wǎng)就行怖侦,但是網(wǎng)速限制了它的使用(特別是在寢室的渣渣網(wǎng)速下)
overleaf 的打開方式:https://www.overleaf.com/
界面如下:
然后注冊即可,建議是在機(jī)房的電腦上注冊(能夠使用IPV6)谜叹,寢室的網(wǎng)可能進(jìn)不去這個界面匾寝,我使用的是163郵箱注冊。
進(jìn)入后的界面如下:
寫文章的時候可以使用 overleaf 里面給的模板荷腊,也可以自己上傳模板艳悔。
使用 overleaf 里的模板
點(diǎn)擊 New Project ,選擇你想使用的模板類型
如 Academic Joural:
我基本看的是 IEEE 的文章女仰, 我就在 Related Tags 里面找 IEEE的猜年,點(diǎn)擊即可。
點(diǎn)擊之后的界面如下:
這里我們選擇第一個點(diǎn)開疾忍,
接著點(diǎn)擊 Open as Template 就創(chuàng)建成功了乔外。
TexStudio
首先下載 TexStudio 和 Texlive。
TexStudio 下載地址:https://www.texstudio.org/
點(diǎn)擊 Download now 即可一罩。
TexLive 建議用清華鏡像下載:https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/
TexLive 的安裝教程如下:https://blog.csdn.net/aiwei169/article/details/81431363
懶得自己寫了杨幼。
準(zhǔn)備工作完成,接下來寫 Latex 的寫法聂渊。
overleaf 和 TexStudio 的里面的寫法是一樣的推汽。
Latex 符號大全
諸如:這些特殊字符,請參考:https://wenku.baidu.com/view/b1ad1658bb68a98271fefaa1.html?re=view
Latex 插入公式
只要使用了正確的公式編寫方式歧沪,公式會自動編號為(1)歹撒,(2),.... 诊胞,(n) 的暖夭,所以不需要擔(dān)心公式編號問題锹杈。
基本寫法框架如下:
\begin{equation}\label{eq.1}
\end{equation}
這里 \label{eq.1} 是為了方便在文章引入該公式。
舉個例子:
上述的計(jì)算公式如 Eq. \ref{eq.1}所示迈着。
這里的 \ref{eq.1} 就是為了引用改公式竭望, 當(dāng)然你給 label 取名為 lalala 也許,只要你引用的時候在 \ref{} 里面的和你取名是對應(yīng)的就 ok裕菠。
普通函數(shù)公式
\begin{equation}\label{equ:7}
\begin{split}
C_{i} &= {1\over S-1}\sum_{s=1}^{S} (x_{s}-\mu _{i})(x_{s}-\mu _{i})^{T}\\
\mu _i &= {1\over S}\sum_{s=1}^{s} x_{s}
\end{split}
\end{equation}
這里的 split 是對齊的意思咬清, 讓兩行公式在 & 的地方對齊,并且 \\ 是換行的意思奴潘。
分段函數(shù)公式
要完成上述公式的 Latex 代碼如下:
\begin{equation}\label{equ:4}
w_{ij} =
\begin{cases}
exp(-||x_{i} - x_{j}||^{2} / t) & \text{$x_{j}\in O(K, x_{i})$}
\\
&\text{or $x_{i}\in O(K, x_{j})$}
\\
&\text{and $y_{i} = y_{j}$};
\\
0 &\text{otherwise}
\end{cases}
\end{equation}
優(yōu)化函數(shù)公式
\begin{equation}\label{equ:13}
\begin{split}
J&(P) = \mathop{\arg}\min_P \sum_{i,j}||P^{T}x_{i}-P^{T}x_{j}||^{2}w_{var}\;_{ij}\\
&\;s.t.\;\;\sum_{ij}||P^{T}x_{i}-P^{T}x_{j}||^{2}w'_{cov}\;_{ij}=1
\end{split}
\end{equation}
這里 \; 是讓公式里空一個字符的意思
可以參考這個 Latex 在線編輯公式(雖然個人不喜歡用)旧烧,鏈接如下:
https://latex.91maths.com/
Latex 插入表格
在 Latex 中想要插入如下的一個表格,需要怎么做呢画髓?
\begin{table*}[htbp]
\small
\caption{Classification Accuracy for the Indian Pines dataset}
\label{tbl:example}
\centering
\scalebox{0.5}{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}cccccccccccc}
\hline
* & PCA & LDA & LPP & LDE & LFDA & LGDA & SGDA & SLGDA & GDA-SS & TLPP &TLDE \\
\hline
1 & 0 & 0 & 8.70 & 0 & 43.48 & 2.17 & 45.65 & 6.52 & 47.83 & 94.74 &\textbf{100 }\\
2 & 57.49 & 70.59 & 67.30 & 74.58 & 79.27 & 74.51 & 75.00 & 69.68 & 73.74 & 85.11 &\textbf{93.00} \\
3 & 38.80 & 41.69 & 62.17 & 70.48 & 64.34 & 67.60 & 63.13 & 58.43 & 63.51 & 88.29 &\textbf{91.96 }\\
4 & 24.89 & 8.44 & 46.84 & 41.35 & 47.26 & 39.66 & 55.70 & 31.22 & 55.70 & 93.67 &\textbf{94.26} \\
5 & 54.68 & 75.98 & 91.30 & 89.23 & 89.23 & 91.51 & 87.16 & 81.99 & 89.03 & 88.84 &\textbf{99.76} \\
6 & 93.42 & 90.68 & 98.22 & 96.16 & \textbf{96.99} & 96.44 & 96.71 & 90.41 & 95.21 & 92.72 & 96.46 \\
7 & 0 & 0 & 53.57 & 0 & 10.71 & 50.00 & 25 & 7.14 & 39.29 & \textbf{100} & 96.15 \\
8 & 99.16 & 89.75 & 98.95 & 99.37 & 96.65 & 99.16 & 99.37 & 98.74 & \textbf{99.79} & 94.00 &99.53 \\
9 & 0 & 0 & 0 & 0 & 10 & 0 & 10 & 0 & 0 & 94.44 &\textbf{100 }\\
10 & 58.02 & 28.09 & 69.44 & 66.53 & 67.39 & 66.77 & 67.59 & 62.55 & 64.92 & 87.33 &\textbf{92.27} \\
11 & 82.29 & 81.02 & 84.81 & 87.09 & 81.30 & 85.17 & 81.14 & 69.90 & 71.16 & 85.98 &\textbf{95.07} \\
12 & 24.45 & 29.85 & 61.38 & 59.19 & 69.48 & 59.36 & 77.74 & 40.81 & 64.76 & 93.95 &\textbf{98.36} \\
13 & 93.17 & 80.49 & 90.73 & 99.02 & 95.61 & 93.17 & 98.05 & 86.34 & 96.59 & 98.38 &\textbf{100} \\
14 & 95.18 & 96.28 & 96.76 & 96.76 & 92.57 & 96.13 & 91.38 & 92.49 & 94.07 & 94.85 &\textbf{ 97.91} \\
15 & 51.04 & 44.56 & 49.48 & 31.35 & 66.58 & 62.18 & 69.95 & 61.40 & 68.65 & \textbf{97.47} &90.06 \\
16 & 90.32 & 0 & 94.62 & 92.47 & 48.39 & 91.40 & 90.32 & 82.80 & 80.65 & 94.81 &\textbf{100} \\
\hline
OA & 69.98 & 66.60 & 78.52 & 79.19 & 79.38 & 79.79 & 79.81 & 71.36 & 76.48 & 89.57 &\textbf{95.27} \\
\hline
AA & 55.81 & 46.09 & 67.14 & 62.66 & 66.20 & 67.20 & 70.87 & 58.78 & 69.06 & 92.78 &\textbf{96.55} \\
\hline
\kappa & 65.08 & 60.91 & 75.32 & 76.01 & 76.27 & 76.75 & 76.85 & 67.25 & 73.17 & 88.05 &\textbf{94.60} \\
\hline
\end{tabular*}}
\end{table*}
其中 \begin{table}中的 * 號是讓表格跨雙欄的意思掘剪,因?yàn)橛行┪恼碌母袷绞请p欄的。\small 是控制里面的字體大心蜗骸(還可以使用 \large夺谁,\normalsize 之類的),\label{} 和公式里的效果一樣肉微,\centering 讓里面的字居中匾鸥, \scalebox{0.5}{table} 讓里面的 table 放縮0.5倍。
然后里面的table用 \begin{tabular}開始寫碉纳,
接著\begin{tabular}{cccccccccccc} 其中 c 的個數(shù)表示有多少列扫腺。
\hline 是畫橫線的意思
& 是對齊的意思
\\ 是換行的意思
Latex 插入圖片
插入一個圖片
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth,height=3.5cm]{windowsiez.png} 文件的相對路徑
\caption{Parameter tuning of window size for TLDE.} %caption是圖片的標(biāo)題
\label{fig3}
\end{figure}
其中 windowsize.png 是你要插入的圖片,路勁要和你的 .tex 文件一樣村象。
\width,\height 控制圖片的長寬
插入一行兩個圖片
\begin{figure}[htbp]
\subfigure[]{
\begin{minipage}{3.9cm}
\includegraphics[width=\linewidth,height=3.9cm]{OA.png}
\end{minipage}
}
\subfigure[]{
\begin{minipage}{3.9cm}
\includegraphics[width=\linewidth,height=3.9cm]{paviawangge.png}
\end{minipage}
}
\caption{The overall accuracy corresponding to different spectral dimension and different spatial dimension for TLDE under the condition of window size of $5\times 5$: (a) Indian Pines dataset; (b) University of Pavia dataset.}
\label{fig5}
\end{figure}
\subfigure[] 就是插入子圖的意思攒至,這個會自動編號 (a), (b)
其實(shí)不是很推薦這樣的插入子圖的方式厚者。我喜歡用另外一個插入子圖的方式,如下節(jié)所示迫吐。
插入多行多列的圖片
\begin{figure*}[htbp]
\begin{center}
\begin{tabular}{cccccc}
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-gt.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-PCA.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-LDA.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-LPP.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-LDE.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-LFDA.png} \\
(a) & (b) & (c) & (d) & (e) & (f)\\
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-LGDA.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-SGDA.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-SLGDA.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-GDA_SS.png} &
\includegraphics[width=2.5cm,height=2.5cm]{TLPP_pavia.png} &
\includegraphics[width=2.5cm,height=2.5cm]{PTLDE-TLDE.png} \\
(g) & (h) & (i) & (j) & (k) & (l)
\end{tabular}
\scalebox{0.5}{
\begin{tabular}{c}
\includegraphics[width=\linewidth]{pavialegend.png}
\end{tabular}}
\end{center}
\caption{\label{fig:pavia gt}
Classification maps of different methods for the University of Pavia dataset: (a) ground truth; (b) PCA: 90.00\%; (c) LDA: 87.49\%; (d) LPP: 90.61\%; (e) LDE: 93.99\%; (f) LFDA: 94.08\%; (g) LGDA: 93.32\%; (h) SGDA: 94.16\%; (i) SLGDA: 92.69\%; (j): GDA-SS: 92.72\%; (k) TLPP: 88.68\%; (l) TLDE: 99.04\%}
\end{figure*}
我喜歡這樣的編寫子圖的形式库菲,類似于寫表格。
Latex 參考文獻(xiàn)
方法1
\begin{thebibliography}{99}
\bibitem{c14}
Gao L, Yang B, Du Q, et al. Adjusted spectral matched filter for target detection in hyperspectral imagery[J]. Remote Sensing, 2015, 7(6): 6611-6634.
\end{thebibliography}
這里的 c14 類似于圖片公式里的 \label{} 括號里的東西志膀,都是為了方便引用熙宇。
這是我文章里的 Latex 寫的片段
Hyperspectral image (HSI) usually consists of hundreds of spectral bands from the visible spectrum to the infrared spectrum \cite{c14}.
編譯后的效果如下:
一定要使用 \cite{} 的方式來引用,并且括號里面要避免使用中文溉浙。
方法2
使用 .bib 文件來存參考文獻(xiàn)
首先新建一個 .txt 文件烫止,然后另存為 .bib 文件。
操作如下:
需要注意的是這里保存類型一定要選擇所有文件戳稽。
然后得到這樣一個 .bib 文件
接著把 new.bib 文件和 .tex 文件放在一個目錄下馆蠕。
然后用 TexStudio 打開 .tex 文件,需要做一定的修改。在 \end{document}之前加上互躬,\bibliographystyle{IEEEtran}播赁,\bibliography{new}
其中 \bibliographystyle{IEEEtran}是參考文獻(xiàn)的風(fēng)格, \bibliography{new}是你文章的參考文獻(xiàn)吼渡。
接著使用 Google 學(xué)術(shù)鏡像容为,網(wǎng)站如下:https://ac.scmor.com/
隨意點(diǎn)擊一個進(jìn)行訪問。
假如需要引用 Patch Tensor-Based Sparse and Low-Rank Graph for Hyperspectral Images Dimensionality Reduction 這篇參考文獻(xiàn)寺酪,操作如下坎背。
首先輸入paper 名字,
點(diǎn)擊下面的 引號 ' '(在被引用次數(shù)旁邊)
如果使用第一種引用參考文獻(xiàn)的方式房维,直接復(fù)制 GB/T 7714 里的內(nèi)容即可沼瘫。
如果使用第二種引用參考文獻(xiàn)的方式,則需點(diǎn)擊左下方的 Bib Tex 咙俩,點(diǎn)開之后的界面如下:
把內(nèi)容復(fù)雜到 new.bib 文件里即可耿戚。
這里 @artucle{PTSLGDA} 就是我們的 \cite{} 里面的東西。我喜歡把這里 \cite{} 里的東西改成好些的阿趁,比如這里我就把原先的 an2018patch 改成了 PTSLGDA