notebook_style.tplx
115 lines
| 3.2 KiB
| text/plain
|
TextLexer
|
r12666 | ((= Notebook input/output style =)) | ||
((* extends 'latex_base.tplx' *)) | ||||
% Custom packages | ||||
((* block packages *)) | ||||
((( super() ))) | ||||
% Needed to box output/input | ||||
\usepackage{tikz} | ||||
\usetikzlibrary{calc,arrows,shadows} | ||||
\usepackage[framemethod=tikz]{mdframed} | ||||
|
r12674 | \usepackage{scrextend} % Used to indent output | ||
|
r12666 | ((* endblock packages *)) | ||
% Custom definitions | ||||
((* block definitions *)) | ||||
((( super() ))) | ||||
\listfiles | ||||
\def\smaller{\fontsize{9.5pt}{9.5pt}\selectfont} | ||||
\definecolor{nbframe-border}{rgb}{0.867,0.867,0.867} | ||||
\definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969} | ||||
\definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502} | ||||
\definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0} | ||||
\newenvironment{ColorVerbatim} | ||||
{\vspace{-2\baselineskip} | ||||
\leavevmode\begin{mdframed}[% | ||||
roundcorner=1.0pt, % | ||||
backgroundcolor=nbframe-bg, % | ||||
userdefinedwidth=1\linewidth, % | ||||
leftmargin=0.1\linewidth, % | ||||
innerleftmargin=0pt, % | ||||
innerrightmargin=0pt, % | ||||
linecolor=nbframe-border, % | ||||
linewidth=1pt, % | ||||
usetwoside=false, % | ||||
|
r12675 | everyline=false, % | ||
|
r12666 | innerlinewidth=3pt, % | ||
innerlinecolor=nbframe-bg, % | ||||
middlelinewidth=1pt, % | ||||
middlelinecolor=nbframe-bg, % | ||||
outerlinewidth=0.5pt, % | ||||
outerlinecolor=nbframe-border, % | ||||
needspace=0pt | ||||
]} | ||||
((* endblock definitions *)) | ||||
%=============================================================================== | ||||
% Input | ||||
%=============================================================================== | ||||
((* block in_prompt scoped *)) | ||||
\br | ||||
((( draw_prompt("In", cell.prompt_number, "nbframe-in-prompt") ))) | ||||
((* endblock in_prompt *)) | ||||
((* block input scoped *)) | ||||
% Add contents below. | ||||
\begin{ColorVerbatim} | ||||
|
r12673 | \smaller{\leavevmode\hspace*{-0.1\linewidth}((( super() ))) | ||
|
r12666 | \end{ColorVerbatim} | ||
((* endblock input *)) | ||||
((* block input_group scoped *)) | ||||
((( super() ))) | ||||
((* endblock input_group *)) | ||||
%=============================================================================== | ||||
% Output | ||||
%=============================================================================== | ||||
((* block output *)) | ||||
\br | ||||
% Only render the prompt if the cell is pyout. Note, the outputs prompt | ||||
% block isn't used since we need to check each indiviual output and only | ||||
% add prompts to the pyout ones. | ||||
((* if output.output_type in ['pyout'] *)) | ||||
((( draw_prompt("Out", cell.prompt_number, "nbframe-out-prompt") ))) | ||||
((* endif *)) | ||||
|
r12674 | \begin{addmargin}[0.1\linewidth]{0em} % left, right | ||
\smaller{((( super() )))} | ||||
\end{addmargin} | ||||
|
r12666 | ((* endblock output *)) | ||
%============================================================================== | ||||
% Support Macros | ||||
%============================================================================== | ||||
% Name: draw_prompt | ||||
% Purpose: Renders an output/input prompt for notebook style pdfs. Prompt is | ||||
% rendered at the current location, the cursor position is left | ||||
% unmodified. | ||||
((* macro draw_prompt(prompt, number, color) *)) | ||||
{ | ||||
\smaller | ||||
\tt | ||||
\color{((( color )))} | ||||
\noindent | ||||
((( prompt ))) | ||||
{[}((( number ))){]}: | ||||
} | ||||
\vspace{-1\baselineskip} | ||||
((* endmacro *)) | ||||