1

I'm trying to find the code to get boxes like the ones we can enjoy in the mathspec or biblatex user guides. It seems to be based on the listings and framed packages. Here is a working minimal example

\documentclass{book}
\usepackage{listings}
\usepackage{xcolor}
\usepackage[top=9cm,bottom=10cm]{geometry}
\usepackage{lipsum}
\definecolor{boxframe}{rgb}{0.99,0.05,0.05}
\definecolor{boxfill}{rgb}{0.99,0.95,0.95}
\lstdefinestyle{plain}{escapechar={\#}}
\lstnewenvironment{example}[1][]
{\lstset{aboveskip=15pt,xleftmargin=3pt,xrightmargin=3pt,basewidth=0.5em,basicstyle=\normalsize,frame=single,backgroundcolor=\color{boxfill},fillcolor=\color{white},rulecolor=\color{boxframe},framesep=2pt,framerule=0.5pt,style=plain,#1}}{}
\begin{document}
\lipsum[1]
\lipsum[1]
\begin{example}
listing
listing
listing
listing
listing
listing
\end{example}
\lipsum[1]
\end{document}

I'd like to be able to extract the relevant piece of code in the listings package for other purposes but, so far, in vain. I thought it was using the framed package but it is not.

  • The source is all available, so you could go digging. For biblatex a lot of the work is done by ltxdockit.sty – Alan Munn Jan 13 '11 at 1:21
  • it is pretty strange because the listings guide mentions the framed package but I cannot find where in the code? I think it is the same for ltxdockit.sty. I'll go further. – pluton Jan 13 '11 at 1:30
  • listings is inspired by fancyvrb and it makes more sense to use it in a way you already did, define a new environment. – user2478 Jan 13 '11 at 9:25
  • @Herbert: I'll have a look at fancyvrb but I wanted to create a theorem-like environment (title, numbering, labeling similar to ntheorem or thmtools) based on the frame offered by listings. That is why I wanted to extract the code dedicated to the frame. Using listings as such could be possible also. – pluton Jan 13 '11 at 14:27
2

You don't need framed.sty.

Use listings.sty and modify its properties.

Together with fancyvrb.sty you can create showexpl.sty-like environment that can span across multiple pages.

Let me know if you need more info how to do it.

  • @Herbert: OK. I will edit my answer. Thanks. – xport Jan 13 '11 at 10:10

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.