\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{Gaston} \pdfinfo{ /Title (python-string-formatting.pdf) /Creator (Cheatography) /Author (Gaston) /Subject (Python String Formatting 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}{82C97D} \definecolor{LightBackground}{HTML}{F7FBF6} \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{Python String Formatting Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Gaston} via \textcolor{DarkBackground}{\uline{cheatography.com/24027/cs/21185/}}} \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}Gaston \\ \uline{cheatography.com/gaston} \\ \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 21st November, 2019.\\ 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*}{2} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{C-printf Style}} \tn % Row 0 \SetRowColor{LightBackground} General form & pf\_string1 \% ( arg1 {[}, arg2 ...{]} ) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & pf\_string2 \% \{ 'name1' : arg1{[}, ...\} ) \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{pf\_string1} & " \textless{}literal\textgreater{}|\textless{}fmt1\textgreater{} ... " \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{pf\_string2} & " \textless{}literal\textgreater{}|\textless{}fmt2\textgreater{} ... " \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \textless{}literal\textgreater{} & any code point outside of fmt is output as is \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \%\% & outputs '\%' (escape) \tn % Row Count 11 (+ 1) % Row 6 \SetRowColor{LightBackground} \textless{}fmt1\textgreater{} & \% {[}\textless{}conversion-flags\textgreater{}{]} {[}\textless{}min-field-width\textgreater{}{]} {[}\textless{}precision\textgreater{}{]} {[}\textless{}length\textgreater{}{]} \textless{}conversion-type\textgreater{} \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} \textless{}fmt2\textgreater{} & \% "(" \textless{}key\textgreater{} ")" {[}\textless{}conversion-flags\textgreater{}{]} {[}\textless{}min-field-width\textgreater{}{]} {[}\textless{}precision\textgreater{}{]} {[}\textless{}length\textgreater{}{]} \textless{}conversion-type\textgreater{} \tn % Row Count 18 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.444 cm} x{2.964 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{printf-style format specifiers}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}key\textgreater{} & mapping key-anme in passed dictionary & \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \textless{}conversion-flags\textgreater{} & "\#" & conversion uses alternative form (see alternative form in format mini-language section) \tn % Row Count 9 (+ 6) % Row 2 \SetRowColor{LightBackground} & "0" & 0 padded numeric value \tn % Row Count 11 (+ 2) % Row 3 \SetRowColor{white} & "-" & left adjust (overrides zero-padding) \tn % Row Count 14 (+ 3) % Row 4 \SetRowColor{LightBackground} & " " & leave space before positive number \tn % Row Count 17 (+ 3) % Row 5 \SetRowColor{white} & "+" & sign character "-" or "+" will preceede the converted number \tn % Row Count 21 (+ 4) % Row 6 \SetRowColor{LightBackground} \textless{}min-field-width\textgreater{} & "*" & minimum width read from passed value tuple and must be followed by the value itself \tn % Row Count 27 (+ 6) % Row 7 \SetRowColor{white} & \textless{}n\textgreater{} & minimum field width \tn % Row Count 29 (+ 2) % Row 8 \SetRowColor{LightBackground} \textless{}precision\textgreater{} & "." "*" & precision read from next value in value tuple followed by th evalue itself \tn % Row Count 34 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.444 cm} x{2.964 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{printf-style format specifiers (cont)}} \tn % Row 9 \SetRowColor{LightBackground} & "." \textless{}n\textgreater{} & precision, \textless{}n\textgreater{} digits after decimal separator \tn % Row Count 3 (+ 3) % Row 10 \SetRowColor{white} \textless{}length-modifier\textgreater{} & "h" | "l" | "L" & ignored in Python \tn % Row Count 6 (+ 3) % Row 11 \SetRowColor{LightBackground} \textless{}conversion-type\textgreater{} & "d"|"i" & signed integer \tn % Row Count 9 (+ 3) % Row 12 \SetRowColor{white} & "o" & signed octal \tn % Row Count 10 (+ 1) % Row 13 \SetRowColor{LightBackground} & "u" & (obsolte) same as "d" \tn % Row Count 12 (+ 2) % Row 14 \SetRowColor{white} & "x" & signed hexadecimal (lower case) \tn % Row Count 14 (+ 2) % Row 15 \SetRowColor{LightBackground} & "X" & signed hexadecimal (upper case) \tn % Row Count 16 (+ 2) % Row 16 \SetRowColor{white} & "e" & floating point number in exponential form (lowercase 'e') \tn % Row Count 20 (+ 4) % Row 17 \SetRowColor{LightBackground} & "E" & floating point number in exponential form (uppercase 'E') \tn % Row Count 24 (+ 4) % Row 18 \SetRowColor{white} & "f"|"F" & decimal floating point \tn % Row Count 26 (+ 2) % Row 19 \SetRowColor{LightBackground} & "g" & floating point form,at using exponential format iof exponent less than -4 (lowercase 'e') \tn % Row Count 32 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.444 cm} x{2.964 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{printf-style format specifiers (cont)}} \tn % Row 20 \SetRowColor{LightBackground} & "G" & floating point form,at using exponential format iof exponent less than -4 (uppercase 'e') \tn % Row Count 6 (+ 6) % Row 21 \SetRowColor{white} & "c" & single character \tn % Row Count 7 (+ 1) % Row 22 \SetRowColor{LightBackground} & "r" & string - converts any object using repr() \tn % Row Count 10 (+ 3) % Row 23 \SetRowColor{white} & "s" & string - converts any object using str() \tn % Row Count 13 (+ 3) % Row 24 \SetRowColor{LightBackground} & "a" & string - converts any object using ascii() \tn % Row Count 16 (+ 3) % Row 25 \SetRowColor{white} & "\%" & literal '\%' \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.292 cm} x{3.116 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{String format}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{str.format()} & \textless{}format-string\textgreater{} "." format( \textless{}args\textgreater{} ) & \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \textless{}format string\textgreater{} & literal string with \textless{}field\textgreater{} definitions & \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \textless{}args\textgreater{} & \textless{}arg1\textgreater{}, \textless{}arg2\textgreater{}, ... & poisitional arguments referenced by index \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} & \textless{}kw1\textgreater{} "=" \textless{}arg1\textgreater{}; \textless{}kw2\textgreater{} "=" \textless{}arg2\textgreater{}, ... & keyword args referenced by name \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} & "**" dctVar & args as dictionary, referenced by name \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} \textless{}field\textgreater{} & "\{" {[}\textless{}field\_name\textgreater{}{]} {[}"!" \textless{}conversion\textgreater{}{]} {[}":" \textless{}format\_spec\textgreater{}{]} "\}" & \tn % Row Count 19 (+ 4) % Row 6 \SetRowColor{LightBackground} \textless{}field\_name\textgreater{} & \textless{}arg\_name\textgreater{} ("." \textless{}attribute\_name\textgreater{} | "{[}" \textless{}element\_index\textgreater{} "{]}")* & \tn % Row Count 23 (+ 4) % Row 7 \SetRowColor{white} \textless{}arg\_name\textgreater{} & {[}\textless{}digit\textgreater{}+ | \textless{}identifier\textgreater{} {]} & refering by index (positional arguments) or name (passed named arguments or dict variable) (see \textless{}args\textgreater{}) \tn % Row Count 30 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.292 cm} x{3.116 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{String format (cont)}} \tn % Row 8 \SetRowColor{LightBackground} \textless{}attribute\_name\textgreater{} & \textless{}identifier\textgreater{} & \tn % Row Count 3 (+ 3) % Row 9 \SetRowColor{white} \textless{}element\_index\textgreater{} & \textless{}digit\textgreater{}+ | \textless{}index\_string\textgreater{} & \tn % Row Count 6 (+ 3) % Row 10 \SetRowColor{LightBackground} \textless{}index\_string\textgreater{} & \textless{}any-character except "{]}"\textgreater{} + & \tn % Row Count 9 (+ 3) % Row 11 \SetRowColor{white} \textless{}conversion\textgreater{} & "r" & convert to string via repr() \tn % Row Count 11 (+ 2) % Row 12 \SetRowColor{LightBackground} & "s" & convert to string via str() \tn % Row Count 13 (+ 2) % Row 13 \SetRowColor{white} & "a" & convert to string via ascii() \tn % Row Count 15 (+ 2) % Row 14 \SetRowColor{LightBackground} \textless{}format-spec\textgreater{} & see format specification mini-language & \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.368 cm} x{1.9 cm} x{4.332 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Formatted String (V3.6+)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{"f"|"F" \textbackslash{}" \textless{}literal\textgreater{}|"\{\{"|"\}\}"|\textless{}field\textgreater{} ... \textbackslash{}"} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}literal\textgreater{} & literal character & any code point except "\{", "\}" or NULL \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} "\{\{" or "\}\}" & escape & outputs "\{" respectively "\}" \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.368 cm} x{3.116 cm} x{3.116 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{\textless{}field\textgreater{}}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}field\textgreater{} & "\{" \textless{}fielddef\textgreater{} "\}" & \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textless{}fielddef\textgreater{} & \textless{}expr\textgreater{} {[} "!" \textless{}conversion\textgreater{} {]} {[} ":" \textless{}format\textgreater{} {]} & \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \textless{}expr\textgreater{} & ( \textless{}conditional\_expression\textgreater{} | "{\emph{" \textless{}or\_expr\textgreater{}) ("," \textless{}conditional\_expression\textgreater{} | "," "}}" \textless{}or\_expr\textgreater{} )* {[}","{]} | \textless{}yield\_expression\textgreater{} & virtually any python expressions works here. Some minor restrictions apply. \tn % Row Count 13 (+ 8) % Row 3 \SetRowColor{white} \textless{}conditional\_expr\textgreater{} & \textless{}or\_test\textgreater{} {[} "if" \textless{}or\_test\textgreater{} "else" \textless{}expression\textgreater{} & \tn % Row Count 16 (+ 3) % Row 4 \SetRowColor{LightBackground} \textless{}expression\textgreater{} & \textless{}conditional\_expr\textgreater{} | \textless{}lambda\textgreater{} & \tn % Row Count 18 (+ 2) % Row 5 \SetRowColor{white} \textless{}lambda\textgreater{} & python lambda expression & \tn % Row Count 20 (+ 2) % Row 6 \SetRowColor{LightBackground} \textless{}or\_test\textgreater{} & boolean expression using "or", "and", "not" and comparisons & \tn % Row Count 24 (+ 4) % Row 7 \SetRowColor{white} \textless{}or\_expr\textgreater{} & bitwise logical and shift expression using "|", "\&", "\textasciicircum{}", "\textless{}\textless{}" and "\textgreater{}\textgreater{}" & \tn % Row Count 29 (+ 5) % Row 8 \SetRowColor{LightBackground} \textless{}conversion\textgreater{} & "s" & converted to string via str() \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.368 cm} x{3.116 cm} x{3.116 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{\textless{}field\textgreater{} (cont)}} \tn % Row 9 \SetRowColor{LightBackground} & "r" & converted to string via repr() \tn % Row Count 2 (+ 2) % Row 10 \SetRowColor{white} & "a" & converted to string via ascii() \tn % Row Count 4 (+ 2) % Row 11 \SetRowColor{LightBackground} \textless{}format\textgreater{} & ( \textless{}literal\textgreater{} | NULL | \textless{}field\textgreater{} ) * & format specifier compatible to str.format() method (see format specification mini-language below) \tn % Row Count 11 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.292 cm} x{3.116 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Format Specification Mini-Language}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}format\_spec\textgreater{} & {[}{[}\textless{}fill\textgreater{}{]}\textless{}align\textgreater{}{]} {[}\textless{}sign\textgreater{}{]}{[}\#{]}{[}0{]}{[}\textless{}width\textgreater{}{]}{[}\textless{}grouping\textgreater{}{]}{[}.\textless{}precision\textgreater{}{]}{[}\textless{}type\textgreater{}{]} & \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \textless{}fill\textgreater{} & \textless{}any character\textgreater{} & fill in the empty space in an aligned value \tn % Row Count 8 (+ 3) % Row 2 \SetRowColor{LightBackground} \textless{}align\textgreater{} & "\textless{}" & left-aliogn \tn % Row Count 10 (+ 2) % Row 3 \SetRowColor{white} & "\textgreater{}" & right-align \tn % Row Count 11 (+ 1) % Row 4 \SetRowColor{LightBackground} & "=" & numeric pĆ¼adding takes place after the sign (like = padding) \tn % Row Count 15 (+ 4) % Row 5 \SetRowColor{white} & "\textasciicircum{}" & center \tn % Row Count 16 (+ 1) % Row 6 \SetRowColor{LightBackground} \textless{}sign\textgreater{} & "+" & show sign for both positive and negative numbers \tn % Row Count 19 (+ 3) % Row 7 \SetRowColor{white} & "-" & show sign for negative nuimbers only (default) \tn % Row Count 22 (+ 3) % Row 8 \SetRowColor{LightBackground} & \textless{}space\textgreater{} & show space for positive and '-' for negative numbers \tn % Row Count 26 (+ 4) % Row 9 \SetRowColor{white} "\#" & alternative form & (see section below) \tn % Row Count 28 (+ 2) % Row 10 \SetRowColor{LightBackground} "0" & "0" in front of the \textless{}width\textgreater{} field if no alignment is specified is wual to "0=" fill and align character combination & number padded by 0 between sign and digits \tn % Row Count 36 (+ 8) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.292 cm} x{3.116 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Format Specification Mini-Language (cont)}} \tn % Row 11 \SetRowColor{LightBackground} \textless{}width\textgreater{} & minimal field width & \tn % Row Count 2 (+ 2) % Row 12 \SetRowColor{white} \textless{}grouping\textgreater{} & "," & use comma for 1000 separator (V3.1+) \tn % Row Count 5 (+ 3) % Row 13 \SetRowColor{LightBackground} & "\_" & use "\_" (underscore) for 1000 separator (V3.6+) \tn % Row Count 8 (+ 3) % Row 14 \SetRowColor{white} \textless{}precision\textgreater{} & number of digits after the decimal point & \tn % Row Count 11 (+ 3) % Row 15 \SetRowColor{LightBackground} \textless{}type\textgreater{} \seqsplit{(integer)} & "b" & binary in base-2 \tn % Row Count 14 (+ 3) % Row 16 \SetRowColor{white} & "c" & character \tn % Row Count 15 (+ 1) % Row 17 \SetRowColor{LightBackground} & "d" & decimal integer \tn % Row Count 16 (+ 1) % Row 18 \SetRowColor{white} & "o" & octal integer (base-8) \tn % Row Count 18 (+ 2) % Row 19 \SetRowColor{LightBackground} & "x" & hex format (base 16) using lowercase letters \tn % Row Count 21 (+ 3) % Row 20 \SetRowColor{white} & "X" & hex format (base 16) using uppercase letters \tn % Row Count 24 (+ 3) % Row 21 \SetRowColor{LightBackground} & "n" & integer number (like "d"), using current locale for number separators \tn % Row Count 29 (+ 5) % Row 22 \SetRowColor{white} & None & same as "d" \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.292 cm} x{3.116 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Format Specification Mini-Language (cont)}} \tn % Row 23 \SetRowColor{LightBackground} \textless{}type\textgreater{} \seqsplit{(float)} & "e" & Exponent (scientific) notation using lowercase "e". Default precision is 6 \tn % Row Count 5 (+ 5) % Row 24 \SetRowColor{white} & "E" & Exponent (scientific) notation using uppercase "E". Default precision is 6 \tn % Row Count 10 (+ 5) % Row 25 \SetRowColor{LightBackground} & "f" & fixed-point notation with default precision of 6 \tn % Row Count 13 (+ 3) % Row 26 \SetRowColor{white} & "F" & Same as "f" but "nan" and "inf" are displayed as "NAN" and "INF" \tn % Row Count 17 (+ 4) % Row 27 \SetRowColor{LightBackground} & "g" & general format with rounded result at given precision digit \tn % Row Count 21 (+ 4) % Row 28 \SetRowColor{white} & "G" & same as "g" except that uppercase "E", "NAN" and "INF" are displayed \tn % Row Count 26 (+ 5) % Row 29 \SetRowColor{LightBackground} & "n" & same as "g" except that it uses current locale for number separator characters \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{1.292 cm} x{3.116 cm} x{3.192 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Format Specification Mini-Language (cont)}} \tn % Row 30 \SetRowColor{LightBackground} & "\%" & precentage, multiplies number by 100, displays it in fixed format (like "f") and appends "\%" \tn % Row Count 6 (+ 6) % Row 31 \SetRowColor{white} & None & similar to "g" buit has at least 1 digit past the decimal point \tn % Row Count 10 (+ 4) % Row 32 \SetRowColor{LightBackground} \textless{}type\textgreater{} \seqsplit{(stzring)} & "s" & string \tn % Row Count 13 (+ 3) % Row 33 \SetRowColor{white} & None & same as "s" \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.72 cm} x{5.28 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Alternative forms (\#)}} \tn % Row 0 \SetRowColor{LightBackground} for octal & "0o" preceeds octal number \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} for hexadecimal & "0x" preceeds hexadecimal number \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} floating point & always contain decimal point even if no digit follows \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} if precision is given & output truncated to precision \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}