diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-25 17:10:49 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-25 17:10:49 +0200 |
| commit | d6c61d988bfa4255baf9cdae42db59ebee38363f (patch) | |
| tree | 118ff3c2424e735149c145524965a4a337e50beb /src/Lecture6/notebook/9-SageLatex.tex | |
| parent | 46eef66b1e1571c77dc828d7e950b129b4c8bfd0 (diff) | |
| download | mathsoftware-d6c61d988bfa4255baf9cdae42db59ebee38363f.tar.gz mathsoftware-d6c61d988bfa4255baf9cdae42db59ebee38363f.zip | |
Added files
Diffstat (limited to 'src/Lecture6/notebook/9-SageLatex.tex')
| -rw-r--r-- | src/Lecture6/notebook/9-SageLatex.tex | 634 |
1 files changed, 634 insertions, 0 deletions
diff --git a/src/Lecture6/notebook/9-SageLatex.tex b/src/Lecture6/notebook/9-SageLatex.tex new file mode 100644 index 0000000..ad59b25 --- /dev/null +++ b/src/Lecture6/notebook/9-SageLatex.tex | |||
| @@ -0,0 +1,634 @@ | |||
| 1 | \documentclass[11pt]{article} | ||
| 2 | |||
| 3 | \usepackage[breakable]{tcolorbox} | ||
| 4 | \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour) | ||
| 5 | |||
| 6 | \usepackage{iftex} | ||
| 7 | \ifPDFTeX | ||
| 8 | \usepackage[T1]{fontenc} | ||
| 9 | \usepackage{mathpazo} | ||
| 10 | \else | ||
| 11 | \usepackage{fontspec} | ||
| 12 | \fi | ||
| 13 | |||
| 14 | % Basic figure setup, for now with no caption control since it's done | ||
| 15 | % automatically by Pandoc (which extracts  syntax from Markdown). | ||
| 16 | \usepackage{graphicx} | ||
| 17 | % Maintain compatibility with old templates. Remove in nbconvert 6.0 | ||
| 18 | \let\Oldincludegraphics\includegraphics | ||
| 19 | % Ensure that by default, figures have no caption (until we provide a | ||
| 20 | % proper Figure object with a Caption API and a way to capture that | ||
| 21 | % in the conversion process - todo). | ||
| 22 | \usepackage{caption} | ||
| 23 | \DeclareCaptionFormat{nocaption}{} | ||
| 24 | \captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt} | ||
| 25 | |||
| 26 | \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size | ||
| 27 | \adjustboxset{max size={0.9\linewidth}{0.9\paperheight}} | ||
| 28 | \usepackage{float} | ||
| 29 | \floatplacement{figure}{H} % forces figures to be placed at the correct location | ||
| 30 | \usepackage{xcolor} % Allow colors to be defined | ||
| 31 | \usepackage{enumerate} % Needed for markdown enumerations to work | ||
| 32 | \usepackage{geometry} % Used to adjust the document margins | ||
| 33 | \usepackage{amsmath} % Equations | ||
| 34 | \usepackage{amssymb} % Equations | ||
| 35 | \usepackage{textcomp} % defines textquotesingle | ||
| 36 | % Hack from http://tex.stackexchange.com/a/47451/13684: | ||
| 37 | \AtBeginDocument{% | ||
| 38 | \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code | ||
| 39 | } | ||
| 40 | \usepackage{upquote} % Upright quotes for verbatim code | ||
| 41 | \usepackage{eurosym} % defines \euro | ||
| 42 | \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support | ||
| 43 | \usepackage{fancyvrb} % verbatim replacement that allows latex | ||
| 44 | \usepackage{grffile} % extends the file name processing of package graphics | ||
| 45 | % to support a larger range | ||
| 46 | \makeatletter % fix for grffile with XeLaTeX | ||
| 47 | \def\Gread@@xetex#1{% | ||
| 48 | \IfFileExists{"\Gin@base".bb}% | ||
| 49 | {\Gread@eps{\Gin@base.bb}}% | ||
| 50 | {\Gread@@xetex@aux#1}% | ||
| 51 | } | ||
| 52 | \makeatother | ||
| 53 | |||
| 54 | % The hyperref package gives us a pdf with properly built | ||
| 55 | % internal navigation ('pdf bookmarks' for the table of contents, | ||
| 56 | % internal cross-reference links, web links for URLs, etc.) | ||
| 57 | \usepackage{hyperref} | ||
| 58 | % The default LaTeX title has an obnoxious amount of whitespace. By default, | ||
| 59 | % titling removes some of it. It also provides customization options. | ||
| 60 | \usepackage{titling} | ||
| 61 | \usepackage{longtable} % longtable support required by pandoc >1.10 | ||
| 62 | \usepackage{booktabs} % table support for pandoc > 1.12.2 | ||
| 63 | \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment) | ||
| 64 | \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout) | ||
| 65 | % normalem makes italics be italics, not underlines | ||
| 66 | \usepackage{mathrsfs} | ||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | % Colors for the hyperref package | ||
| 71 | \definecolor{urlcolor}{rgb}{0,.145,.698} | ||
| 72 | \definecolor{linkcolor}{rgb}{.71,0.21,0.01} | ||
| 73 | \definecolor{citecolor}{rgb}{.12,.54,.11} | ||
| 74 | |||
| 75 | % ANSI colors | ||
| 76 | \definecolor{ansi-black}{HTML}{3E424D} | ||
| 77 | \definecolor{ansi-black-intense}{HTML}{282C36} | ||
| 78 | \definecolor{ansi-red}{HTML}{E75C58} | ||
| 79 | \definecolor{ansi-red-intense}{HTML}{B22B31} | ||
| 80 | \definecolor{ansi-green}{HTML}{00A250} | ||
| 81 | \definecolor{ansi-green-intense}{HTML}{007427} | ||
| 82 | \definecolor{ansi-yellow}{HTML}{DDB62B} | ||
| 83 | \definecolor{ansi-yellow-intense}{HTML}{B27D12} | ||
| 84 | \definecolor{ansi-blue}{HTML}{208FFB} | ||
| 85 | \definecolor{ansi-blue-intense}{HTML}{0065CA} | ||
| 86 | \definecolor{ansi-magenta}{HTML}{D160C4} | ||
| 87 | \definecolor{ansi-magenta-intense}{HTML}{A03196} | ||
| 88 | \definecolor{ansi-cyan}{HTML}{60C6C8} | ||
| 89 | \definecolor{ansi-cyan-intense}{HTML}{258F8F} | ||
| 90 | \definecolor{ansi-white}{HTML}{C5C1B4} | ||
| 91 | \definecolor{ansi-white-intense}{HTML}{A1A6B2} | ||
| 92 | \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF} | ||
| 93 | \definecolor{ansi-default-inverse-bg}{HTML}{000000} | ||
| 94 | |||
| 95 | % commands and environments needed by pandoc snippets | ||
| 96 | % extracted from the output of `pandoc -s` | ||
| 97 | \providecommand{\tightlist}{% | ||
| 98 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} | ||
| 99 | \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} | ||
| 100 | % Add ',fontsize=\small' for more characters per line | ||
| 101 | \newenvironment{Shaded}{}{} | ||
| 102 | \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | ||
| 103 | \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} | ||
| 104 | \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | ||
| 105 | \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | ||
| 106 | \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | ||
| 107 | \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | ||
| 108 | \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | ||
| 109 | \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} | ||
| 110 | \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} | ||
| 111 | \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | ||
| 112 | \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} | ||
| 113 | \newcommand{\RegionMarkerTok}[1]{{#1}} | ||
| 114 | \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | ||
| 115 | \newcommand{\NormalTok}[1]{{#1}} | ||
| 116 | |||
| 117 | % Additional commands for more recent versions of Pandoc | ||
| 118 | \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}} | ||
| 119 | \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | ||
| 120 | \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | ||
| 121 | \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}} | ||
| 122 | \newcommand{\ImportTok}[1]{{#1}} | ||
| 123 | \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}} | ||
| 124 | \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | ||
| 125 | \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | ||
| 126 | \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}} | ||
| 127 | \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | ||
| 128 | \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}} | ||
| 129 | \newcommand{\BuiltInTok}[1]{{#1}} | ||
| 130 | \newcommand{\ExtensionTok}[1]{{#1}} | ||
| 131 | \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}} | ||
| 132 | \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}} | ||
| 133 | \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | ||
| 134 | \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | ||
| 135 | |||
| 136 | |||
| 137 | % Define a nice break command that doesn't care if a line doesn't already | ||
| 138 | % exist. | ||
| 139 | \def\br{\hspace*{\fill} \\* } | ||
| 140 | % Math Jax compatibility definitions | ||
| 141 | \def\gt{>} | ||
| 142 | \def\lt{<} | ||
| 143 | \let\Oldtex\TeX | ||
| 144 | \let\Oldlatex\LaTeX | ||
| 145 | \renewcommand{\TeX}{\textrm{\Oldtex}} | ||
| 146 | \renewcommand{\LaTeX}{\textrm{\Oldlatex}} | ||
| 147 | % Document parameters | ||
| 148 | % Document title | ||
| 149 | \title{Sage and Latex interaction} | ||
| 150 | \author{Sebastiano Tronto - \texttt{sebastiano.tronto@uni.lu}} | ||
| 151 | \date{2021-05-07} | ||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | % Pygments definitions | ||
| 158 | \makeatletter | ||
| 159 | \def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax% | ||
| 160 | \let\PY@ul=\relax \let\PY@tc=\relax% | ||
| 161 | \let\PY@bc=\relax \let\PY@ff=\relax} | ||
| 162 | \def\PY@tok#1{\csname PY@tok@#1\endcsname} | ||
| 163 | \def\PY@toks#1+{\ifx\relax#1\empty\else% | ||
| 164 | \PY@tok{#1}\expandafter\PY@toks\fi} | ||
| 165 | \def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{% | ||
| 166 | \PY@it{\PY@bf{\PY@ff{#1}}}}}}} | ||
| 167 | \def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}} | ||
| 168 | |||
| 169 | \expandafter\def\csname PY@tok@w\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}} | ||
| 170 | \expandafter\def\csname PY@tok@c\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | ||
| 171 | \expandafter\def\csname PY@tok@cp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}} | ||
| 172 | \expandafter\def\csname PY@tok@k\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 173 | \expandafter\def\csname PY@tok@kp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 174 | \expandafter\def\csname PY@tok@kt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}} | ||
| 175 | \expandafter\def\csname PY@tok@o\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 176 | \expandafter\def\csname PY@tok@ow\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} | ||
| 177 | \expandafter\def\csname PY@tok@nb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 178 | \expandafter\def\csname PY@tok@nf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | ||
| 179 | \expandafter\def\csname PY@tok@nc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | ||
| 180 | \expandafter\def\csname PY@tok@nn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | ||
| 181 | \expandafter\def\csname PY@tok@ne\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}} | ||
| 182 | \expandafter\def\csname PY@tok@nv\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | ||
| 183 | \expandafter\def\csname PY@tok@no\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}} | ||
| 184 | \expandafter\def\csname PY@tok@nl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}} | ||
| 185 | \expandafter\def\csname PY@tok@ni\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}} | ||
| 186 | \expandafter\def\csname PY@tok@na\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}} | ||
| 187 | \expandafter\def\csname PY@tok@nt\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 188 | \expandafter\def\csname PY@tok@nd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} | ||
| 189 | \expandafter\def\csname PY@tok@s\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 190 | \expandafter\def\csname PY@tok@sd\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 191 | \expandafter\def\csname PY@tok@si\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}} | ||
| 192 | \expandafter\def\csname PY@tok@se\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}} | ||
| 193 | \expandafter\def\csname PY@tok@sr\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}} | ||
| 194 | \expandafter\def\csname PY@tok@ss\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | ||
| 195 | \expandafter\def\csname PY@tok@sx\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 196 | \expandafter\def\csname PY@tok@m\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 197 | \expandafter\def\csname PY@tok@gh\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} | ||
| 198 | \expandafter\def\csname PY@tok@gu\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}} | ||
| 199 | \expandafter\def\csname PY@tok@gd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}} | ||
| 200 | \expandafter\def\csname PY@tok@gi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}} | ||
| 201 | \expandafter\def\csname PY@tok@gr\endcsname{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}} | ||
| 202 | \expandafter\def\csname PY@tok@ge\endcsname{\let\PY@it=\textit} | ||
| 203 | \expandafter\def\csname PY@tok@gs\endcsname{\let\PY@bf=\textbf} | ||
| 204 | \expandafter\def\csname PY@tok@gp\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} | ||
| 205 | \expandafter\def\csname PY@tok@go\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} | ||
| 206 | \expandafter\def\csname PY@tok@gt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}} | ||
| 207 | \expandafter\def\csname PY@tok@err\endcsname{\def\PY@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}} | ||
| 208 | \expandafter\def\csname PY@tok@kc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 209 | \expandafter\def\csname PY@tok@kd\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 210 | \expandafter\def\csname PY@tok@kn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 211 | \expandafter\def\csname PY@tok@kr\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 212 | \expandafter\def\csname PY@tok@bp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} | ||
| 213 | \expandafter\def\csname PY@tok@fm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} | ||
| 214 | \expandafter\def\csname PY@tok@vc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | ||
| 215 | \expandafter\def\csname PY@tok@vg\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | ||
| 216 | \expandafter\def\csname PY@tok@vi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | ||
| 217 | \expandafter\def\csname PY@tok@vm\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} | ||
| 218 | \expandafter\def\csname PY@tok@sa\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 219 | \expandafter\def\csname PY@tok@sb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 220 | \expandafter\def\csname PY@tok@sc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 221 | \expandafter\def\csname PY@tok@dl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 222 | \expandafter\def\csname PY@tok@s2\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 223 | \expandafter\def\csname PY@tok@sh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 224 | \expandafter\def\csname PY@tok@s1\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} | ||
| 225 | \expandafter\def\csname PY@tok@mb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 226 | \expandafter\def\csname PY@tok@mf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 227 | \expandafter\def\csname PY@tok@mh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 228 | \expandafter\def\csname PY@tok@mi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 229 | \expandafter\def\csname PY@tok@il\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 230 | \expandafter\def\csname PY@tok@mo\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} | ||
| 231 | \expandafter\def\csname PY@tok@ch\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | ||
| 232 | \expandafter\def\csname PY@tok@cm\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | ||
| 233 | \expandafter\def\csname PY@tok@cpf\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | ||
| 234 | \expandafter\def\csname PY@tok@c1\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | ||
| 235 | \expandafter\def\csname PY@tok@cs\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} | ||
| 236 | |||
| 237 | \def\PYZbs{\char`\\} | ||
| 238 | \def\PYZus{\char`\_} | ||
| 239 | \def\PYZob{\char`\{} | ||
| 240 | \def\PYZcb{\char`\}} | ||
| 241 | \def\PYZca{\char`\^} | ||
| 242 | \def\PYZam{\char`\&} | ||
| 243 | \def\PYZlt{\char`\<} | ||
| 244 | \def\PYZgt{\char`\>} | ||
| 245 | \def\PYZsh{\char`\#} | ||
| 246 | \def\PYZpc{\char`\%} | ||
| 247 | \def\PYZdl{\char`\$} | ||
| 248 | \def\PYZhy{\char`\-} | ||
| 249 | \def\PYZsq{\char`\'} | ||
| 250 | \def\PYZdq{\char`\"} | ||
| 251 | \def\PYZti{\char`\~} | ||
| 252 | % for compatibility with earlier versions | ||
| 253 | \def\PYZat{@} | ||
| 254 | \def\PYZlb{[} | ||
| 255 | \def\PYZrb{]} | ||
| 256 | \makeatother | ||
| 257 | |||
| 258 | |||
| 259 | % For linebreaks inside Verbatim environment from package fancyvrb. | ||
| 260 | \makeatletter | ||
| 261 | \newbox\Wrappedcontinuationbox | ||
| 262 | \newbox\Wrappedvisiblespacebox | ||
| 263 | \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}} | ||
| 264 | \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}} | ||
| 265 | \newcommand*\Wrappedcontinuationindent {3ex } | ||
| 266 | \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox} | ||
| 267 | % Take advantage of the already applied Pygments mark-up to insert | ||
| 268 | % potential linebreaks for TeX processing. | ||
| 269 | % {, <, #, %, $, ' and ": go to next line. | ||
| 270 | % _, }, ^, &, >, - and ~: stay at end of broken line. | ||
| 271 | % Use of \textquotesingle for straight quote. | ||
| 272 | \newcommand*\Wrappedbreaksatspecials {% | ||
| 273 | \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}% | ||
| 274 | \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}% | ||
| 275 | \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}% | ||
| 276 | \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}% | ||
| 277 | \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}% | ||
| 278 | \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}% | ||
| 279 | \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}% | ||
| 280 | \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}% | ||
| 281 | \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}% | ||
| 282 | \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}% | ||
| 283 | \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}% | ||
| 284 | \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}% | ||
| 285 | \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}% | ||
| 286 | \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}% | ||
| 287 | } | ||
| 288 | % Some characters . , ; ? ! / are not pygmentized. | ||
| 289 | % This macro makes them "active" and they will insert potential linebreaks | ||
| 290 | \newcommand*\Wrappedbreaksatpunct {% | ||
| 291 | \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}% | ||
| 292 | \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}% | ||
| 293 | \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}% | ||
| 294 | \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}% | ||
| 295 | \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}% | ||
| 296 | \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}% | ||
| 297 | \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}% | ||
| 298 | \catcode`\.\active | ||
| 299 | \catcode`\,\active | ||
| 300 | \catcode`\;\active | ||
| 301 | \catcode`\:\active | ||
| 302 | \catcode`\?\active | ||
| 303 | \catcode`\!\active | ||
| 304 | \catcode`\/\active | ||
| 305 | \lccode`\~`\~ | ||
| 306 | } | ||
| 307 | \makeatother | ||
| 308 | |||
| 309 | \let\OriginalVerbatim=\Verbatim | ||
| 310 | \makeatletter | ||
| 311 | \renewcommand{\Verbatim}[1][1]{% | ||
| 312 | %\parskip\z@skip | ||
| 313 | \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}% | ||
| 314 | \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}% | ||
| 315 | \def\FancyVerbFormatLine ##1{\hsize\linewidth | ||
| 316 | \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@ | ||
| 317 | \doublehyphendemerits\z@\finalhyphendemerits\z@ | ||
| 318 | \strut ##1\strut}% | ||
| 319 | }% | ||
| 320 | % If the linebreak is at a space, the latter will be displayed as visible | ||
| 321 | % space at end of first line, and a continuation symbol starts next line. | ||
| 322 | % Stretch/shrink are however usually zero for typewriter font. | ||
| 323 | \def\FV@Space {% | ||
| 324 | \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font | ||
| 325 | \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak} | ||
| 326 | {\kern\fontdimen2\font}% | ||
| 327 | }% | ||
| 328 | |||
| 329 | % Allow breaks at special characters using \PYG... macros. | ||
| 330 | \Wrappedbreaksatspecials | ||
| 331 | % Breaks at punctuation characters . , ; ? ! and / need catcode=\active | ||
| 332 | \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]% | ||
| 333 | } | ||
| 334 | \makeatother | ||
| 335 | |||
| 336 | % Exact colors from NB | ||
| 337 | \definecolor{incolor}{HTML}{303F9F} | ||
| 338 | \definecolor{outcolor}{HTML}{D84315} | ||
| 339 | \definecolor{cellborder}{HTML}{CFCFCF} | ||
| 340 | \definecolor{cellbackground}{HTML}{F7F7F7} | ||
| 341 | |||
| 342 | % prompt | ||
| 343 | \makeatletter | ||
| 344 | \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep} | ||
| 345 | \makeatother | ||
| 346 | \newcommand{\prompt}[4]{ | ||
| 347 | \ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip} | ||
| 348 | } | ||
| 349 | |||
| 350 | |||
| 351 | |||
| 352 | % Prevent overflowing lines due to hard-to-break entities | ||
| 353 | \sloppy | ||
| 354 | % Setup hyperref package | ||
| 355 | \hypersetup{ | ||
| 356 | breaklinks=true, % so long urls are correctly broken across lines | ||
| 357 | colorlinks=true, | ||
| 358 | urlcolor=urlcolor, | ||
| 359 | linkcolor=linkcolor, | ||
| 360 | citecolor=citecolor, | ||
| 361 | } | ||
| 362 | % Slightly bigger margins than the latex defaults | ||
| 363 | |||
| 364 | \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} | ||
| 365 | |||
| 366 | |||
| 367 | |||
| 368 | \begin{document} | ||
| 369 | |||
| 370 | \maketitle | ||
| 371 | |||
| 372 | |||
| 373 | |||
| 374 | |||
| 375 | It can happen that you need to include the results of your Sage | ||
| 376 | computations and/or Sage code inside a LaTeX document. Luckily Sage | ||
| 377 | provides some functions to translate its objects into LaTeX, and the | ||
| 378 | listings package for LaTeX can be used to include any code (Sage, Python | ||
| 379 | or any other language) in a LaTeX document. | ||
| 380 | |||
| 381 | In this document we will describe some of these interactions between | ||
| 382 | LaTeX and Sage. | ||
| 383 | |||
| 384 | \hypertarget{the-show-command}{% | ||
| 385 | \section{\texorpdfstring{The \texttt{show()} | ||
| 386 | command}{The show() command}}\label{the-show-command}} | ||
| 387 | |||
| 388 | \textbf{Reference:} | ||
| 389 | {[}\href{https://doc.sagemath.org/html/en/reference/repl/sage/repl/display/pretty_print.html}{1}{]} | ||
| 390 | (\texttt{show()} is just an alternative name for | ||
| 391 | \texttt{pretty\_print()}). | ||
| 392 | |||
| 393 | With this command Sage will generate a picture displaying the object. | ||
| 394 | The result depends on the object itself: most of them will be typeset in | ||
| 395 | Latex, but for example graphics primitives (such as plots) will be | ||
| 396 | displayed as pictures. | ||
| 397 | |||
| 398 | You can see it as an alternative to \texttt{print()}. | ||
| 399 | |||
| 400 | \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] | ||
| 401 | \prompt{In}{incolor}{4}{\boxspacing} | ||
| 402 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 403 | \PY{n}{s} \PY{o}{=} \PY{p}{(}\PY{n}{e}\PY{o}{\PYZca{}}\PY{n}{x}\PY{p}{)}\PY{o}{.}\PY{n}{series}\PY{p}{(}\PY{n}{x}\PY{o}{==}\PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{4}\PY{p}{)} | ||
| 404 | \PY{n}{M} \PY{o}{=} \PY{n}{matrix}\PY{p}{(}\PY{p}{[}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{,}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{,}\PY{p}{[}\PY{l+m+mi}{4}\PY{p}{,}\PY{l+m+mi}{5}\PY{p}{,}\PY{l+m+mi}{6}\PY{p}{]}\PY{p}{,}\PY{p}{[}\PY{l+m+mi}{8}\PY{p}{,}\PY{l+m+mi}{9}\PY{p}{,}\PY{l+m+mi}{10}\PY{p}{]}\PY{p}{]}\PY{p}{)} | ||
| 405 | \PY{n+nb}{print}\PY{p}{(}\PY{n}{s}\PY{p}{)} | ||
| 406 | \PY{n}{show}\PY{p}{(}\PY{n}{s}\PY{p}{)} | ||
| 407 | \PY{n+nb}{print}\PY{p}{(}\PY{n}{M}\PY{p}{)} | ||
| 408 | \PY{n}{show}\PY{p}{(}\PY{n}{M}\PY{p}{)} | ||
| 409 | \PY{n+nb}{print}\PY{p}{(}\PY{n}{pi}\PY{p}{)} | ||
| 410 | \PY{n}{show}\PY{p}{(}\PY{n}{pi}\PY{p}{)} | ||
| 411 | \end{Verbatim} | ||
| 412 | \end{tcolorbox} | ||
| 413 | |||
| 414 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 415 | 1 + 1*x + 1/2*x\^{}2 + 1/6*x\^{}3 + Order(x\^{}4) | ||
| 416 | \end{Verbatim} | ||
| 417 | |||
| 418 | \begin{math} | ||
| 419 | \newcommand{\Bold}[1]{\mathbf{#1}}1 + 1 x + \frac{1}{2} x^{2} + \frac{1}{6} x^{3} + \mathcal{O}\left(x^{4}\right) | ||
| 420 | \end{math} | ||
| 421 | |||
| 422 | |||
| 423 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 424 | [ 1 2 3] | ||
| 425 | [ 4 5 6] | ||
| 426 | [ 8 9 10] | ||
| 427 | \end{Verbatim} | ||
| 428 | |||
| 429 | \begin{math} | ||
| 430 | \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} | ||
| 431 | 1 & 2 & 3 \\ | ||
| 432 | 4 & 5 & 6 \\ | ||
| 433 | 8 & 9 & 10 | ||
| 434 | \end{array}\right) | ||
| 435 | \end{math} | ||
| 436 | |||
| 437 | |||
| 438 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 439 | pi | ||
| 440 | \end{Verbatim} | ||
| 441 | |||
| 442 | \begin{math} | ||
| 443 | \newcommand{\Bold}[1]{\mathbf{#1}}\pi | ||
| 444 | \end{math} | ||
| 445 | |||
| 446 | |||
| 447 | In a Jupyter notebook, the results above are displayed using | ||
| 448 | \href{https://www.mathjax.org/}{MathJax}. | ||
| 449 | |||
| 450 | If you are running this code in an interactive console (terminal) | ||
| 451 | instead of a Jupyter notebook, you will get the Latex source code for | ||
| 452 | those objects. You can force this behavior by using the \texttt{latex()} | ||
| 453 | command. | ||
| 454 | |||
| 455 | \hypertarget{the-latex-command}{% | ||
| 456 | \section{\texorpdfstring{The \texttt{latex()} | ||
| 457 | command}{The latex() command}}\label{the-latex-command}} | ||
| 458 | |||
| 459 | \textbf{Reference:} | ||
| 460 | {[}\href{https://doc.sagemath.org/html/en/reference/misc/sage/misc/latex.html}{2}{]} | ||
| 461 | |||
| 462 | This command is potentially very useful if you need to include the | ||
| 463 | results of Sage computations in a Latex file, especially with complex | ||
| 464 | objects like matrices or very large polynomials. | ||
| 465 | |||
| 466 | Technically, this is a function that returns a string, so you need to | ||
| 467 | \texttt{print()} it to see the result. | ||
| 468 | |||
| 469 | \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] | ||
| 470 | \prompt{In}{incolor}{5}{\boxspacing} | ||
| 471 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 472 | \PY{n+nb}{print}\PY{p}{(}\PY{n}{latex}\PY{p}{(}\PY{n}{s}\PY{p}{)}\PY{p}{)} | ||
| 473 | \PY{n+nb}{print}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+se}{\PYZbs{}n}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)} | ||
| 474 | \PY{n+nb}{print}\PY{p}{(}\PY{n}{latex}\PY{p}{(}\PY{n}{M}\PY{p}{)}\PY{p}{)} | ||
| 475 | \end{Verbatim} | ||
| 476 | \end{tcolorbox} | ||
| 477 | |||
| 478 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 479 | 1 + 1 x + \textbackslash{}frac\{1\}\{2\} x\^{}\{2\} + \textbackslash{}frac\{1\}\{6\} x\^{}\{3\} + \textbackslash{}mathcal\{O\}\textbackslash{}left(x\^{}\{4\}\textbackslash{}right) | ||
| 480 | |||
| 481 | |||
| 482 | \textbackslash{}left(\textbackslash{}begin\{array\}\{rrr\} | ||
| 483 | 1 \& 2 \& 3 \textbackslash{}\textbackslash{} | ||
| 484 | 4 \& 5 \& 6 \textbackslash{}\textbackslash{} | ||
| 485 | 8 \& 9 \& 10 | ||
| 486 | \textbackslash{}end\{array\}\textbackslash{}right) | ||
| 487 | \end{Verbatim} | ||
| 488 | |||
| 489 | Interestingly, Sage can use matplotlib's PGF backend to generate Latex | ||
| 490 | code for a plot. (PGF is the graphics language underlying TikZ, like TeX | ||
| 491 | is the language underlying Latex). | ||
| 492 | |||
| 493 | \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] | ||
| 494 | \prompt{In}{incolor}{15}{\boxspacing} | ||
| 495 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 496 | \PY{c+c1}{\PYZsh{}latex(plot(x\PYZca{}2)) \PYZsh{} The output is more than 20 pages long} | ||
| 497 | \end{Verbatim} | ||
| 498 | \end{tcolorbox} | ||
| 499 | |||
| 500 | It is probably easier to just generate the picture and include that in | ||
| 501 | your Latex document with \texttt{\textbackslash{}includegraphics}. | ||
| 502 | |||
| 503 | \hypertarget{a-latex-name-for-your-variables}{% | ||
| 504 | \subsection{A Latex name for your | ||
| 505 | variables}\label{a-latex-name-for-your-variables}} | ||
| 506 | |||
| 507 | \textbf{Reference:} | ||
| 508 | {[}\href{https://doc.sagemath.org/html/en/reference/calculus/sage/calculus/var.html}{3}{]} | ||
| 509 | |||
| 510 | Sometimes you might want to use variables and functions that have, for | ||
| 511 | example, a Greek letter as a name. You can tell Sage that you want them | ||
| 512 | displayed this way when you declare them: | ||
| 513 | |||
| 514 | \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] | ||
| 515 | \prompt{In}{incolor}{16}{\boxspacing} | ||
| 516 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 517 | \PY{n}{var}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{epsilon}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{latex\PYZus{}name}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+se}{\PYZbs{}\PYZbs{}}\PY{l+s+s2}{varepsilon}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)} | ||
| 518 | \PY{n}{function}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{phi1}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{n}{latex\PYZus{}name}\PY{o}{=}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+se}{\PYZbs{}\PYZbs{}}\PY{l+s+s2}{phi\PYZus{}1}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)} | ||
| 519 | |||
| 520 | \PY{n+nb}{print}\PY{p}{(}\PY{n}{phi1}\PY{p}{(}\PY{n}{epsilon}\PY{p}{)}\PY{p}{)} | ||
| 521 | \PY{n}{show}\PY{p}{(}\PY{n}{phi1}\PY{p}{(}\PY{n}{epsilon}\PY{p}{)} \PY{o}{+} \PY{n}{e}\PY{o}{\PYZca{}}\PY{n}{epsilon}\PY{p}{)} | ||
| 522 | \PY{n}{latex}\PY{p}{(}\PY{n}{phi1}\PY{p}{(}\PY{n}{epsilon}\PY{p}{)} \PY{o}{+} \PY{n}{e}\PY{o}{\PYZca{}}\PY{n}{epsilon}\PY{p}{)} | ||
| 523 | \end{Verbatim} | ||
| 524 | \end{tcolorbox} | ||
| 525 | |||
| 526 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 527 | phi1(epsilon) | ||
| 528 | \end{Verbatim} | ||
| 529 | |||
| 530 | \begin{math} | ||
| 531 | \newcommand{\Bold}[1]{\mathbf{#1}}e^{{\varepsilon}} + \phi_1\left({\varepsilon}\right) | ||
| 532 | \end{math} | ||
| 533 | |||
| 534 | |||
| 535 | \begin{tcolorbox}[breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0] | ||
| 536 | \prompt{Out}{outcolor}{16}{\boxspacing} | ||
| 537 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 538 | e\^{}\{\{\textbackslash{}varepsilon\}\} + \textbackslash{}phi\_1\textbackslash{}left(\{\textbackslash{}varepsilon\}\textbackslash{}right) | ||
| 539 | \end{Verbatim} | ||
| 540 | \end{tcolorbox} | ||
| 541 | |||
| 542 | \textbf{Warning:} You need to use two backspaces | ||
| 543 | \texttt{\textbackslash{}\textbackslash{}}. The reason is that in Python | ||
| 544 | (like in many other programming languages) the backslash symbol inside a | ||
| 545 | string is used to print special characters, such as a newline | ||
| 546 | \texttt{\textbackslash{}n}. | ||
| 547 | |||
| 548 | \hypertarget{from-jupyter-to-latex}{% | ||
| 549 | \section{From Jupyter to Latex}\label{from-jupyter-to-latex}} | ||
| 550 | |||
| 551 | \textbf{Reference:} | ||
| 552 | {[}\href{https://nbconvert.readthedocs.io/en/latest/}{4}{]} | ||
| 553 | |||
| 554 | From the Jupyter menu \texttt{File\ \textgreater{}\ Download\ as} you | ||
| 555 | can choose to download your work in many formats, among which there are | ||
| 556 | also Latex and pdf. Personally I prefer downloading the .tex file, so | ||
| 557 | then I can change the title, add an author name and make any other | ||
| 558 | change I like before compiling it into a pdf file. | ||
| 559 | |||
| 560 | If you choose to download the pdf file, you might need to install some | ||
| 561 | extra packages. For example I had to install | ||
| 562 | \href{https://pandoc.org/}{\texttt{pandoc}}, \texttt{texlive-XeTeX} and | ||
| 563 | \texttt{texlive-Xdvi}, but this depends on your operating system and | ||
| 564 | Latex distribution. | ||
| 565 | |||
| 566 | \hypertarget{sagetex}{% | ||
| 567 | \section{SageTex}\label{sagetex}} | ||
| 568 | |||
| 569 | \textbf{Reference:} | ||
| 570 | {[}\href{https://doc.sagemath.org/html/en/tutorial/sagetex.html}{5}{]} | ||
| 571 | |||
| 572 | With SageTex it is possible to run Sage commands directly inside Latex, | ||
| 573 | using the \texttt{\textbackslash{}sage\{\}} command. In this way you | ||
| 574 | don't need to run your Sage code first and then copy the results in | ||
| 575 | Latex. It can be useful especially for short Sage commands. | ||
| 576 | |||
| 577 | You might need to take some extra steps to make this work on your | ||
| 578 | system, see the link above. | ||
| 579 | |||
| 580 | \hypertarget{the-latex-listings-package}{% | ||
| 581 | \section{\texorpdfstring{The Latex \texttt{listings} | ||
| 582 | package}{The Latex listings package}}\label{the-latex-listings-package}} | ||
| 583 | |||
| 584 | \textbf{References:} | ||
| 585 | {[}\href{https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings}{6}{]} | ||
| 586 | and | ||
| 587 | {[}\href{https://ftp.snt.utwente.nl/pub/software/tex/macros/latex/contrib/listings/listings.pdf}{7}{]} | ||
| 588 | |||
| 589 | If you want to include some code (Sage, Python or anything else) in a | ||
| 590 | Latex document you can use the listings package. | ||
| 591 | |||
| 592 | \begin{verbatim} | ||
| 593 | \usepackage{listings} | ||
| 594 | |||
| 595 | ... | ||
| 596 | |||
| 597 | \begin{lstlisting}[language=Python] | ||
| 598 | for i in range(0,100): | ||
| 599 | if i%5 == 0: | ||
| 600 | print("Multiple of 5!") | ||
| 601 | \end{lstlisting} | ||
| 602 | \end{verbatim} | ||
| 603 | |||
| 604 | You need to specify the language you are using with the | ||
| 605 | \texttt{language=} option. This option can also be set at the beginning | ||
| 606 | of the document using the | ||
| 607 | \texttt{\textbackslash{}lstset\{language=Python\}} command. | ||
| 608 | |||
| 609 | As an alternative, you can include a file directly without copying the | ||
| 610 | code into the tex file, like you would do for a picture: | ||
| 611 | |||
| 612 | \begin{verbatim} | ||
| 613 | \lstinputlisting[language=Python]{file.py} | ||
| 614 | \end{verbatim} | ||
| 615 | |||
| 616 | It is technically possible to include Latex listings in a markdown cell | ||
| 617 | of the Jupyter notebook using | ||
| 618 | \href{https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/latex_envs/README.html}{this | ||
| 619 | package}, but it does not make much sense. So we will move to a Latex | ||
| 620 | editor for the examples. | ||
| 621 | |||
| 622 | \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] | ||
| 623 | \prompt{In}{incolor}{ }{\boxspacing} | ||
| 624 | \begin{Verbatim}[commandchars=\\\{\}] | ||
| 625 | |||
| 626 | \end{Verbatim} | ||
| 627 | \end{tcolorbox} | ||
| 628 | |||
| 629 | |||
| 630 | % Add a bibliography block to the postdoc | ||
| 631 | |||
| 632 | |||
| 633 | |||
| 634 | \end{document} | ||
