notebook_style.tplx
121 lines
| 3.4 KiB
| text/plain
|
TextLexer
Jonathan Frederic
|
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} | ||||
Jonathan Frederic
|
r12684 | \usepackage[framemethod=tikz]{((( resources.latex.mdframed_path | posix_path )))/mdframed} | ||
Jonathan Frederic
|
r12677 | |||
Jonathan Frederic
|
r12674 | \usepackage{scrextend} % Used to indent output | ||
Jonathan Frederic
|
r12677 | \usepackage{needspace} % Make prompts follow contents | ||
Jonathan Frederic
|
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, % | ||||
leftmargin=0.1\linewidth, % | ||||
innerleftmargin=0pt, % | ||||
innerrightmargin=0pt, % | ||||
linecolor=nbframe-border, % | ||||
linewidth=1pt, % | ||||
usetwoside=false, % | ||||
Jonathan Frederic
|
r12675 | everyline=false, % | ||
Jonathan Frederic
|
r12666 | innerlinewidth=3pt, % | ||
innerlinecolor=nbframe-bg, % | ||||
middlelinewidth=1pt, % | ||||
middlelinecolor=nbframe-bg, % | ||||
outerlinewidth=0.5pt, % | ||||
outerlinecolor=nbframe-border, % | ||||
Jonathan Frederic
|
r12677 | needspace=3em, % | ||
nobreak=false | ||||
Jonathan Frederic
|
r12666 | ]} | ||
Jonathan Frederic
|
r12676 | {\end{mdframed}\vspace{-1\baselineskip}} | ||
Jonathan Frederic
|
r12666 | |||
((* 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} | ||||
Jonathan Frederic
|
r12685 | In [0]: \vspace{-1\baselineskip}\smaller{((( super() )))} | ||
Jonathan Frederic
|
r12666 | \end{ColorVerbatim} | ||
((* endblock input *)) | ||||
((* block input_group scoped *)) | ||||
((( super() ))) | ||||
((* endblock input_group *)) | ||||
%=============================================================================== | ||||
% Output | ||||
%=============================================================================== | ||||
Jonathan Frederic
|
r12677 | ((* block output_group *)) | ||
{\br}((( super() ))) | ||||
((* endblock output_group *)) | ||||
Jonathan Frederic
|
r12666 | ((* block output *)) | ||
% 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 *)) | ||||
Jonathan Frederic
|
r12674 | \begin{addmargin}[0.1\linewidth]{0em} % left, right | ||
\smaller{((( super() )))} | ||||
\end{addmargin} | ||||
Jonathan Frederic
|
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) *)) | ||||
Jonathan Frederic
|
r12685 | |||
Jonathan Frederic
|
r12666 | { | ||
\smaller | ||||
\tt | ||||
\color{((( color )))} | ||||
Jonathan Frederic
|
r12685 | \noindent\relax | ||
Jonathan Frederic
|
r12666 | ((( prompt ))) | ||
{[}((( number ))){]}: | ||||
} | ||||
\vspace{-1\baselineskip} | ||||
((* endmacro *)) | ||||