Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python cheat sheet table problem
\documentclass[10pt,landscape]{article}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{calc}
\usepackage{ifthen}
\usepackage[landscape]{geometry}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{menukeys}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
% Narrow margins
\ifthenelse{\lengthtest { \paperwidth = 11in}}
{ \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
{\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm} }
}
% Turn off header and footer
\pagestyle{empty}
% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%x
{\normalfont\large\bfseries\center\color{RoyalBlue}}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
{-1explus -.5ex minus -.2ex}%
{0.5ex plus .2ex}%
{\normalfont\normalsize\bfseries\center\color{Cerulean}}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
{-1ex plus -.5ex minus -.2ex}%
{1ex plus .2ex}%
{\normalfont\small\bfseries\center\color{ForestGreen}}}
\makeatother
% Highlighted text
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}
% Don't print section numbers
\setcounter{secnumdepth}{0}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}
% -----------------------------------------------------------------------
\begin{document}
\raggedright
\footnotesize
\begin{center}
\includegraphics[width=12em]{../img/python-logo-master-v3-TM.pdf}
\Large{\textbf{\color{WildStrawberry}{Python REgex cheat sheet}}} \\
\end{center}
\section{Meta characters}
\begin{tabularx}{\textwidth}{ |X|X|X|X| }
\hline
\texttt{re.match('go.', 'gob')} & 2 & 3 & 4 \\
\hline
\color{ForestGreen}{\texttt{re.match('go.', 'gob')}} & 2 & 3 & 4 \\
\hline
\end{tabularx}
\section{Quantifiers}
\begin{tabularx}{\linewidth}{@{}lX@{}}
\texttt{*} & 0 or more repetitions\\
\texttt{+} & 1 or more repetitions\\
\texttt{?} & 0 or 1 repetitions\\
\end{tabularx}
\begin{center}
\rule{0.3\linewidth}{0.25pt}
\end{center}
\includegraphics[width=6em]{../img/by_nc_sa.eps} This work is licensed under a \href{http://creativecommons.org/licenses/by-nc-sa/3.0/}{Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License}.
{\copyright\ 2012 \href{http://matan.name}{Adam Matan}.}
\begin{tiny}
Sources: %\href{http://rayninfo.co.uk/vimtips.html}{Best of Vim Tips},
%\href{http://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.pdf}{Vim Visual Cheat Sheet}
StackOverflow.com questions %\href{http://stackoverflow.com/questions/506075/how-do-i-fix-the-indentation-of-an-entire-file-in-vi} {506075},
%\href{http://stackoverflow.com/questions/12128678/vim-go-to-beginning-end-of-next-method} {12128678}
Graphics credits: %\href{http://commons.wikimedia.org/wiki/File:Gnome-face-smile.svg} {Happy icon},
\href{http://www.python.org/community/logos/python-logo-master-v3-TM.png} {Python Logo},
\href{http://creativecommons.org/about/downloads} {Creative Commons License}
Template and general idea based on a \href{http://www.stdout.org/~winston/latex/}{\LaTeX\ template by Winston Chang}.
\end{tiny}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.