Skip to content

Instantly share code, notes, and snippets.

@fatihbaltaci
Last active November 17, 2019 19:18
Show Gist options
  • Save fatihbaltaci/e46dd0cb504285586d88df43a2821c26 to your computer and use it in GitHub Desktop.
Save fatihbaltaci/e46dd0cb504285586d88df43a2821c26 to your computer and use it in GitHub Desktop.
Latex Cheet Sheet

Symbols

  • Division - Fraction: \frac{}{}
  • Greater or equal: \geq
  • Smaller or equal: \leq

Comment on Algorithm algorithm2e package

\usepackage[ruled, linesnumbered]{algorithm2e}

\tcp*{There is a cycle}

Unweighted Graph Example with tikz

\usepackage{tikz}

\begin{figure}[H]
	\centering

\begin{tikzpicture}
	[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
	\node (s) at (1,5) {s};
	\node (n3) at (4,8)  {3};
	\node (n4) at (8,9)  {4};
	\node (t) at (11,8) {t};
	\node (n2) at (9,6)  {2};
	\node (n1) at (5,5)  {1};
	
	\foreach \from/\to in {s/n3,n3/n4,n2/n4,n2/t, n1/n3, n1/n4, s/n1}
	\draw (\from) -- (\to);
\end{tikzpicture}
\caption{Example Flight Network Graph}
\label{fig:graph}
\end{figure}

Weighted Graph Example with tikz

\begin{figure}[H]
	\centering
	
	\begin{tikzpicture}
	[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
	\node (a) at (1,5) {a};
	\node (b) at (1,9) {b};
	\node (c) at (5,9) {c};
	\node (d) at (5,5) {d};
	
	\foreach \from/\to/\lbl in {a/b/1, b/c/4, c/d/3, b/d/3, a/d/5, a/c/2}
	\draw (\from) -- node[midway,fill=none] {\lbl} (\to);
	\end{tikzpicture}
	\caption{Graph A}
	\label{fig:graph}
\end{figure}

Aligned Formulas

\begin{align}
f(n) &= \frac{(n-1)n(n+1)}{2}\\
	   &= \frac{(n^3-n))}{2}\\
	   &= \frac{1}{2}n^3 - \frac{1}{2}n \label{eq:3}
\end{align}

Cases with Curl Brackets

\usepackage{mathtools}

\[
	f(x)= 
	\begin{dcases}
	\frac{x^2-x}{x},& \text{if } x\geq 1\\
	0,              & \text{otherwise}
	\end{dcases}
\]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment