rened / LaTeX.jl

Create LaTeX documents from within Julia, including image handling
Other
54 stars 15 forks source link

Formatted output of Julia code #1

Closed ViralBShah closed 9 years ago

ViralBShah commented 9 years ago

I am not sure if you already have this, but in our recent paper on julia, we have a nice way to show Julia code input/outputs, in an ipython-notebook style.

This is the code snippet we used (I can track down the original author and license, if you find this useful here). What this misses is the auto-evaluation of the input to create the output. It is simply a display style.

\definecolor{shadecolor}{gray}{.92}
\definecolor{incolor}{rgb}{0,0,.7}
\definecolor{outcolor}{rgb}{.65,0,0}
\definecolor{syntaxcolor}{rgb}{.65,0,0}
\usepackage{verbatim}
\newcommand{\sh}[1]{\textcolor{syntaxcolor}{#1}}

\newcounter{jcounter}
\newenvironment{jinput}[1][]{\ifx#1\relax\else\setcounter{jcounter}{#1}\addtocounter{jcounter}{-1}\fi\refstepcounter{jcounter}\ttfamily\hspace*{-.7in}\noindent\begin{minipage}[t]{.19\textwidth}\vskip2ex\hspace*{\fill}\textcolor{incolor}{In[\arabic{jcounter}]: }\end{minipage}\begin{minipage}[t]{.8\textwidth}\vskip-0ex\begin{shaded}}{\end{shaded}\end{minipage}\par}

\newenvironment{joutput}[1][]{\vskip1ex plus .2ex minus .1ex\ifx#1\relax\else\setcounter{jcounter}{#1}\fi\addtocounter{jcounter}{-1}\refstepcounter{jcounter}\ttfamily\noindent\hspace*{-.5in}\begin{minipage}[t]{.19\textwidth}\vskip0ex\hspace*{\fill}\textcolor{outcolor}{Out[\arabic{jcounter}]: }\end{minipage}\begin{minipage}[t]{.8\textwidth}\vskip-0ex}{\end{minipage}\par\vskip1.5ex}

     \newcommand{\ja}{\begin{jinput}}
     \newcommand{\jb}{\end{jinput}\begin{joutput}}
     \newcommand{\jc}{\end{joutput}}

    \newcommand{\jav}{\begin{jinput}\begin{verbatim}}
     \newcommand{\jbv}{\end{verbatim}\end{jinput}\begin{joutput}\begin{verbatim}}
     \newcommand{\jcv}{\end{verbatim} \end{joutput}}

\usepackage{fancyvrb}
rened commented 9 years ago

Thanks a lot, I'd would like to add this! Could you please check the license situation?

We could even think about using GitHub's syntax highlighter to obtain syntax coloring at some point.

ViralBShah commented 9 years ago

@alanedelman Do you know who sent you this latex code? Can we get them to MIT license it?

malacroi commented 9 years ago

Consider this my consent to license the LaTeX snippet.

ViralBShah commented 9 years ago

Thanks!

rened commented 9 years ago

Implemented with syntax highlighting via 1bf9c2d1c49149aebe78c008b3f0b4e1e75213f7.