I am writing a short introductory book on LaTeX and I would like to implement nice looking code example boxes. Using this answer:
Source code listing with frame around code? I made the boxes with the listings packages by setting in the preamble:
\usepackage{listings}
\usepackage{xcolor}
\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{%
\parbox{\textwidth}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}\vskip-4pt}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\lstset{frame=lrb,xleftmargin=\fboxsep,xrightmargin=-\fboxsep,language=[LaTeX]{TeX},columns=flexible}
\renewcommand{\lstlistingname}{Example}
and in the text for example:
\begin{lstlisting}[label=firstlook,caption=A First Look]
\documentclass{article}
\begin{document}
Hello World!
\end{document}
\end{lstlisting}
Which results in:
And looks nice. I would like to make something similar for the output, and was wondering how I could do that (by manually writing the output I mean, not automatically taking what I enter there and evaluate it). Just the same looking box would be cool, having this box split in the middle and show an "output panel" or something would be even cooler. Does anyone know how I can do such a thing?
Best Answer
I think the good package is
showexpl
.This package works withlistings
.I work actually on the tkzexample package. The last version is on ctan but I try to finish the doc. You can present the source code and the result but it's not possible to highlight the syntax.