% Python execution section template for rxiv-maker
% This template provides consistent formatting for Python code execution reports

% Define custom commands for Python execution reporting
\usepackage{listings}
\usepackage{xcolor}

% Configure listings for Python code display
\lstdefinestyle{pythonexecstyle}{
    language=Python,
    basicstyle=\footnotesize\ttfamily,
    keywordstyle=\color{blue},
    commentstyle=\color{green!60!black},
    stringstyle=\color{red},
    numbers=left,
    numberstyle=\tiny\color{gray},
    stepnumber=1,
    numbersep=5pt,
    backgroundcolor=\color{gray!5},
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    frame=single,
    rulecolor=\color{gray!30},
    tabsize=2,
    captionpos=b,
    breaklines=true,
    breakatwhitespace=false,
    escapeinside={\%*}{*)}
}

% Set the default style for Python code in execution reports
\lstset{style=pythonexecstyle}

% Custom commands for formatting Python execution elements
\newcommand{\pyexecblock}[2]{%
    \textbf{#1}
    \begin{lstlisting}[style=pythonexecstyle]
#2
    \end{lstlisting}
}

\newcommand{\pyexecoutput}[1]{%
    \textbf{Output:}
    \begin{verbatim}
#1
    \end{verbatim}
}

\newcommand{\pyexecerror}[1]{%
    \textcolor{red}{\textbf{Error:}}
    \begin{verbatim}
#1
    \end{verbatim}
}

\newcommand{\pyexecvariable}[2]{%
    \texttt{#1}: \texttt{#2}
}

\newcommand{\pyexectimestamp}[1]{%
    \textit{Generated on #1}
}

% Section formatting commands
\newcommand{\pyexecsectionheader}{%
    \section*{Python Code Execution Report}
    \addcontentsline{toc}{section}{Python Code Execution Report}
}

\newcommand{\pyexecsubsection}[1]{%
    \subsection*{#1}
}

\newcommand{\pyexecsummaryitem}[2]{%
    \textbf{#1:} #2 \\
}

% Environment for Python execution statistics
\newenvironment{pyexecsummary}{%
    \begin{flushleft}
    \textbf{Execution Summary:} \\
}{%
    \end{flushleft}
}

% Environment for Python variable listings
\newenvironment{pyexecvarlist}{%
    \begin{itemize}
}{%
    \end{itemize}
}

% Footer for Python execution reports
\newcommand{\pyexecfooter}{%
    \vspace{0.5cm}
    \textit{This report was automatically generated by rxiv-maker during manuscript compilation.}
}