Text Formattingbox in a newenvironment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Aurelien
Posts: 1
Joined: Thu Nov 19, 2009 1:22 pm

box in a newenvironment

Post by Aurelien »

Hi all,

I am on Ubuntu Karmic Koala using Tex-live.

I am writing a document in which I have to put chunks of code. I would like to put these in red in a box with a grey background. The following code does what I want:

Code: Select all

\documentclass{article}

\usepackage{verbatim}
\usepackage{color}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node[left,text width=11cm, fill=gray!30,inner sep=1ex]
{\color{red!90}
\begin{verbatim}
Some code
\end{verbatim}
};
\end{tikzpicture}

\end{document}
Because I am going to use this many times, I wanted to put this in a newenvironment that I could call when needed. Despite many attempts, I have not been able to do that so far. My knowledge in Latex is limited and I was wondering whether somebody could explain me how to do that.

Thanks in advance

Aurélien

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

box in a newenvironment

Post by gmedina »

Hi,

try using the listings package.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply