%% %% This is file `pythontex.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% pythontex.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2012-2013 by Geoffrey M. Poore %% -------------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3 or later is part of all distributions of LaTeX %% version 2005/12/01 or later. %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{pythontex} [2013/01/23 Version~0.10beta2 PythonTeX] \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{pythontex}[2013/01/23 v0.10beta2] \newcommand{\pytx@packagename}{PythonTeX} \RequirePackage{fancyvrb} \RequirePackage{etex} \RequirePackage{etoolbox} \RequirePackage{xstring} \RequirePackage{pgfopts} \RequirePackage{newfloat} \AtBeginDocument{\@ifpackageloaded{color}{}{\RequirePackage{xcolor}}} \def\pytx@opt@rerun{default} \pgfkeys{/PYTX/pkgopt/runall/.default=true} \pgfkeys{/PYTX/pkgopt/runall/.is choice} \pgfkeys{/PYTX/pkgopt/runall/true/.code=\def\pytx@opt@rerun{all}} \pgfkeys{/PYTX/pkgopt/runall/false/.code=\relax} \pgfkeys{/PYTX/pkgopt/rerun/.is choice} \pgfkeys{/PYTX/pkgopt/rerun/modified/.code=\def\pytx@opt@rerun{modified}} \pgfkeys{/PYTX/pkgopt/rerun/errors/.code=\def\pytx@opt@rerun{errors}} \pgfkeys{/PYTX/pkgopt/rerun/warnings/.code=\def\pytx@opt@rerun{warnings}} \pgfkeys{/PYTX/pkgopt/rerun/all/.code=\def\pytx@opt@rerun{all}} \def\pytx@opt@hashdependencies{default} \pgfkeys{/PYTX/pkgopt/hashdependencies/.is choice} \pgfkeys{/PYTX/pkgopt/hashdependencies/.default=true} \pgfkeys{/PYTX/pkgopt/hashdependencies/true/.code=\def\pytx@opt@hashdependencies{true}} \pgfkeys{/PYTX/pkgopt/hashdependencies/false/.code=\def\pytx@opt@hashdependencies{false}} \newbool{pytx@opt@autoprint} \booltrue{pytx@opt@autoprint} \pgfkeys{/PYTX/pkgopt/autoprint/.default=true} \pgfkeys{/PYTX/pkgopt/autoprint/.is choice} \pgfkeys{/PYTX/pkgopt/autoprint/true/.code=\booltrue{pytx@opt@autoprint}} \pgfkeys{/PYTX/pkgopt/autoprint/false/.code=\boolfalse{pytx@opt@autoprint}} \newcommand{\setpythontexautoprint}[1]{% \ifstrequal{#1}{true}{\booltrue{pytx@opt@autoprint}}{}% \ifstrequal{#1}{false}{\boolfalse{pytx@opt@autoprint}}{}% } \newbool{pytx@opt@stdout} \booltrue{pytx@opt@stdout} \pgfkeys{/PYTX/pkgopt/stdout/.default=true} \pgfkeys{/PYTX/pkgopt/stdout/.is choice} \pgfkeys{/PYTX/pkgopt/stdout/true/.code=\booltrue{pytx@opt@stdout}} \pgfkeys{/PYTX/pkgopt/stdout/false/.code=\boolfalse{pytx@opt@stdout}} \pgfkeys{/PYTX/pkgopt/print/.default=true} \pgfkeys{/PYTX/pkgopt/print/.is choice} \pgfkeys{/PYTX/pkgopt/print/true/.code=\booltrue{pytx@opt@stdout}} \pgfkeys{/PYTX/pkgopt/print/false/.code=\boolfalse{pytx@opt@stdout}} \AtBeginDocument{% \ifbool{pytx@opt@stdout}{}{% \PackageWarning{\pytx@packagename}{Option stdout/print is set to false}% }% } \newbool{pytx@opt@stderr} \pgfkeys{/PYTX/pkgopt/stderr/.default=true} \pgfkeys{/PYTX/pkgopt/stderr/.is choice} \pgfkeys{/PYTX/pkgopt/stderr/true/.code=\booltrue{pytx@opt@stderr}} \pgfkeys{/PYTX/pkgopt/stderr/false/.code=\boolfalse{pytx@opt@stderr}} \def\pytx@opt@stderrfilename{full} \pgfkeys{/PYTX/pkgopt/stderrfilename/.default=full} \pgfkeys{/PYTX/pkgopt/stderrfilename/.is choice} \pgfkeys{/PYTX/pkgopt/stderrfilename/full/.code=\def\pytx@opt@stderrfilename{full}} \pgfkeys{/PYTX/pkgopt/stderrfilename/session/.code=\def\pytx@opt@stderrfilename{session}} \pgfkeys{/PYTX/pkgopt/stderrfilename/genericfile/.code=% \def\pytx@opt@stderrfilename{genericfile}} \pgfkeys{/PYTX/pkgopt/stderrfilename/genericscript/.code=% \def\pytx@opt@stderrfilename{genericscript}} \def\pytx@opt@pyfuture{default} \pgfkeys{/PYTX/pkgopt/pyfuture/.is choice} \pgfkeys{/PYTX/pkgopt/pyfuture/default/.code=\def\pytx@opt@pyfuture{default}} \pgfkeys{/PYTX/pkgopt/pyfuture/all/.code=\def\pytx@opt@pyfuture{all}} \pgfkeys{/PYTX/pkgopt/pyfuture/none/.code=\def\pytx@opt@pyfuture{none}} \newbool{pytx@opt@upquote} \booltrue{pytx@opt@upquote} \pgfkeys{/PYTX/pkgopt/upquote/.default=true} \pgfkeys{/PYTX/pkgopt/upquote/.is choice} \pgfkeys{/PYTX/pkgopt/upquote/true/.code=\booltrue{pytx@opt@upquote}} \pgfkeys{/PYTX/pkgopt/upquote/false/.code=\boolfalse{pytx@opt@upquote}} \newbool{pytx@opt@fixlr} \booltrue{pytx@opt@fixlr} \pgfkeys{/PYTX/pkgopt/fixlr/.default=true} \pgfkeys{/PYTX/pkgopt/fixlr/.is choice} \pgfkeys{/PYTX/pkgopt/fixlr/true/.code=\booltrue{pytx@opt@fixlr}} \pgfkeys{/PYTX/pkgopt/fixlr/false/.code=\boolfalse{pytx@opt@fixlr}} \def\pytx@opt@keeptemps{none} \pgfkeys{/PYTX/pkgopt/keeptemps/.default=all} \pgfkeys{/PYTX/pkgopt/keeptemps/.is choice} \pgfkeys{/PYTX/pkgopt/keeptemps/all/.code=\def\pytx@opt@keeptemps{all}} \pgfkeys{/PYTX/pkgopt/keeptemps/code/.code=\def\pytx@opt@keeptemps{code}} \pgfkeys{/PYTX/pkgopt/keeptemps/none/.code=\def\pytx@opt@keeptemps{none}} \newbool{pytx@opt@pygments} \booltrue{pytx@opt@pygments} \pgfkeys{/PYTX/pkgopt/pygments/.default=true} \pgfkeys{/PYTX/pkgopt/pygments/.is choice} \pgfkeys{/PYTX/pkgopt/pygments/true/.code=\booltrue{pytx@opt@pygments}} \pgfkeys{/PYTX/pkgopt/pygments/false/.code=\boolfalse{pytx@opt@pygments}} \def\pytx@pyglexer{} \pgfkeys{/PYTX/pkgopt/pyglexer/.code=\def\pytx@pyglexer{#1}} \def\pytx@pygopt{} \pgfkeys{/PYTX/pkgopt/pygopt/.code=\def\pytx@pygopt{#1}} \newbool{pytx@opt@pyginline} \booltrue{pytx@opt@pyginline} \pgfkeys{/PYTX/pkgopt/pyginline/.default=true} \pgfkeys{/PYTX/pkgopt/pyginline/.is choice} \pgfkeys{/PYTX/pkgopt/pyginline/true/.code=\booltrue{pytx@opt@pyginline}} \pgfkeys{/PYTX/pkgopt/pyginline/false/.code=\boolfalse{pytx@opt@pyginline}} \def\pytx@fvextfile{-1} \pgfkeys{/PYTX/pkgopt/fvextfile/.default=25} \pgfkeys{/PYTX/pkgopt/fvextfile/.code=\IfInteger{#1}{% \ifnum#1>0\relax \def\pytx@fvextfile{#1}% \else \PackageError{\pytx@packagename}{option fvextfile must be an integer > 0}{}% \fi}% {\PackageError{\pytx@packagename}{option fvextfile must be an integer > 0}{}}% } \def\pytx@opt@pyconbanner{none} \pgfkeys{/PYTX/pkgopt/pyconbanner/.is choice} \pgfkeys{/PYTX/pkgopt/pyconbanner/none/.code=\def\pytx@opt@pyconbanner{none}} \pgfkeys{/PYTX/pkgopt/pyconbanner/standard/.code=\def\pytx@opt@pyconbanner{standard}} \pgfkeys{/PYTX/pkgopt/pyconbanner/default/.code=\def\pytx@opt@pyconbanner{default}} \pgfkeys{/PYTX/pkgopt/pyconbanner/pyversion/.code=\def\pytx@opt@pyconbanner{pyversion}} \def\pytx@opt@pyconfilename{stdin} \pgfkeys{/PYTX/pkgopt/pyconfilename/.is choice} \pgfkeys{/PYTX/pkgopt/pyconfilename/stdin/.code=\def\pytx@opt@pyconfilename{stdin}} \pgfkeys{/PYTX/pkgopt/pyconfilename/console/.code=\def\pytx@opt@pyconfilename{console}} \newbool{pytx@opt@depythontex} \pgfkeys{/PYTX/pkgopt/depythontex/.default=true} \pgfkeys{/PYTX/pkgopt/depythontex/.is choice} \pgfkeys{/PYTX/pkgopt/depythontex/true/.code=\booltrue{pytx@opt@depythontex}} \pgfkeys{/PYTX/pkgopt/depythontex/false/.code=\boolfalse{pytx@opt@depythontex}} \ProcessPgfPackageOptions{/PYTX/pkgopt} \ifbool{pytx@opt@fixlr}{ \IfStrEq{\detokenize\expandafter{\left}}{\detokenize{\left}}{ \let\originalleft\left \let\originalright\right \renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft} \renewcommand{\right}{\aftergroup\egroup\originalright} }{} }{} \ifbool{pytx@opt@upquote}{\RequirePackage{upquote}}{} \def\pytx@CheckCounter#1{% \ifcsname c@#1\endcsname\else\newcounter{#1}\fi } \newcommand{\definepythontexcontext}[1]{% \def\pytx@SetContext{% \edef\pytx@context{#1}% }% } \definepythontexcontext{} \@onlypreamble\definepythontexcontext \newcommand{\restartpythontexsession}[1]{% \def\pytx@SetGroup{% \edef\pytx@group{#1}% }% \def\pytx@SetGroupVerb{% \edef\pytx@group{#1verb}% }% \def\pytx@SetGroupCons{% \edef\pytx@group{#1cons}% }% \AtBeginDocument{% \pytx@SetGroup \IfSubStr{\pytx@group}{verb}{% \PackageError{\pytx@packagename}% {String "verb" is not allowed in \string\restartpythontexsession}% {Use \string\restartpythontexsession with a valid argument}}{}% \IfSubStr{\pytx@group}{cons}{% \PackageError{\pytx@packagename}% {String "cons" is not allowed in \string\restartpythontexsession}% {Use \string\restartpythontexsession with a valid argument}}{}% }% } \@onlypreamble\restartpythontexsession \restartpythontexsession{default} \StrSubstitute{\jobname}{ }{-}[\pytx@jobname] \StrSubstitute{\pytx@jobname}{"}{}[\pytx@jobname] \StrSubstitute{\pytx@jobname}{*}{-}[\pytx@jobname] \newcommand{\setpythontexoutputdir}[1]{\def\pytx@outputdir{#1}} \setpythontexoutputdir{pythontex-files-\pytx@jobname} \AtBeginDocument{\@ifpackageloaded{graphicx}{\graphicspath{{\pytx@outputdir/}}}{}} \@onlypreamble\setpythontexoutputdir \newcommand{\setpythontexworkingdir}[1]{% \def\pytx@workingdir{#1}% } \@onlypreamble\setpythontexworkingdir \AtBeginDocument{% \ifcsname pytx@workingdir\endcsname\else \setpythontexworkingdir{\pytx@outputdir}\fi } \newbool{pytx@usedpygments} \AfterEndPreamble{% \ifbool{pytx@usedpygments}% {\InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxpyg}{}{}}{}% } \AtBeginDocument{% \InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxmcr}{}{}% } \newwrite\pytx@codefile \immediate\openout\pytx@codefile=\jobname.pytxcode \edef\pytx@delimchar{\string#} \edef\pytx@delim{=\string>PYTHONTEX\string#} \edef\pytx@delimsettings{=\string>PYTHONTEX:SETTINGS\string#} \AtEndDocument{ \immediate\write\pytx@codefile{% \pytx@delimsettings outputdir=\pytx@outputdir\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings workingdir=\pytx@workingdir\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings rerun=\pytx@opt@rerun\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings hashdependencies=\pytx@opt@hashdependencies\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings stderr=% \ifbool{pytx@opt@stderr}{true}{false}\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings stderrfilename=\pytx@opt@stderrfilename\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings keeptemps=\pytx@opt@keeptemps\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings pyfuture=\pytx@opt@pyfuture\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings pygments=% \ifbool{pytx@opt@pygments}{true}{false}\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings pyglexer=\pytx@pyglexer\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings pygopt=\string{\pytx@pygopt\string}\pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings fvextfile=\pytx@fvextfile \pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings pyconbanner=\pytx@opt@pyconbanner \pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings pyconfilename=\pytx@opt@pyconfilename \pytx@delimchar}% \immediate\write\pytx@codefile{% \pytx@delimsettings depythontex=% \ifbool{pytx@opt@depythontex}{true}{false}\pytx@delimchar}% } \def\pytx@WriteCodefileInfo{% \immediate\write\pytx@codefile{\pytx@delim\pytx@type\pytx@delimchar% \pytx@session\pytx@delimchar\pytx@group\pytx@delimchar% \arabic{\pytx@counter}\pytx@delimchar\pytx@cmd\pytx@delimchar% \pytx@context\pytx@delimchar\the\inputlineno\pytx@delimchar}% } \newcommand{\pytx@WriteCodefileInfoExt}[1][]{% \immediate\write\pytx@codefile{\pytx@delim\pytx@type\pytx@delimchar% \pytx@session\pytx@delimchar\pytx@group\pytx@delimchar% 0\pytx@delimchar\pytx@cmd\pytx@delimchar% \pytx@context\pytx@delimchar\the\inputlineno\pytx@delimchar#1}% } \newcommand{\setpythontexfv}[2][]{% \ifstrempty{#1}% {\gdef\pytx@fvsettings{#2}}% {\expandafter\gdef\csname pytx@fvsettings@#1\endcsname{#2}}% }% \setpythontexfv{tabsize=4} \def\pytx@FVSet{% \expandafter\let\expandafter\pytx@fvsettings@@% \csname pytx@fvsettings@\pytx@type\endcsname \ifdefstring{\pytx@fvsettings@@}{}% {}% {\expandafter\fvset\expandafter{\pytx@fvsettings@@}}% \ifdefstring{\pytx@fvsettings}{}% {}% {\expandafter\fvset\expandafter{\pytx@fvsettings}}% } \newcounter{pytx@FancyVerbLineTemp} \def\pytx@FVB@SaveVerbatim#1{% \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \@bsphack \begingroup \FV@UseKeyValues \def\SaveVerbatim@Name{#1}% \def\FV@ProcessLine##1{% \expandafter\gdef\expandafter\FV@TheVerbatim\expandafter{% \FV@TheVerbatim\FV@StepLineNo\FV@ProcessLine{##1}}}% \gdef\FV@TheVerbatim{\FV@CodeLineNo=1}% \FV@Scan} \def\pytx@FVE@SaveVerbatim{% \expandafter\global\expandafter\let \csname FV@SV@\SaveVerbatim@Name\endcsname\FV@TheVerbatim \endgroup\@esphack \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}} \let\FVB@SaveVerbatim\pytx@FVB@SaveVerbatim \let\FVE@SaveVerbatim\pytx@FVE@SaveVerbatim \def\pytx@stdfile{} \def\pytx@stdout@warntext{} \def\pytx@FetchStdoutfile[#1][#2]#3{% \IfFileExists{\pytx@outputdir/#3.stdout}{% \ifstrequal{#1}{}{\input{\pytx@outputdir/#3.stdout}}{}% \ifstrequal{#1}{raw}{\input{\pytx@outputdir/#3.stdout}}{}% \ifstrequal{#1}{verb}{\VerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}% \ifstrequal{#1}{inlineverb}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}% \ifstrequal{#1}{v}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}% }% {\pytx@stdout@warntext \PackageWarning{\pytx@packagename}{Non-existent printed content}}% } \ifbool{pytx@opt@stdout}{}{\def\pytx@FetchStdoutfile[#1][#2]#3{}} \AtBeginDocument{\def\pytx@stdout@warntext{\textbf{??~\pytx@packagename~??}}} \def\stdoutpythontex{% \@ifnextchar[{\pytx@Stdout}{\pytx@Stdout[]}% } \def\pytx@Stdout[#1]{% \@ifnextchar[{\pytx@Stdout@i[#1]}{\pytx@Stdout@i[#1][]}% } \def\pytx@Stdout@i[#1][#2]{% \pytx@FetchStdoutfile[#1][#2]{\pytx@stdfile}% } \let\printpythontex\stdoutpythontex \def\savestdoutpythontex#1{% \ifcsname pytx@SVout@#1\endcsname \PackageError{\pytx@packagename}% {Attempt to save content using an already-defined name}% {Use a name that is not already defined}% \else \expandafter\edef\csname pytx@SVout@#1\endcsname{\pytx@stdfile}% \fi } \let\saveprintpythontex\savestdoutpythontex \def\usestdoutpythontex{% \@ifnextchar[{\pytx@UseStdout}{\pytx@UseStdout[]}% } \def\pytx@UseStdout[#1]{% \@ifnextchar[{\pytx@UseStdout@i[#1]}{\pytx@UseStdout@i[#1][]}% } \def\pytx@UseStdout@i[#1][#2]#3{% \ifcsname pytx@SVout@#3\endcsname \pytx@FetchStdoutfile[#1][#2]{\csname pytx@SVout@#3\endcsname}% \else \textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent saved printed content}% \fi } \let\useprintpythontex\usestdoutpythontex \def\pytx@FetchStderrfile[#1][#2]#3{% \IfFileExists{\pytx@outputdir/#3.stderr}{% \ifstrequal{#1}{}{\VerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}% \ifstrequal{#1}{raw}{\input{\pytx@outputdir/#3.stderr}}{}% \ifstrequal{#1}{verb}{\VerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}% \ifstrequal{#1}{inlineverb}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}% \ifstrequal{#1}{v}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}% }% {\textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent stderr content}}% } \def\stderrpythontex{% \@ifnextchar[{\pytx@Stderr}{\pytx@Stderr[]}% } \def\pytx@Stderr[#1]{% \@ifnextchar[{\pytx@Stderr@i[#1]}{\pytx@Stderr@i[#1][]}% } \def\pytx@Stderr@i[#1][#2]{% \pytx@FetchStderrfile[#1][#2]{\pytx@stdfile}% } \def\savestderrpythontex#1{% \ifcsname pytx@SVerr@#1\endcsname \PackageError{\pytx@packagename}% {Attempt to save content using an already-defined name}% {Use a name that is not already defined}% \else \expandafter\edef\csname pytx@SVerr@#1\endcsname{\pytx@stdfile}% \fi } \def\usestderrpythontex{% \@ifnextchar[{\pytx@UseStderr}{\pytx@UseStderr[]}% } \def\pytx@UseStderr[#1]{% \@ifnextchar[{\pytx@UseStderr@i[#1]}{\pytx@UseStderr@i[#1][]}% } \def\pytx@UseStderr@i[#1][#2]#3{% \ifcsname pytx@SVerr@#3\endcsname \pytx@FetchStderrfile[#1][#2]{\csname pytx@SVerr@#3\endcsname}% \else \textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent saved stderr content}% \fi } \def\pytx@Inline{% \begingroup \let\do\@makeother\dospecials \catcode`\{=1 \@ifnextchar[{\endgroup\pytx@InlineOarg}{\endgroup\pytx@InlineOarg[]}% }% \def\pytx@InlineOarg[#1]{% \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}% \begingroup \let\do\@makeother\dospecials \catcode`\{=1 \catcode`\}=2 \catcode`\ =\active \catcode`\^^I=\active \@ifnextchar\bgroup {\pytx@InlineMargBgroup}% {\catcode`\{=12 \catcode`\}=12 \pytx@InlineMargOther}% } \def\pytx@InlineMargOther#1{% \endgroup \ifstrequal{#1}{ }{% \PackageError{\pytx@packagename}% {The space character cannot be used as a delimiting character}% {Choose another delimiting character}}{}% \def\pytx@InlineMargOtherGet##1#1{\pytx@InlineMargBgroup{##1}}% \begingroup \let\do\@makeother\dospecials \pytx@InlineMargOtherGet } \def\pytx@InlineMargBgroup#1{% \endgroup \def\pytx@argdetok{\detokenize{#1}}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}% \pytx@InlineShow \pytx@InlineSave \pytx@InlinePrint \stepcounter{\pytx@counter}% }% \def\pytx@InlineShowFV{% \begingroup \let\do\@makeother\dospecials \catcode`\ =\active \catcode`\^^I=\active \tokenize{\pytx@argretok}{\pytx@argdetok}% \endgroup \begingroup \pytx@FVSet \FV@BeginVBox \frenchspacing \FV@SetupFont \FV@DefineWhiteSpace \FancyVerbDefineActive \FancyVerbFormatCom \FV@ObeyTabsInit \hbox{\FancyVerbFormatLine{\pytx@argretok}}% \FV@EndVBox \endgroup } \def\pytx@InlineShowPyg{% \begingroup \pytx@FVSet \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \BUseVerbatim{\pytx@counter @\arabic{\pytx@counter}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \else \textbf{??}% \PackageWarning{\pytx@packagename}{Non-existent Pygments content}% \fi \endgroup } \def\pytx@InlineSaveCode{% \pytx@WriteCodefileInfo \immediate\write\pytx@codefile{\pytx@argdetok}% } \let\pytx@InlineAutoprint\@empty \AtBeginDocument{ \def\pytx@InlineAutoprint{% \ifbool{pytx@opt@autoprint}{% \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.stdout}{}{}}{}% } \ifbool{pytx@opt@stdout}{}{\let\pytx@InlineAutoprint\@empty} } \def\pytx@InlineMacroprint{% \edef\pytx@mcr{pytx@MCR@\pytx@type @\pytx@session @\pytx@group @\arabic{\pytx@counter}}% \ifcsname\pytx@mcr\endcsname \csname\pytx@mcr\endcsname \else \textbf{??}% \PackageWarning{\pytx@packagename}{Missing autoprint content}% \fi } \ifbool{pytx@opt@stdout}{}{\let\pytx@InlineMacroprint\@empty} \newcommand{\pytx@MakeInlinebFV}[1]{% \expandafter\newcommand\expandafter{\csname #1b\endcsname}{% \xdef\pytx@type{#1}% \edef\pytx@cmd{inlineb}% \pytx@SetContext \pytx@SetGroup \let\pytx@InlineShow\pytx@InlineShowFV \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\@empty \pytx@Inline }% }% \newcommand{\pytx@MakeInlinebPyg}[1]{% \expandafter\newcommand\expandafter{\csname #1b\endcsname}{% \xdef\pytx@type{#1}% \edef\pytx@cmd{inlineb}% \pytx@SetContext \pytx@SetGroup \let\pytx@InlineShow\pytx@InlineShowPyg \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\@empty \pytx@Inline }% }% \newcommand{\pytx@MakeInlinevFV}[1]{% \expandafter\newcommand\expandafter{\csname #1v\endcsname}{% \xdef\pytx@type{#1}% \edef\pytx@cmd{inlinev}% \pytx@SetContext \pytx@SetGroupVerb \let\pytx@InlineShow\pytx@InlineShowFV \let\pytx@InlineSave\@empty \let\pytx@InlinePrint\@empty \pytx@Inline }% }% \newcommand{\pytx@MakeInlinevPyg}[1]{% \expandafter\newcommand\expandafter{\csname #1v\endcsname}{% \xdef\pytx@type{#1}% \edef\pytx@cmd{inlinev}% \pytx@SetContext \pytx@SetGroupVerb \let\pytx@InlineShow\pytx@InlineShowPyg \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\@empty \pytx@Inline }% }% \newcommand{\pytx@MakeInlinecFV}[1]{% \expandafter\newcommand\expandafter{\csname #1c\endcsname}{% \xdef\pytx@type{#1}% \edef\pytx@cmd{inlinec}% \pytx@SetContext \pytx@SetGroup \let\pytx@InlineShow\@empty \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\pytx@InlineAutoprint \pytx@Inline }% }% \let\pytx@MakeInlinecPyg\pytx@MakeInlinecFV \newcommand{\pytx@MakeInlineFV}[1]{% \expandafter\newcommand\expandafter{\csname #1\endcsname}{% \xdef\pytx@type{#1}% \edef\pytx@cmd{inline}% \pytx@SetContext \pytx@SetGroup \let\pytx@InlineShow\@empty \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\pytx@InlineMacroprint \pytx@Inline }% }% \let\pytx@MakeInlinePyg\pytx@MakeInlineFV \newcommand{\pythontexcustomc}[2][begin]{% \ifstrequal{#1}{begin}{}{% \ifstrequal{#1}{end}{}{\PackageError{\pytx@packagename}% {Invalid optional argument for \string\pythontexcustomc}{} }% }% \xdef\pytx@type{CC:#2:#1}% \edef\pytx@cmd{inlinec}% \def\pytx@context{}% \def\pytx@group{none}% \let\pytx@InlineShow\@empty \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\@empty \pytx@Inline[none]% }% \def\setpythontexcustomcode#1{% \PackageWarning{\pytx@packagename}{The command \string\setpythontexcustomcode\space has been deprecated; use \string\pythontexcustomc\space or pythontexcustomcode instead}% \begingroup \let\do\@makeother\dospecials \catcode`\{=1 \catcode`\}=2 \catcode`\^^M=10\relax \pytx@SetCustomCode{#1}% } \long\def\pytx@SetCustomCode#1#2{% \endgroup \pythontexcustomc{#1}{pythontexcustomcode=[#2]; exec('for expr in pythontexcustomcode: exec(expr)'); del(pythontexcustomcode)} } \@onlypreamble\setpythontexcustomcode \begingroup \catcode`\^^M=\active \gdef\pytx@FancyVerbGetLine#1^^M{% \@nil% \FV@CheckEnd{#1}% \ifx\@tempa\FV@EnvironName% \ifx\@tempb\FV@@@CheckEnd\else\FV@BadEndError\fi% \let\next\FV@EndScanning% \else% \def\FV@Line{#1}% \def\next{\FV@PreProcessLine\FV@GetLine}% \immediate\write\pytx@codefile{\detokenize{#1}}% \fi% \next}% \endgroup \newcommand{\pytx@MakeBlockFV}[1]{% \expandafter\newenvironment{#1block}{% \VerbatimEnvironment \xdef\pytx@type{#1}% \edef\pytx@cmd{block}% \pytx@SetContext \pytx@SetGroup \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginBlockEnvFV}{\endgroup\pytx@BeginBlockEnvFV[]}% }% {\end{Verbatim}% \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}% \setcounter{\pytx@linecount}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% } \def\pytx@BeginBlockEnvFV[#1]{% \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \edef\pytx@linecount{\pytx@counter @line}% \pytx@CheckCounter{\pytx@linecount}% \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{\pytx@linecount}}% \pytx@WriteCodefileInfo \let\FancyVerbGetLine\pytx@FancyVerbGetLine \pytx@FVSet \begin{Verbatim}% } \newcommand{\pytx@MakeVerbFV}[1]{% \expandafter\newenvironment{#1verb}{% \VerbatimEnvironment \xdef\pytx@type{#1}% \edef\pytx@cmd{verb}% \pytx@SetContext \pytx@SetGroupVerb \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginVerbEnvFV}{\endgroup\pytx@BeginVerbEnvFV[]}% }% {\end{Verbatim}% \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}% \setcounter{\pytx@linecount}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% } \def\pytx@BeginVerbEnvFV[#1]{% \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \edef\pytx@linecount{\pytx@counter @line}% \pytx@CheckCounter{\pytx@linecount}% \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{\pytx@linecount}}% \pytx@FVSet \begin{Verbatim}% } \newcommand{\pytx@MakePygEnv}[2]{% \expandafter\newenvironment{#1#2}{% \VerbatimEnvironment \xdef\pytx@type{#1}% \edef\pytx@cmd{#2}% \pytx@SetContext \ifstrequal{#2}{block}{\pytx@SetGroup}{} \ifstrequal{#2}{verb}{\pytx@SetGroupVerb}{} \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginEnvPyg}{\endgroup\pytx@BeginEnvPyg[]}% }% {\end{VerbatimOut}% \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}% \setcounter{FancyVerbLine}{\value{\pytx@linecount}}% \pytx@FVSet \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}% \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}% \else \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.pygtex}{}% {\textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}% \fi \setcounter{\pytx@linecount}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% }% \def\pytx@BeginEnvPyg[#1]{% \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \edef\pytx@linecount{\pytx@counter @line}% \pytx@CheckCounter{\pytx@linecount}% \pytx@WriteCodefileInfo \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginEnvPyg@i}{\endgroup\pytx@BeginEnvPyg@i[]}% }% \def\pytx@BeginEnvPyg@i[#1]{% \def\pytx@fvopttmp{#1}% \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut \begin{VerbatimOut}% }% \newcommand{\pytx@MakeBlockPyg}[1]{\pytx@MakePygEnv{#1}{block}} \newcommand{\pytx@MakeVerbPyg}[1]{\pytx@MakePygEnv{#1}{verb}} \def\pytx@WriteDetok#1{% \immediate\write\pytx@codefile{\detokenize{#1}}}% \def\pytx@FVB@VerbatimOut{% \@bsphack \begingroup \let\FV@ProcessLine\pytx@WriteDetok \let\FV@FontScanPrep\relax \let\@noligs\relax \FV@Scan}% \def\pytx@FVE@VerbatimOut{\endgroup\@esphack}% \let\pytx@EnvAutoprint\@empty \AtBeginDocument{ \def\pytx@EnvAutoprint{% \ifbool{pytx@opt@autoprint}{% \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.stdout}{}{}}{}% } \ifbool{pytx@opt@stdout}{}{\let\pytx@EnvAutoprint\@empty} } \newcommand{\pytx@MakeCodeFV}[1]{% \expandafter\newenvironment{#1code}{% \VerbatimEnvironment \xdef\pytx@type{#1}% \edef\pytx@cmd{code}% \pytx@SetContext \pytx@SetGroup \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginCodeEnv}{\endgroup\pytx@BeginCodeEnv[]}% }% {\end{VerbatimOut}% \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}% \pytx@EnvAutoprint \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% }% \def\pytx@BeginCodeEnv[#1]{% \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \pytx@WriteCodefileInfo \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginCodeEnv@i}{\endgroup\pytx@BeginCodeEnv@i[]}% }% \def\pytx@BeginCodeEnv@i[#1]{% \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut \begin{VerbatimOut}% }% \let\pytx@MakeCodePyg\pytx@MakeCodeFV \newenvironment{pythontexcustomcode}[2][begin]{% \VerbatimEnvironment \ifstrequal{#1}{begin}{}{% \ifstrequal{#1}{end}{}{\PackageError{\pytx@packagename}% {Invalid optional argument for pythontexcustomcode}{} }% }% \xdef\pytx@type{CC:#2:#1}% \edef\pytx@cmd{code}% \def\pytx@context{}% \def\pytx@group{none}% \pytx@BeginCodeEnv[none]}% {\end{VerbatimOut}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% \newcommand{\pytx@MakeConsFV}[1]{% \expandafter\newenvironment{#1console}{% \VerbatimEnvironment \xdef\pytx@type{#1}% \edef\pytx@cmd{console}% \pytx@SetContext \pytx@SetGroupCons \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginConsEnvFV}{\endgroup\pytx@BeginConsEnvFV[]}% }% {\end{VerbatimOut}% \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}% \setcounter{FancyVerbLine}{\value{\pytx@linecount}}% \pytx@FVSet \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}% \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}% \else \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.pygtex}{}% {\textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent console content}}% \fi \setcounter{\pytx@linecount}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% } \def\pytx@BeginConsEnvFV[#1]{% \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \edef\pytx@linecount{\pytx@counter @line}% \pytx@CheckCounter{\pytx@linecount}% \pytx@WriteCodefileInfo \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BeginConsEnvFV@i}{\endgroup\pytx@BeginConsEnvFV@i[]}% }% \def\pytx@BeginConsEnvFV@i[#1]{% \def\pytx@fvopttmp{#1}% \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut \begin{VerbatimOut}% }% \let\pytx@MakeConsPyg\pytx@MakeConsFV \newcommand{\makepythontexfamilyfv}[2][]{% \IfBeginWith{#2}{PYG}% {\PackageError{\pytx@packagename}% {Attempt to create macros with reserved prefix PYG}{}}{}% \pytx@MakeInlinebFV{#2}% \pytx@MakeInlinevFV{#2}% %\pytx@MakeInlinecFV{#2}% \pytx@MakeInlineFV{#2}% \pytx@MakeBlockFV{#2}% \pytx@MakeVerbFV{#2}% %\pytx@MakeCodeFV{#2}% \ifstrequal{#1}{console}{\pytx@MakeConsFV{#2}}{}% \ifstrequal{#1}{all}{\pytx@MakeConsFV{#2}}{}% \setpythontexfv[#2]{}% } \@onlypreamble\makepythontexfamilyfv \newcommand{\makepythontexfamilypyg}[4][]{% \IfBeginWith{#2}{PYG}% {\PackageError{\pytx@packagename}% {Attempt to create macros with reserved prefix PYG}{}}{}% \ifbool{pytx@opt@pyginline}% {\pytx@MakeInlinebPyg{#2}% \pytx@MakeInlinevPyg{#2}}% {\pytx@MakeInlinebFV{#2}% \pytx@MakeInlinevFV{#2}}% %\pytx@MakeInlinecPyg{#2}% \pytx@MakeInlinePyg{#2}% \pytx@MakeBlockPyg{#2}% \pytx@MakeVerbPyg{#2}% %\pytx@MakeCodePyg{#2}% \ifstrequal{#1}{console}{\pytx@MakeConsPyg{#2}}{}% \ifstrequal{#1}{all}{\pytx@MakeConsPyg{#2}}{}% \setpythontexfv[#2]{}% \booltrue{pytx@usedpygments}% \expandafter\xdef\csname pytx@pygopt@#2\endcsname{#4}% \AtEndDocument{\immediate\write\pytx@codefile{% \pytx@delimsettings pygfamily=#2,#3,% \string{\csname pytx@pygopt@#2\endcsname\string}\pytx@delimchar}% }% } \@onlypreamble\makepythontexfamilypyg \def\setpythontexpyglexer#1#2{% \ifcsname pytx@pyglexer@#1\endcsname \expandafter\xdef\csname pytx@pyglexer@#1\endcsname{#2}% \else \PackageError{\pytx@packagename}% {Cannot modify a non-existent family}{}% \fi }% \@onlypreamble\setpythontexpyglexer \newcommand{\setpythontexpygopt}[2]{% \ifcsname pytx@pygopt@#1\endcsname \expandafter\xdef\csname pytx@pygopt@#1\endcsname{#2}% \else \PackageError{\pytx@packagename}% {Cannot modify Pygments options for a non-existent family}{}% \fi } \@onlypreamble\setpythontexpygopt \newcommand{\makepythontexfamily}[4][]{% \expandafter\xdef\csname pytx@macroformatter@#2\endcsname{auto} \expandafter\xdef\csname pytx@pyglexer@#2\endcsname{#3} \expandafter\xdef\csname pytx@pygopt@#2\endcsname{#4} \pytx@MakeInlinecFV{#2} \pytx@MakeCodeFV{#2} \AtBeginDocument{% \ifcsstring{pytx@macroformatter@#2}{auto}{% \ifbool{pytx@opt@pygments}% {\makepythontexfamilypyg[#1]{#2}{\csname pytx@pyglexer@#2\endcsname}% {\csname pytx@pygopt@#2\endcsname}}% {\makepythontexfamilyfv[#1]{#2}}}{}% \ifcsstring{pytx@macroformatter@#2}{fancyvrb}% {\makepythontexfamilyfv[#1]{#2}}{}% \ifcsstring{pytx@macroformatter@#2}{pygments}% {\makepythontexfamilypyg[#1]{#2}{\csname pytx@pyglexer@#2\endcsname}% {\csname pytx@pygopt@#2\endcsname}}{}% }% } \@onlypreamble\makepythontexfamily \def\setpythontexformatter#1#2{% \ifcsname pytx@macroformatter@#1\endcsname \expandafter\xdef\csname pytx@macroformatter@#1\endcsname{#2} \else \PackageError{\pytx@packagename}% {Cannot modify a family that does not exist or does not allow formatter choices}% {Create the family with \string\makepythontexfamily}% \fi } \@onlypreamble\setpythontexformatter \makepythontexfamily[all]{py}{python}{} \makepythontexfamily[all]{sympy}{python}{} \makepythontexfamily[all]{pylab}{python}{} \newbool{pytx@listingenv} \def\setpythontexlistingenv#1{ \DeclareFloatingEnvironment[fileext=lopytx,listname={List of Listings},name=Listing]{#1} \booltrue{pytx@listingenv} } \@onlypreamble\setpythontexlistingenv \AtBeginDocument{ \ifcsname listing\endcsname \ifbool{pytx@listingenv}{}% {\PackageWarning{\pytx@packagename}% {A "listing" environment already exists \MessageBreak \pytx@packagename\space will not create one \MessageBreak Use \string\setpythontexlistingenv to create a custom listing environment}}% \else \ifbool{pytx@listingenv}{}{\DeclareFloatingEnvironment[fileext=lopytx]{listing}} \fi } \def\pytx@MakePygmentsInlineFV{% \newcommand{\pygment}[1]{% \edef\pytx@type{PYG##1}% \edef\pytx@cmd{inlinev}% \pytx@SetContext \pytx@SetGroupVerb \let\pytx@InlineShow\pytx@InlineShowFV \let\pytx@InlineSave\@empty \let\pytx@InlinePrint\@empty \ifcsname pytx@fvsettings@\pytx@type\endcsname \else \expandafter\gdef\csname pytx@fvsettings@\pytx@type\endcsname{}% \fi \pytx@Inline[]% }% } \def\pytx@MakePygmentsInlinePyg{% \newcommand{\pygment}[1]{% \edef\pytx@type{PYG##1}% \edef\pytx@cmd{inlinev}% \pytx@SetContext \pytx@SetGroupVerb \let\pytx@InlineShow\pytx@InlineShowPyg \let\pytx@InlineSave\pytx@InlineSaveCode \let\pytx@InlinePrint\@empty \ifcsname pytx@fvsettings@\pytx@type\endcsname \else \expandafter\gdef\csname pytx@fvsettings@\pytx@type\endcsname{}% \fi \pytx@Inline[] }% } \def\pytx@MakePygmentsEnvFV{% \newenvironment{pygments}{% \VerbatimEnvironment \pytx@SetContext \pytx@SetGroupVerb \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BEPygmentsFV}{\endgroup\pytx@BEPygmentsFV[]}% }% {\end{Verbatim}% \setcounter{\pytx@linecount}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% }% } \def\pytx@BEPygmentsFV[#1]{% \def\pytx@fvopttmp{#1}% \begingroup \obeylines \pytx@BEPygmentsFV@i } \def\pytx@BEPygmentsFV@i#1{% \endgroup \edef\pytx@type{PYG#1}% \edef\pytx@cmd{verb}% \edef\pytx@session{default}% \edef\pytx@linecount{pytx@\pytx@type @\pytx@session @\pytx@group @line}% \pytx@CheckCounter{\pytx@linecount}% \ifcsname pytx@fvsettings@\pytx@type\endcsname \else \expandafter\gdef\csname pytx@fvsettings@\pytx@type\endcsname{}% \fi \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{\pytx@linecount}}% \pytx@FVSet \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}% \begin{Verbatim}% } \def\pytx@MakePygmentsEnvPyg{% \newenvironment{pygments}{% \VerbatimEnvironment \pytx@SetContext \pytx@SetGroupVerb \begingroup \obeylines \@ifnextchar[{\endgroup\pytx@BEPygmentsPyg}{\endgroup\pytx@BEPygmentsPyg[]}% }% {\end{VerbatimOut}% \setcounter{FancyVerbLine}{\value{\pytx@linecount}}% \pytx@FVSet \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}% \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}% \else \InputIfFileExists{\pytx@outputdir/% \pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}.pygtex}{}% {\textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}% \fi \setcounter{\pytx@linecount}{\value{FancyVerbLine}}% \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% \stepcounter{\pytx@counter}% }% } \def\pytx@BEPygmentsPyg[#1]{% \def\pytx@fvopttmp{#1}% \begingroup \obeylines \pytx@BEPygmentsPyg@i } \def\pytx@BEPygmentsPyg@i#1{% \endgroup \edef\pytx@type{PYG#1}% \edef\pytx@cmd{verb}% \edef\pytx@session{default}% \edef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}% \pytx@CheckCounter{\pytx@counter}% \edef\pytx@linecount{\pytx@counter @line}% \pytx@CheckCounter{\pytx@linecount}% \pytx@WriteCodefileInfo \ifcsname pytx@fvsettings@\pytx@type\endcsname \else \expandafter\gdef\csname pytx@fvsettings@\pytx@type\endcsname{}% \fi \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut \begin{VerbatimOut}% } \def\pytx@MakePygmentsInputFV{ \newcommand{\inputpygments}[3][]{% \edef\pytx@type{PYG##2}% \edef\pytx@cmd{verb}% \pytx@SetContext \pytx@SetGroupVerb \edef\pytx@session{EXT:##3}% \ifcsname pytx@fvsettings@\pytx@type\endcsname \else \expandafter\gdef\csname pytx@fvsettings@\pytx@type\endcsname{}% \fi \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \begingroup \pytx@FVSet \fvset{firstnumber=auto}% \IfFileExists{##3}% {\VerbatimInput[##1]{##3}}% {\PackageWarning{\pytx@packagename}{Input file <##3> doesn't exist}}% \endgroup \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% }% } \def\pytx@MakePygmentsInputPyg{ \newcommand{\inputpygments}[3][]{% \edef\pytx@type{PYG##2}% \edef\pytx@cmd{verb}% \pytx@SetContext \pytx@SetGroupVerb \edef\pytx@session{EXT:##3}% \ifcsname pytx@fvsettings@\pytx@type\endcsname \else \expandafter\gdef\csname pytx@fvsettings@\pytx@type\endcsname{}% \fi \pytx@WriteCodefileInfoExt \IfFileExists{##3}{}{\PackageWarning{\pytx@packagename}% {Input file <##3> does not exist}} \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}% \begingroup \pytx@FVSet \fvset{firstnumber=auto}% \ifcsname FV@SV@pytx@\pytx@type @\pytx@session @\pytx@group @0\endcsname \UseVerbatim[##1]{pytx@\pytx@type @\pytx@session @\pytx@group @0}% \else \InputIfFileExists{\pytx@outputdir/##3_##2.pygtex}{}% {\textbf{??~\pytx@packagename~??}% \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}% \fi \endgroup \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}% }% } \newcommand{\setpygmentsfv}[2][]{% \ifstrempty{#1}% {\gdef\pytx@fvsettings{#2}}% {\expandafter\gdef\csname pytx@fvsettings@PYG#1\endcsname{#2}}% }% \def\setpygmentspygopt#1#2{% \AtEndDocument{\immediate\write\pytx@codefile{% \pytx@delimsettings pygfamily=PYG#1,#1,% \string{#2\string}\pytx@delimchar}% }% } \@onlypreamble\setpygmentspygopt \def\setpygmentsformatter#1{\xdef\pytx@macroformatter@PYG{#1}} \@onlypreamble\setpygmentsformatter \setpygmentsformatter{auto} \def\makepygmentsfv{% \pytx@MakePygmentsInlineFV \pytx@MakePygmentsEnvFV \pytx@MakePygmentsInputFV }% \@onlypreamble\makepygmentsfv \def\makepygmentspyg{% \ifbool{pytx@opt@pyginline}% {\pytx@MakePygmentsInlinePyg}% {\pytx@MakePygmentsInlineFV}% \pytx@MakePygmentsEnvPyg \pytx@MakePygmentsInputPyg \booltrue{pytx@usedpygments} }% \@onlypreamble\makepygmentspyg \def\makepygments{% \AtBeginDocument{% \ifdefstring{\pytx@macroformatter@PYG}{auto}% {\ifbool{pytx@opt@pygments}% {\makepygmentspyg}{\makepygmentsfv}}{} \ifdefstring{\pytx@macroformatter@PYG}{pygments}% {\makepygmentspyg}{} \ifdefstring{\pytx@macroformatter@PYG}{fancyvrb}% {\makepygmentsfv}{} }% }% \@onlypreamble\makepygments \makepygments \AfterEndDocument{% \immediate\closeout\pytx@codefile } \endinput %% %% End of file `pythontex.sty'.