Latex-常用操作


一、開篇

定義文章類型

\documentclass{}

包括宏包

\usepackage{}

標題設置

\title{}

正文

\begin{document}
	\maketitle	% 標題顯示
	\begin{abstract}	% 摘要
	
	\end{abstract}
	% 正文部分
	\section{}	% 一級部分
		\subsection{}	% 二級部分
		\cref{label}	% 引用文內資源
	% 參考文獻
	\begin{thebibliography}{9}%寬度9
   		\bibitem[1]{liuhaiyang2013latex}
    	劉海洋.
    	\newblock \LaTeX {}入門\allowbreak[J].
    	\newblock 電子工業出版社, 北京, 2013.
    	\bibitem[2]{mathematical-modeling}
    	全國大學生數學建模競賽論文格式規范 (2020 年 8 月 25 日修改).
    	\bibitem{3} \url{https://www.latexstudio.net}
	\end{thebibliography}
	% 附頁
	\begin{appendices}

	\end{appendices}
\end{document}

二、圖片

單圖

\begin{figure}[!h]
    \centering
    \includegraphics[width=.5\textwidth]{fig}	%	通過方框內系數調整圖片大小
    \caption{標題}
    \label{fig:label}	% 標簽
\end{figure}

\begin{figure}后的方框為對圖片進行限制,各參數含義如下:
[h] 當前位置。將圖形放置在正文文本中給出該圖形環境的地方。如果本頁所剩的頁面不夠,這一參數將不起作用。
[t] 頂部。將圖形放置在頁面的頂部。
[b] 底部。將圖形放置在頁面的底部。
[p] 浮動頁。將圖形放置在一只允許有浮動對象的頁面上。
[!] 嘗試定位在當前位置,若該位置放不下仍會浮動

多圖並列

\begin{figure}
    \centering
    \begin{minipage}[c]{0.3\textwidth}
        \centering
        \includegraphics[width=0.95\textwidth]{f1}
        \subcaption{圖1}
        \label{fig:001}
    \end{minipage}
    \begin{minipage}[c]{0.3\textwidth}
        \centering
        \includegraphics[width=0.95\textwidth]{f2}
        \subcaption{圖2}
        \label{fig:002}
    \end{minipage}
    \begin{minipage}[c]{0.3\textwidth}
        \centering
        \includegraphics[width=0.95\textwidth]{f3}
        \subcaption{圖3}
        \label{fig:003}
    \end{minipage}
    \caption{多圖並排示例}
    \label{fig:fig0}
\end{figure}

若要限制圖像高度,則可在包括圖片時指定高度

\includegraphics[height=0.2\textheight]{fig}

三、表格

普通三線表格

\begin{table}[!htbp]
    \caption{標准三線表格}\label{tab:001} \centering
    \begin{tabular}{ccccc}
        \toprule[1.5pt]
        $D$(in) & $P_u$(lbs) & $u_u$(in) & $\beta$ & $G_f$(psi.in)\\
        \midrule[1pt]
        5 & 269.8 & 0.000674 & 1.79 & 0.04089\\
        10 & 421.0 & 0.001035 & 3.59 & 0.04089\\
        20 & 640.2 & 0.001565 & 7.18 & 0.04089\\
        \bottomrule[1.5pt]
    \end{tabular}
\end{table}

四、公式

行內公式

$a = b$

行間公式

% 無編號
\[
	a = b
\]
% 或
\begin{equation*}
	E=mc^2
	\label{eq:energy}
\end{equation*}

% 有編號
\begin{equation}
	E=mc^2
	\label{eq:energy}
\end{equation}

多行公式

\begin{align}
	P & = UI \\
	  & = I^2R
\end{align}

公式每行在&​處對齊,在\\處換行

分段函數同理,可以放到cases環境中

\[
f(x) =
    \begin{cases}
        0 &  x \text{為無理數} ,\\
        1 &  x \text{為有理數} .
    \end{cases}
\]

矩陣輸入

\[
\mathbf{X} = \left(
    \begin{bmatrix}{cccc}
    x_{11} & x_{12} & \ldots & x_{1n}\\
    x_{21} & x_{22} & \ldots & x_{2n}\\
    \vdots & \vdots & \ddots & \vdots\\
    x_{n1} & x_{n2} & \ldots & x_{nn}\\
    \end{bmatrix} \right)
\]

其他環境

\begin{definition}
    定義環境
    \label{def:nosense}
\end{definition}

\begin{theorem}
    這是一個定理。
    \label{thm:example}
\end{theorem}

\begin{lemma}
    這是一個引理。
    \label{lem:example}
\end{lemma}

\begin{corollary}
    這是一個推論。
    \label{cor:example}
\end{corollary}

\begin{assumption}
    這是一個假設。
    \label{asu:example}
\end{assumption}

\begin{conjecture}
    這是一個猜想。
    \label{con:example}
\end{conjecture}

\begin{axiom}
    這是一個公理。
    \label{axi:example}
\end{axiom}

\begin{principle}
    這是一個定律。
    \label{pri:example}
\end{principle}

\begin{problem}
    這是一個問題。
    \label{pro:example}
\end{problem}

\begin{example}
    這是一個例子。
    \label{exa:example}
\end{example}

\begin{proof}
    這是一個證明。
    \label{prf:example}
\end{proof}

\begin{solution}
    這是一個解。
    \label{sol:example}
\end{solution}

五、其他補充

腳注

\footnote{腳注說明}

列表

% 有序列表
\begin{enumerate}
    \item one
    \item two
    \item ...
\end{enumerate}
% 無序列表
\begin{itemize}
    \item one
    \item two
    \item ...
\end{itemize}

字體加粗

% 文字加粗
\textbf{文字}
% 公式加粗
\pmb{\alpha}

代碼塊

\begin{lstlisting}[language=matlab] % 選定語言
% 代碼正文

% 正文結束
\end{lstlisting}

符號輸入





免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM