\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{tam vu} \pdfinfo{ /Title (beginner.pdf) /Creator (Cheatography) /Author (tam vu) /Subject (beginner Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0A14A3} \definecolor{LightBackground}{HTML}{F7F7FC} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{beginner Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{tam vu} via \textcolor{DarkBackground}{\uline{cheatography.com/146656/cs/31754/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}tam vu \\ \uline{cheatography.com/tam-vu} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 11th May, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{numpy}} \tn % Row 0 \SetRowColor{LightBackground} create numpy array kieu integer & np.empty ((m, n), np.int\_) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} create a set of n random points with coordinate & \seqsplit{np.random.randint(start}, end, (n,2)) \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} import matplotlib to plot & import matplotlib.pyplot as plt \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} import math & import math \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} sort list X from highest to smallest & \seqsplit{X.sort(reverse=True)} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} sort list X smallest to highest & X.sort() \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} define a function with a value. Need to call f(x) later such as: y = f(x) & def f(x): square = x**x return square \tn % Row Count 16 (+ 4) % Row 7 \SetRowColor{white} define a function without return (print) & def f(x): square x**x print(square) \tn % Row Count 19 (+ 3) % Row 8 \SetRowColor{LightBackground} điểm i được visit hay chưa, nhận giá trị 0 1 & \seqsplit{routing.ActiveVar(i)} \tn % Row Count 22 (+ 3) % Row 9 \SetRowColor{white} xe nào đi qua điểm i (trả giá trị xe thứ k) & \seqsplit{routing.VehicleVar(i)} \tn % Row Count 25 (+ 3) % Row 10 \SetRowColor{LightBackground} tập hợp các điểm có thể đi từ i trong tập còn lại của vertex trong ngôn ngữ máy & routing.NextVar(i) \tn % Row Count 31 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{numpy (cont)}} \tn % Row 11 \SetRowColor{LightBackground} Sau điểm 3 không được chạy đến điểm 1 & \seqsplit{routing.NextVar(3).remove(1)} \tn % Row Count 3 (+ 3) % Row 12 \SetRowColor{white} Or tool-xe k có chạy hay không? & \seqsplit{routing.ActiveVehicleVar(k)} \tn % Row Count 5 (+ 2) % Row 13 \SetRowColor{LightBackground} Or tool-time tới điểm i & routing.timeAcum(i) \tn % Row Count 7 (+ 2) % Row 14 \SetRowColor{white} Or tool-append (add) one more value to x & x.append(value) \tn % Row Count 9 (+ 2) % Row 15 \SetRowColor{LightBackground} Or tool-length of matrix is number of rows (m) & x = np.empty ((m,n), np.int\_), len(x) \tn % Row Count 12 (+ 3) % Row 16 \SetRowColor{white} ctrl+? & \# text \tn % Row Count 13 (+ 1) % Row 17 \SetRowColor{LightBackground} ctrl+F9 & run from the beginning \tn % Row Count 15 (+ 2) % Row 18 \SetRowColor{white} define an array(3,1) in numpy & x = np.array({[}{[}1{]}, {[}2{]}, {[}3{]}{]}) \tn % Row Count 18 (+ 3) % Row 19 \SetRowColor{LightBackground} matrix b multiply matrix a & c = np.dot(b,a) \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{numpy}} \tn % Row 0 \SetRowColor{LightBackground} create a set of n random points with coordinate & \seqsplit{np.random.randint(start}, end, (n,2)) \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}