Latex入門以及基本代碼詳解

本文送給想了解Latex基本排版功能&面對龐大的模板不知所措的小夥伴

1.全英文輸出

\documentclass{article}
% 這裏是導言區
\begin{document}
Hello, world!
\end{document}

2.中英文混輸

\documentclass[UTF8]{ctexart}
\begin{document}
你好,world!
\end{document}

3.數學公式

(空一行爲另起一段,\\爲段內強制換行。)

\documentclass{article} 
\usepackage{amsmath} 
\usepackage{amssymb} 
\begin{document}
The Newton's second law is $F=ma$.
 
Greek Letters $\eta$ and $\mu$ 
 
Fraction $\frac{a}{b}$ 
 
Power $a^b$  
\end{document}

輸出
在這裏插入圖片描述

\documentclass{article} 
   \usepackage{amsmath} 
   \usepackage{amssymb} 
\begin{document}
$p_{\theta }\left ( x\mid y \right )\propto exp\sum_{e\in E,k}^{}\lambda _{k} $
\end{document}

在 https://private.codecogs.com/latex/eqneditor.php 網站中編輯數學公式
$$是開啓行內數學模式,用於和文本合在一起使用。
在這裏插入圖片描述

4.標題,作者

\documentclass{article} 
   \author{My Name} 
   \title{The Title} 
\begin{document}  
   \maketitle  
   hello, world % This is comment  
\end{document}

在這裏插入圖片描述

5.段落章節

\documentclass{article} 
   \title{Hello World} 
\begin{document}  
   \maketitle  
   \section{Hello China} China is in East Asia.  
     \subsection{Hello Beijing} Beijing is the capital of China.  
       \subsubsection{Hello Dongcheng District}  
         \paragraph{Tian'anmen Square}is in the center of Beijing  
           \subparagraph{Chairman Mao} is in the center of Tian'anmen Square  
      \subsection{Hello Guangzhou}  
         \paragraph{Sun Yat-sen University} is the best university in Guangzhou.  
\end{document}

在這裏插入圖片描述

文檔結構點擊相應位置可以準確定位
在這裏插入圖片描述

6.插入圖片,可以調整圖片大小

\documentclass{article} 
   \usepackage{graphicx} 
\begin{document}
hello world!\\
   \includegraphics[width=1.40in,height=1.30in]{1.png}  
\end{document}

[width = .5\textwidth] 按圖片原比例調整圖片大小

7.製作表格

\documentclass{article} 
   \usepackage{graphicx} 
\begin{document}
\begin{table}
\centering
\caption{TableName}
\begin{tabular}{|l|l|l|l|}
\hline
 & vgg16 & incev3 & resnet \\ \hline
patch-unary & 0.734 & 0.766 & 0.888 \\ \hline
patch-binary & 0.677 & 0.788 & 0.676 \\ \hline
\end{tabular}
\end{table}
\end{document}

效果不怎麼樣,略醜
在這裏插入圖片描述

8.引用文獻

過程有點曲折。。
首先要有一個放以下引用目錄的bib文件

@article{rivero2001resistance,
title={Resistance to cold and heat stress: accumulation of phenolic compounds in tomato and watermelon plants},
author={Rivero, Rosa M and Ruiz, Juan M and Garc{\i}a, Pablo C and L{\'o}pez-Lefebre, Luis R and S{\'a}nchez, Esteban and Romero, Luis},
journal={Plant Science},
volume={160},
number={2},
pages={315--321},
year={2001},
publisher={Elsevier}
}


@article{gostout1992clinical,
title={The clinical and endoscopic spectrum of the watermelon stomach},
author={Gostout, Christopher J and Viggiano, Thomas R and Ahlquist, David A and Wang, Kenneth K and Larson, Mark V and Balm, Rita},
journal={Journal of clinical gastroenterology},
volume={15},
number={3},
pages={256--263},
year={1992},
publisher={LWW}
}

一開始創建的時候只可以創建tex文件,然後選打開方式,用texwork打開,另存爲選擇bib格式,然後和.tex存到同一個目錄下
一開始編譯說undefine

\documentclass{article}
\usepackage[numbers]{natbib}
\begin{document} 
          One reference about watermelon \cite{gostout1992clinical}         
          Another reference about watermelon \cite{rivero2001resistance}         
          \bibliographystyle{plain}         
          \bibliography{reference}         
        \end{document}

採用玄學編譯法使用 pdflatex 編譯

之後使用 bibtex 編譯

之後在使用 pdflatex 編譯兩次

可以之後可以使用bibtex 編譯一次

Xelatex 編譯兩次。
最後再快速構建一次就行了
想知道怎麼得到BIB文件內容的戳我
在這裏插入圖片描述

https://blog.csdn.net/junruitian/article/details/102736042

8.標號

\begin{itemize}
\item 內容
\item 
\end{itemize}
%默認爲圓點標記
\begin{enumerate}
\item 內容
\item 
\end{enumerate}
%數字有序標識
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章