I want to put one small C-code in a textbox.

How shall I do it?

Printable View

- 06-19-2010anirbanLateX Help
I want to put one small C-code in a textbox.

How shall I do it? - 06-19-2010Shakti
- 06-19-2010anirban
Thanks but I could not make it work!

I want to put the following inside textbox.

Code:`FindMincut(undirected graph G)`

{

while there are more than 2 nodes in G do

{

pick an edge (u,v) at random in G;

contract the edge, while preserving multi-edges;

remove all loops;

}

output the remaining edges;

}

Code:`\begin{framed}`

\begin{verbatim}

FindMincut(undirected graph G)

{

while there are more than 2 nodes in G do

{

pick an edge (u,v) at random in G;

contract the edge, while preserving multi-edges;

remove all loops;

}

output the remaining edges;

}

\end{verbatim}

\end{framed}

Can I make it smaller and more descent looking?

I want the boxes like this given in the PAGE-4 of the following PDF.

Code:`http://www.cs.dartmouth.edu/~ac/Teach/CS105-Winter05/Handouts/05-mincut.pdf`

- 06-19-2010Shakti
Ok i have to admit it wasnt as easy as i thought, but after much googling i found it out:

Code:`\documentclass[11pt,a4paper]{report}`

\usepackage[pdftex]{graphicx}

\usepackage{fancyvrb}

\begin{document}

\begin{SaveVerbatim}{Code}

FindMincut(undirected graph G)

{

while there are more than 2 nodes in G do

{

pick an edge (u,v) at random in G;

contract the edge, while preserving multi-edges;

remove all loops;

}

output the remaining edges;

}

\end{SaveVerbatim}

\fbox

{

\begin{minipage}[t]{\textwidth}

\BUseVerbatim{Code}

\end{minipage}

}

\end{document}

- 06-19-2010anirban
Thanks for the help

But it is not showing as I wanted in the PDF as shown above in the link!