I’d like to add some code examples in two column form. The left is a description and the right is the REPL input code and output.
Here’s an example of what I’d like to achieve:
Are there well known packages for this type of environment?
Update:
Here's what I've tried so far, but it's rather messy:
Here's a MWE:
\documentclass{book}
\usepackage{a4wide}
\usepackage{tabularx}
\usepackage[]{sourcecodepro}
\usepackage[T1]{fontenc}
\usepackage{ragged2e}
\newlength\textlen
\newlength\codelen
\newlength\halflen
\setlength\halflen{\dimexpr.5\columnwidth-2\tabcolsep-0.5\arrayrulewidth\relax}
\setlength\textlen{.95\halflen}
\setlength\codelen{1.05\halflen}
\usepackage{color}
\definecolor{mygray}{rgb}{0.9,0.9,0.9}
\usepackage{minted}
\setminted{
baselinestretch=1,
tabsize=4,
fontsize=\fontsize{8}{11}
}
\begin{document}
\fontsize{12}{14}\selectfont
\justify
We restrict our sorting functions to permutations of the numbers $1\cdots n$. A simple way to visualize the amount of ``sortedness'' in such a list of numbers is a picture obtained with {\fontsize{10}{12}\selectfont\texttt{ListPlot}}.
\vspace{1.5mm}
{
\fontfamily{ptm}\selectfont
\fontsize{9}{11}\selectfont
\def\arraystretch{2}
\noindent\begin{tabular}{@{}p{\textlen}p{\codelen}@{}}
This definition is used to plot permutations of the numbers $1\cdots n$ with suitable settings of graphics options. &
\begin{minipage}[t]{0.5\textwidth}
\begin{minted}{Mathematica}
In[1]:= PermutationPlot[l_List, opts___] :=
ListPlot[ l,
PlotRange -> { {0.5, Length[l]+0.5},
{0.5, Length[l]+0.5} },
PlotStyle -> PointSize[0.75/Length[l]],
opts, Axes->None, FrameTicks->None,
Frame->True, AspectRatio->1 ]
\end{minted}
\end{minipage}\\
Here is a random permutation. &
\begin{minipage}[t]{0.5\textwidth}
\begin{minted}{Mathematica}
In[2]:= p1 = PermutationPlot[
{9,10,6,8,2,4,12,1,7,5,3,11},
DisplayFunction->Identity ];
\end{minted}
\end{minipage}
\end{tabular}
}
\vspace{1.5mm}
\justify
Sed efficitur diam eget ante elementum pharetra. Nullam dignissim pulvinar molestie. Sed dapibus tristique feugiat.
\end{document}



\texttt{}. You can also use themulticolpackage. See this question: https://tex.stackexchange.com/questions/3820/achieving-multicolumn-like-this?rq=1 – bmv Nov 29 '17 at 23:55