LateX Help

This is a discussion on LateX Help within the Tech Board forums, part of the Community Boards category; I want to put one small C-code in a textbox. How shall I do it?...

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    LateX Help

    I want to put one small C-code in a textbox.
    How shall I do it?
    Last edited by anirban; 06-19-2010 at 09:06 AM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203

  3. #3
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    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;
    }
    I tried the following...

    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}
    I am getting a page wide huge box around the text.
    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

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    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}

  5. #5
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Thanks for the help
    But it is not showing as I wanted in the PDF as shown above in the link!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LaTeX
    By master5001 in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 10-29-2008, 05:38 PM
  2. LaTeX help
    By Draco in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 04-18-2007, 03:59 PM
  3. LaTeX Question: Displaying Text and Images
    By Reisswolf in forum Tech Board
    Replies: 0
    Last Post: 06-30-2006, 08:01 AM
  4. LaTeX Question
    By Reisswolf in forum Tech Board
    Replies: 2
    Last Post: 05-07-2006, 11:11 AM
  5. LaTEX help....need LaTex guru advice
    By jodders in forum Tech Board
    Replies: 2
    Last Post: 03-13-2005, 01:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21