1

When using \printpythontex and the output verbatim, I'd like to set a default styling. For example:

\documentclass{article}

\usepackage[usefamily={jl,julia,juliacon},autoprint=false,autostdout=false,makestderr]{pythontex}


\begin{document}

\begin{jlblock}
A=[i+j for i=1:3,j=1:3]
display(A)
\end{jlblock}
\printpythontex[verbatim][frame=single,fillcolor=yellow,highlightlines={1-20},highlightcolor=yellow]

\end{document}

where I'm using julia as the language, but that shouldn't be relevant.

I'd like to have all (or nearly all) verbatim output have this style.

2

The \printpythontex command with the verbatim option internally calls \VerbatimInput from the fancyvrb package. You can set default options for \VerbatimInput using \RecustomVerbatimCommand, as mentioned in the manual for fancyvrb on page 18 in a footnote.

MWE (converted to Python because I don't have Julia installed):

\documentclass{article}

\usepackage[usefamily={jl,julia,juliacon},autoprint=false,autostdout=false,makestderr]{pythontex}

\begin{document}
\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}
{frame=single,fillcolor=yellow,highlightlines={1-20},highlightcolor=yellow}

%\begin{jlblock}
%A=[i+j for i=1:3,j=1:3]
%display(A)
%\end{jlblock}

\begin{pyblock}
for i in range(1,4):
   for j in range(1,4):
      print(i+j, end=" ")
   print()
\end{pyblock}
\printpythontex[verbatim]

\end{document}

Result:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.