1 Basics 2 Formatting Pages 3 Text Attributes
Total Page:16
File Type:pdf, Size:1020Kb
Cheat Sheet for LATEX Firuza Karmali aka Aibara Page 1 of 2 1 Basics Page Breaks: \pagebreak OR \newpage Document Structure \documentclass[10pt|11pt|12pt] 2-Column Page: \documentclass[...,twocolumn]{...} {article|book|report} \title{Title of your Document} Multi Column: \usepackage{multicol} \author{Name 1 \\ Name 2} \begin{multicols}{No. of cols} \date{\today} ... ... \begin{document} \end{multicols} \ maketitle ... New column: \columnbreak \end{document} Multi-Column(Spacing): \setlength{\columnsep}{Xpt} Multi-Column(Rule): Level No. LevelName / Sections Article Report Book \setlength{\columnseprule}{Xpt} -1 n partfTitleg Footnotes: 0 nchapterfTitleg N ... \footnote{Text...} ... 1 nsectionfTitleg 3 Text Attributes 2 nsubsectionfTitleg 3 nsubsubsectionfTitleg Style Command Size 10pt 11pt 12pt 4 nparagraphfTitleg Bold ntextbff...g tiny 5 6 6 5 nsubparagraphfTitleg Italics ntextitf...g scriptsize 7 8 8 Blank cell denotes `Yes' Emphasis nemphf...g footnotesize 8 9 10 ToC (Table of Contents): \tableofcontents Underline nunderlinef...g small 9 10 10.95 Hide in ToC: LevelName*{...} E.g. \section*{...} Alternate Title in ToC (Display alias): Small Caps ntextscf...g normalsize 10 10.95 12 E.g. \section[Alternative]{Actual Title} Roman ntextrmf...g large 12 12 14.4 Sans Serif ntextsff...g Large 14.4 14.4 17.28 Hyhen:- En-dash:\textendash Em-dash:\textemdash Typewriter ntextttf...g LARGE 17.28 17.28 20.74 Special characters Superscript ntextsuperscriptf...g huge 20.74 20.74 24.88 !@*()-+=?[]/\$ \& \% \_ \{ \} \# Subscript ntextsubscriptf...g Huge 24.88 24.88 24.88 2 Formatting Pages Colors: https ://en.wikibooks.org/wiki/LaTeX/Colors Size: \usepackage[<PSize>]{geometry} \usepackage{color} %Basic Colors <PSize>: a0paper to a6paper, b0paper to b6paper, \usepackage[dvipsnames]{xcolor} %More colors legalpaper, executivepaper, etc. Single color: \textcolor{name}{...Text...} Mix with white: Margins (Single Side Document): \textcolor{name!Percentage}{Text} Mixture of 2: \textcolor{name!Percentage!name}{Text} \usepackage[margin=1in]{geometry} Page color: \pagecolor{name} \usepackage[top=1in,bottom=2in,left=1in,right=1in] { geometry } Text Alignment Two Sided Document Certain part: \begin{flushleft|flushright|center} \documentclass[twoside]{article|report} ... \documentclass{book} %book is 2sided \end{flushleft | flushright | center} Margins (Two Sided Document - Even and Odd): Larger part: \flushleft \flushright \centering Justify: \usepackage{ragged2e} \justify \usepackage[inner=2in,outer=1in]{geometry} Spacing Page Numbering(Entire Document): \pagestyle{<Style>} Page Numbering(Current Page): \usepackage{setspace} \thispagestyle{<Style>} (Larger part) <Style>: empty, plain, headings \singlespacing | \onehalfspacing | \doublespacing (Specific Part) Fancy Header and Footer: \begin{singlespace|onehalfspace|doublespace} \usepackage{fancyhdr} ... \pagestyle{fancy} \end{singlespace|onehalfspace|doublespace} \lhead{...} \chead{...} \rhead{...} Custom (Larger part) \spacing{X} \lfoot{...} \cfoot{...} \rfoot{...} Custom (Specific) \begin{spacing}{X}...\end{spacing} Fields in Header and Footer: Vertical Spacing: \vspace{Xpt}, \smallskip, \medskip, \thepage : Page number \bigskip, \vfill \chaptername: Denotes the title 'Chapter' Horizontal Spacing: \hspace{Xpt} \ \, \hfill \thechapter : Chapter number \thesection : Section number Bullets and Numbering \usepackage{lastpage} \pageref{LastPage}:No.ofPages \begin{itemize | enumerate | description} \ item ... Numbering Style: \pagenumbering \item[...] ... % Used only with description {arabic|roman|Roman|alph|Alph} \end{itemize | enumerate | description} Set Page Number:\setcounter{page}{<Number>} Change Numering Style Landscape (Entire Document): \usepackage{enumerate} \begin{enumerate}[A.] \usepackage[...,landscape]{geometry} Change Bullet Style Landscape (Specific Part): \usepackage{amssymb} \usepackage{lscape} OR \usepackage{pdflscape} \renewcommand{\labelitem<Level>}{$<Style>$} \begin{landscape} <Style>: \blacksquare, \square, \bullet, \cdot, \ ... diamond, -, *, \circ \end{landscape} Cheat Sheet for LATEX Firuza Karmali aka Aibara Page 2 of 2 4 Mathematics Use as Figures \begin{figure}[h|b|t] \usepackage{amsmath} \includegraphics ... Typeset inline $ ... $ \caption{...} Typeset bigger \[...\] \end{figure} \listoffigures Basic symbols ^ _ \times \cos \sin \cup \text{...} \{ ... \} Subfigure \usepackage{caption} \usepackage{subcaption} Fractions: \frac{num}{den} \begin{figure}[h|b|t] \begin{subfigure}{<width>} Bracket size: \Bigg \bigg \Big \big \includegraphics... \caption{...} Summation: \sum_{min}^{max} \end{subfigure} ... Integration: \int_{min}^{max} \caption{...} \end{figure} Limits: \ lim_ {...} Matrices: \begin{<matrixType >}...\end{<matrixType>} 7 Title, Links <matrixType>: matrix, pmatrix, bmatrix, Bmatrix, Title Page: \begin{titlepage} ... \end{titlepage} vmatrix, Vmatrix Hyperlinks: \usepackage{hyperref} \url{...} OR \href{...}{Alias} Equation: \begin{equation}...\end{equation} Cross Referencing: \label{KEY} \ref{KEY}, \nameref{KEY}, \pageref{KEY} Multi-line Equation: \begin{align}...\end{align} &= \ nonumber 8 Index 5 Tables \usepackage{imakeidx} \makeindex[columns=X, title=..., intoc] \begin{tabular}{<Alignment>} Entry: \index{KEY} ... Sub-entry: \index{ParentKEY!KEY} \end{tabular} Cross-referencing Key: \index{KEY|see{OtherKEY}} <Alignment>: l, r, c, p{Xcm} Print index: \printindex Note the following: - & denotes new column/cell - \\ denotes end of the row 9 References (Bibliography) - | vertical line .bib File - \ hline @article{KEY, - \cline{i-j} author = { }, - Dashed border: \usepackage{arydshln} title = { }, - : dashed vertical line } - \hdashline[size of dash/space between dash] Citing in .tex File: \cite{KEY} - \cdashline[size of dash/space between dash]{i-j} \bibliographystyle{abbrv|alpha|unsrt|acm} Merge Columns \bibliography{filename.bib} Including Reference without Citing: \nocite{KEY} \multicolumn{<NumberOfColumns >}{<Alignment >}{...} Merge Rows \usepackage{multirow} 10 Beamer \multirow{<NumberOfRows >}{<Width>}{...} <Width> can be replaced with * or actual width \documentclass{beamer} Slides: \begin{frame}[t|c|b]{Frame Title} ... Spacing: \renewcommand{\arraystretch}{X} \end{frame} Theme: \usetheme{....} Color Theme: Table(Spanning Multiple Pages): \usepackage{longtable} \usecolortheme{...} \begin{longtable} \url{https://hartwork.org/beamer-theme-matrix/} ... Blocks: \end{longtable} \begin{block}{title} ... \end{block} \begin{alertblock}{Title} ... \end{alertblock} Table Environment: \begin{table}[h|b|t] \begin{example} ... \end{example} Columns: \begin{tabular}... \begin{columns} ... \end{columns} ... \column{X\textwidth} Overlay: \end{tabular} \pause, <No.->, <No.>, \onslide<No.->, \caption{...} \onslide<No.> \end{table} Customize themes: \listoftables \setbeamercolor{structure}{fg=color} 6 Images \setbeamercolor{palette tertiary}{bg=color, fg= color } \usepackage{graphicx} \setbeamercolor{palette secondary}{bg=color, Original:\includegraphics{file.extn} fg= color } Resize:\includegraphics[width|height=Xin]{file.extn} \setbeamercolor{palette primary}{bg=color,fg=color} Scale:\includegraphics[scale=X]{file.extn} \setbeamercolor{title}{bg=color,fg=color} Crop:\includegraphics[clip=true, \setbeamercolor{frametitle}{bg=color,fg=color} trim=Lmm Bmm Rmm Tmm]{file.extn} \setbeamercolor{background canvas}{bg=color} Rotate:\includegraphics[angle=X]{file.extn} Border 11 Important Packages Thickness: \setlength{\fboxrule}{Xpt} geometry, lipsum, lscape, pdflscape, multicol, color, xcolor, ragged2e, Space: \setlength{\fboxsep}{Xpt} setspace, enumerate, amssymb, arydshln, multirow, longtable, graphicx, cap- Set: \fbox{\includegraphics...} tion, subcaption, imakeidx.