Back

My Latex Cheatsheet

整理一下自己用过的latex命令。

标题及基础设置

\documentclass[a4paper, zihao=-4, UTF8]{ctexart}
\CTEXsetup[format={\Large\bfseries}]{section}

\title{}
\author{}
\date{}
\pagesytle{}

%\setcounter{section}{-1}   % section start from 0

\begin{document}
	\maketitle
	\section{}
	\section[short title]{}
	\label{sec:section_with_short_title}
	section \ref{sec:section_with_short_title} is a section with a short title. %交叉引用
	\section*{}
	\subsection{}
	\subsection*{}
	\subsubsection{}
	\subsubsection*{}
	\paragraph{}
	\par
\end{document}

数学符号

常用数学符号

Code Latex Code Latex
\because $\because$ \therefore $\therefore$
\frac{a}{b} $\frac{a}{b}$ \dfrac{a}{b} $\dfrac{a}{b}$
\cdot $\cdot$ \cdots $\cdots$
\ldots $\ldots$ \infty $\infty$
\log $\log$ \lim $\lim$
\sin $\sin$ \cos $\cos$
\rightarrow $\rightarrow$ \int_{0}^{1} $\int_{0}^{1}$
\iint $\iint$ \oint $\oint$
\oiint $\oiint$ \iiint $\iiint$
\in $\in$ \notin $\notin$
\forall $\forall$ \exist $\exist$
\sqrt{a} $\sqrt{a}$ \exist $\exist$
\neg $\neg$ \oplus $\oplus$

\sum\limits\_{i=1}^{10}: $\sum\limits_{i=1}^{10}$

\prod\limits\_{i=1}^{10}: $\prod\limits_{i=1}^{10}$

\lim\limits\_{i\rightarrow+\infty}: $\lim\limits_{i\rightarrow+\infty}$

希腊字母

Code Latex Code Latex
\alpha $\alpha$ \varepsilon $\varepsilon$
\delta $\delta$ \pi $\pi$
\rho $\rho$ \lambda $\lambda$
\varphi $\varphi$ \mu $\mu$
\Delta $\Delta$ \Sigma $\Sigma$
\Pi $\Pi$ \theta $\theta$

二元运算符

Code Latex Code Latex
\equiv $\equiv$ \neq $\neq$
\leqslant $\leqslant$ \geqslant $\geqslant$
\sim $\sim$ \approx $\approx$
\mid $\mid$ \nmid $\nmid$
\pm $\pm$ \times $\times$
\cup $\cup$ \cap $\cap$
\subset $\subset$ \supset $\supset$

括号

Code Latex Code Latex
\left( \right) $\left(\right)$ \left[ \right] $\left[\right]$
\left\\{ \right\\} $\left{\right}$ \left\lbrace \right\rbrace $\left\lbrace\right\rbrace$
\left< \right> $\left<\right>$ \left) \right( $\left) \right($
\left|\right| $\left|\right|$ \left&#124; \right&#124; $\left&#124; \right&#124;$
\left\{ \right. $\left{ \right.$

图片

\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption2}

\renewcommand{\figurename}{图}
\renewcommand{\captionlabeldelim}{.}
\renewcommand{\thesubfigure} {\thefigure.\arabic{subfigure}} \makeatletter
\renewcommand{\@thesubfigure}{\thesubfigure:\space} \renewcommand{\p@subfigure}{} \makeatother

\begin{document}
	\begin{figure}[h]
		\centering
		\includegraphics[width=0.8\textwidth]{filepath/pngname.png}
		\caption{caption of this figure}
		\label{label of this figure}
	\end{figure}
	\begin{figure}[H]
		\centering
		\subfigure[caption of this subfigure-1]{
			\includegraphics[width=0.45\textwidth]{filepath/pngname}
			\label{label of this subfigure-1}
		}
		\subfigure[caption of this subfigure-2]{
			\includegraphics[width=0.45\textwidth]{filepath/pngname}
			\label{label of this subfigure-2}
		}
		\caption{caption of figures}
		\label{label of figures}
	\end{figure}
	use \ref{label of this figure} to quote it. %交叉引用
\end{document}

代码块

\usepackage{listings}
\usepackage{xcolor}

\setmonofont{Consolas}
\setsansfont{Consolas}
\lstset{
	columns=fixed,
	breakatwhitespace=true,
	breaklines=true,
	breakindent=26pt,
	captionpos=bl,
	numbers=left,
	frame=shadowbox,
	basicstyle=\ttfamily,
	keywordstyle=\ttfamily\color{blue},
	numberstyle=\footnotesize\color{darkgray},
	commentstyle=\ttfamily\it\color[RGB]{0,96,96},
	stringstyle=\ttfamily\color{magenta},
	showstringspaces=false,
	language=Java,
	identifierstyle=\ttfamily,
	tabsize=4,
}

\begin{document}
	\begin{lstlisting}[title={\bf your.title}]
% put your code here
	\end{lstlisting}
\end{document}

作者

\usepackage{authblk}
\renewcommand*{\Affilfont}{\small} % 修改机构名称的字体与大小
\renewcommand\Authand{, } % 去掉 and 前的逗号

\title{\textbf{Title} }
\author[1]{xxx}
\author[2]{xxx}
\affil[1]{(\it xx大学\ xx学院,\ \rm 0000)}
\affil[2]{(\it xx大学\ xx学院,\ \rm 0000)}
\date{}

摘要

中英文摘要

\newcommand{\enabstractname}{Abstract}
\newcommand{\cnabstractname}{摘要}
\newenvironment{cnabstract}{%
	\par\small
	\noindent\mbox{}\hfill{\bfseries \cnabstractname}\hfill\mbox{}\par
	\vskip 2.5ex}{\par\vskip 2.5ex}

\newenvironment{enabstract}{%
	\par\small
	\noindent\mbox{}\hfill{\bfseries \enabstractname}\hfill\mbox{}\par
	\vskip 1.5ex}{\par\vskip 2.5ex} 

\begin{document}
	\begin{cnabstract}
		xxx
		
		\textbf{关键词:}xxx;xxx;xxx
	\end{cnabstract}
	\begin{enabstract}
		xxx
		
		\textbf{Keywords:}xxx;xxx;xxx;
	\end{enabstract}
\end{document}

交叉引用

\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
	citecolor=blue,
	linkcolor=blue
}
\begin{document}
	\ref{label}
	\nameref{label}
	
	\cite{1} % cite a reference
	
	\begin{thebibliography}{99} % reference
		\bibitem{1}
		xxx,xxx,xxx
	\end{thebibliography}
\end{document}

附录

\usepackage{appendix}
\renewcommand{\appendixname}{Appendix~\Alph{section}}

\begin{document}
	\newpage
	\appendix
	\section{xxxxx}
\end{document}

画图

闲得无聊查了一下,惊奇地发现Latex甚至可以画图,而且功能极其庞大,甚至有老哥画了个印度地图。。。

https://texample.net/tikz/examples/

找到个网站。要用的时候到里面找吧。

Built with Hugo
Theme Stack designed by Jimmy