Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Verbatim text with colored background
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ashish Revar  
View profile  
 More options Jan 29 2011, 12:39 am
From: Ashish Revar <ashishre...@gmail.com>
Date: Sat, 29 Jan 2011 11:09:58 +0530
Local: Sat, Jan 29 2011 12:39 am
Subject: Verbatim text with colored background

Hello there,
I am trying to make verbatim text may differ from the other text.
For that, I have defined some commands like below,

*\usepackage{color}*
*\definecolor{gray}{gray}{0.5}*
*
*
*\fcolorbox{gray}{gray}%*
*  {\color{white} *
*
*
*\begin{verbatim}*
*euca-bundle-image -i <kernel file> --kernel true*
*euca-upload-bundle -b <kernel bucket> -m /tmp/<kernel file>.manifest.xml*
*euca-register <kernel-bucket>/<kernel file>.manifest.xml*
*\end{verbatim}*
* }*

But this shows an error, I want something like this, black text, gray BG and
black border.
[image: Latex.jpg]
--
Any package or code for this?

*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com
9909298846*

  Latex.jpg
138K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashish Revar  
View profile  
 More options Jan 29 2011, 2:08 am
From: Ashish Revar <ashishre...@gmail.com>
Date: Sat, 29 Jan 2011 12:38:55 +0530
Local: Sat, Jan 29 2011 2:08 am
Subject: Re: Verbatim text with colored background

Hello there,

I have found out one probable solution for me but I want more. Here is the
code which I am using right now.

*\definecolor{gray}{gray}{0.5}*
*
*
*\makeatletter*
*\def\inverseverbatim{%*
*  \color{white}\scriptsize*
*  \def\verbatim@processline{%*
*    {\setbox0=\hbox{\the\verbatim@line}%*
*    \hsize=\wd0 \the\verbatim@line\par}}%*
*  \@minipagetrue*
*  \@tempswatrue*
*  \@totalleftmargin\z@*
*  \setbox0=\vbox\bgroup \verbatim*
*}*
*\def\endinverseverbatim{%*
*  \endverbatim*
*  \unskip\setbox0=\lastbox*
*  \egroup*
*  \colorbox{gray}{\box0}%*
*} \makeatother*
*
*
*\begin{inverseverbatim}*
*      auto eth0*
*\end{inverseverbatim}*

So, here what about the border color and all?
Is it proper as per the rules in LaTeX?

On Sat, Jan 29, 2011 at 11:09 AM, Ashish Revar <ashishre...@gmail.com>wrote:

--
*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com
9909298846*

  Latex.jpg
138K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashish Revar  
View profile  
 More options Jan 29 2011, 2:20 am
From: Ashish Revar <ashishre...@gmail.com>
Date: Sat, 29 Jan 2011 12:50:32 +0530
Local: Sat, Jan 29 2011 2:20 am
Subject: Re: Verbatim text with colored background

Hello there,

Sorry for posting again without waiting for any answer from others.
I have found out another way to do this,

*\usepackage{verbatim,framed}*
*\usepackage[usenames,dvipsnames]{color}*
*
*
*\newenvironment{colorverbatim}[1][Gray]%*
*{%*
*\definecolor{shadecolor}{named}{#1}%*
*% supress ugly vertical space which is inserted by*
*% environment above and below text:*
*\topsep=0ex\relax*
*% start shaded and verbatim:*
*\shaded \verbatim \color{White}*
*}%*
*{%*
*\endverbatim*
*\endshaded*
*}%*
*
*
*\begin{colorverbatim}*
*   auto eth0*
*\end{colorverbatim}*
*
*
This environment gives me the output I want, but still black border is
needed.
How to do this?

On Sat, Jan 29, 2011 at 12:38 PM, Ashish Revar <ashishre...@gmail.com>wrote:

--
*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com
9909298846*

  Latex.jpg
138K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gildas Cotomale  
View profile  
 More options Jan 29 2011, 4:36 am
From: Gildas Cotomale <gildas.cotom...@gmail.com>
Date: Sat, 29 Jan 2011 10:36:53 +0100
Local: Sat, Jan 29 2011 4:36 am
Subject: Re: [latexusersgroup] Verbatim text with colored background

> I am trying to make verbatim text may differ from the other text.
> For that, I have defined some commands like below,
> \usepackage{color}
> \definecolor{gray}{gray}{0.5}

Sound ok exept that i won't use a name that is also a keyword and that
is meanless (as you are using grayscale, gray by it's own is a
nonsense; \definecolor{gray50}{gray}{0.5} or
\definecolor{halfgray}{gray}{0.5} sound better imho) My suggestion :
\definecolor{BoxBackground}{gray}{0.1} % 10%
\definecolor{BoxForeground}{gray}{0.9} % 90%
\definecolor{BoxBorderframe}{gray}{0.8} % 80%
\fcolorbox{BoxBorderframe}{BoxBackground}{
\color{BoxForeground} % the default text color (black) is not changed,
we had to specify the desired one if we want something else (then no
need with the default black excep if the hole is chanfed previousely)
... now comes your text :)

}
> \fcolorbox{gray}{gray}%
>   {\color{white}
> \begin{verbatim}
> euca-bundle-image -i <kernel file> --kernel true
> euca-upload-bundle -b <kernel bucket> -m /tmp/<kernel file>.manifest.xml
> euca-register <kernel-bucket>/<kernel file>.manifest.xml
> \end{verbatim}
>  }

> But this shows an error, I want something like this, black text, gray BG and black border.

I didn't test it but maybe color package don't know the color name
"white" ? I used to use those names too, but I always instruct the
package that I want to use some basic/common friendly names so:
\usepackage[usenames,dvipsnames]{color} %
http://en.wikibooks.org/wiki/LaTeX/Colors#The_68_standard_colors_know...
Please consider reading the package documentation (command line: texdoc color)

You may consider using the package Fancy Verbatim too (also read the
documentation)
\usepackage{fancyvrb}
\usepackage{color}
% don't forget to define your needed colors..
...
\colorbox{BoxBackgroud}{ % this trick is required because there's no
option provided for that, but you may redefine some internals used by
Verbatim if you wisth ;)
\begin{Verbatim}[frame=single, fillcolor=BoxBackground,
formatcom=\color{BoxForeground}]
% the frame use the same color as the text, otherwise add the option
rulecolor=\color{BoxBorderframe} in the list too.
\end{Verbatim}
% beware: "Verbatim" (capital v) instead of "verbatim"

}

Another solution.. listing package
\usepackage{fancyvrb}
\usepackage{color}
% don't forget to define your needed colors..
...
\lstset{language=bash, backgroundcolor=\color{BoxBackgroud},
rulecolor=\color{BoxBorderframe} }
\textcolor{BoxForeground}{ % use this trick if you don't want to use
defautlt text color and don't have time to tweek each class
ofwords/tokens used by the language ;)
\begin{lstlisting}[frame=single]
% put your listing here
\end{lstlisting}

}

Best regards

--
http://www.math.harvard.edu/computing/latex/color.html
http://mirror.ctan.org/macros/latex/contrib/xcolor/xcolor.pdf
http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/fancyvr...
http://kom.aau.dk/group/02gr506/diverse/guide%20to%20fancyvrb.pdf
ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/listings/listing...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Flynn  
View profile  
 More options Jan 29 2011, 6:56 am
From: Peter Flynn <anglebrac...@gmail.com>
Date: Sat, 29 Jan 2011 11:56:12 +0000
Local: Sat, Jan 29 2011 6:56 am
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

Use fancyvrb and fancybox. It means an extra pair of lines but gives you *
much* better control.
Also, use xcolor, not color

\documentclass{article}
\usepackage{fancyvrb,fancybox}
\usepackage[svgnames]{xcolor}
\newenvironment{colframe}{%
  \begin{Sbox}
    \begin{minipage}{.8\columnwidth}

}{%

  \end{minipage}
  \end{Sbox}
  \begin{center}
    \fcolorbox{black}{LightSteelBlue}{\TheSbox}
  \end{center}
}

\begin{document}
\begin{colframe}
\begin{Verbatim}{frame=single}
   auto eth0
\end{Verbatim}
\end{colframe}
\end{document}

The problem with the verbatim environment is that the line \end{verbatim} *
must* occur exactly as-is *in the document*, not in a macro. The verbatim
package tries to overcome this restriction, but adds some of its own. The
Verbatim (capital V) environment from fancyvrb still has that restriction,
but has options for a frame and a lot of other bells and whistles. The
fancybox package provides the Sbox environment which lets you capture
material into a box which you can then frame and colour yourself as the
\TheSbox.

///Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashish Revar  
View profile  
 More options Jan 29 2011, 12:35 pm
From: Ashish Revar <ashishre...@gmail.com>
Date: Sat, 29 Jan 2011 17:35:57 +0000
Local: Sat, Jan 29 2011 12:35 pm
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

Thank you all,
But I am having report class not article.

As well as I have tried this fancyverb package but this shows error in
itemize...somehow, which can't figure out, why?
It prompts the error with the line that already defined or somewhat which
means \item is being conflicted by using this fancyverb package in report
class.

Any guess to use this in report class?

On Sat, Jan 29, 2011 at 11:56 AM, Peter Flynn <anglebrac...@gmail.com>wrote:

--
*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com
9909298846*

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Flynn  
View profile  
 More options Jan 29 2011, 5:28 pm
From: Peter Flynn <anglebrac...@gmail.com>
Date: Sat, 29 Jan 2011 22:28:48 +0000
Local: Sat, Jan 29 2011 5:28 pm
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

On Sat, Jan 29, 2011 at 5:35 PM, Ashish Revar <ashishre...@gmail.com> wrote:
> Thank you all,
> But I am having report class not article.

I don't understand the problem. What I wrote works in any class. Just copy
and paste it into a report.

> As well as I have tried this fancyverb package but this shows error in
> itemize...somehow, which can't figure out, why?

Because I make the box too wide (.85\columnwidth). I changed it (see below)
so that it automatically adapts to fit the available space (I hope). I added
the calc package so it could work this out.

> It prompts the error with the line that already defined or somewhat which
> means \item is being conflicted by using this fancyverb package in report
> class.

Nothing to do with it.

> Any guess to use this in report class?

The error has nothing to do with the report class.

\documentclass{report}
\usepackage{fancyvrb,fancybox,calc}
\usepackage[svgnames]{xcolor}
\newenvironment{colframe}{%
  \begin{Sbox}
    \begin{minipage}
      {\columnwidth-\leftmargin-\rightmargin-2\fboxsep-2\fboxrule-4pt}

}{%

  \end{minipage}
  \end{Sbox}
  \begin{center}
    \fcolorbox{black}{LightSteelBlue}{\TheSbox}
  \end{center}
}

\begin{document}
This is an example of using it in a report
\begin{itemize}
  \item To make networking start on boot, type
    \begin{colframe}
      \begin{Verbatim}{frame=single}
   $ auto eth0
\end{Verbatim}
    \end{colframe}
  \item To get rid of a bogus \texttt{eth0} device left over from a
    wired connection when your wireless fires up \texttt{eth1}, type
    \begin{colframe}
      \begin{Verbatim}{frame=single}
   $ ifconfig eth0 down
\end{Verbatim}
    \end{colframe}
  \item Happy \LaTeX ing!
\end{itemize}
\end{document}

 ///Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashish Revar  
View profile  
 More options Jan 31 2011, 1:19 am
From: Ashish Revar <ashishre...@gmail.com>
Date: Mon, 31 Jan 2011 11:49:11 +0530
Local: Mon, Jan 31 2011 1:19 am
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

Thanks Peter,

For colored background and all, we are using fancyverb and others packages.
If I want the same thing for itemize (Lists) or maybe for any matrix or
array, then what to do?

Is there any document related to this?
As I want to study the SBox and Minipage which you have coded in last reply.
Can you please explain that code if possible?

--
*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com
9909298846*

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Flynn  
View profile  
 More options Jan 31 2011, 5:45 am
From: Peter Flynn <anglebrac...@gmail.com>
Date: Mon, 31 Jan 2011 10:45:20 +0000
Local: Mon, Jan 31 2011 5:45 am
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

On Mon, Jan 31, 2011 at 6:19 AM, Ashish Revar <ashishre...@gmail.com> wrote:
> Thanks Peter,

> For colored background and all, we are using fancyverb and others packages.
> If I want the same thing for itemize (Lists) or maybe for any matrix or
> array, then what to do?

The same:

\begin{colframe}
  \begin{itemize}
    \item foo
    \item bar
    \item blort
  \end{itemize}
\end{colframe}

 Is there any document related to this?


http://latex.silmaril.ie/formattinginformation/macros.html#macenv

> As I want to study the SBox and Minipage which you have coded in last
> reply.
> Can you please explain that code if possible?

Read The Fine Manual
http://tug.ctan.org/tex-archive/macros/latex/contrib/fancybox/fancybo...

///Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashish Revar  
View profile  
 More options Apr 19 2011, 4:46 am
From: Ashish Revar <ashishre...@gmail.com>
Date: Tue, 19 Apr 2011 14:16:35 +0530
Local: Tues, Apr 19 2011 4:46 am
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

Hello there,

I finally found out the problem which was preventing my file to successful
output. In our institute format textwidth  was predefined using below
command.

\renewcommand{\textwidth}{6in}

So, I have then commented that line and now it is working. But I want to
know that, what was the problem here?

On Tue, Apr 19, 2011 at 11:01 AM, Ashish Revar <ashishre...@gmail.com>wrote:

--
*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com*
* <ashishre...@gmail.com>DreamLab | Technical Solutions<http://dreamlab.co.cc/>
9909298846*

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashish Revar  
View profile  
 More options Apr 19 2011, 1:31 am
From: Ashish Revar <ashishre...@gmail.com>
Date: Tue, 19 Apr 2011 11:01:34 +0530
Local: Tues, Apr 19 2011 1:31 am
Subject: Re: [latexusersgroup] Re: Verbatim text with colored background

Hello there,

Solution given by Peter was working fine in my previous report. But this
time I am using this with my final report it making some conflicts. Below
are the packages which I have used in report.

\documentclass[12pt,a4paper]{report}

\usepackage[pdftex]{graphicx}
\DeclareGraphicsExtensions{.pdf,.jpeg,.png}
\usepackage{amsthm,amssymb} % for mathematical formulas
\usepackage{rotating} %used to have landskape figures
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{epsfig}

%\usepackage{algorithms}
%\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage{pseudocode}
%\usepackage{fancybox}
%\usepackage{mathpazo} %for good font

\usepackage{subfigure}
%\usepackage{slashbox}
\usepackage{pict2e}
\usepackage{makeidx}
%\usepackage{subfig}
\usepackage{multirow}
\usepackage{nomencl}
   % to have links to figures and citations in PDF version.
\usepackage{hyperref}
\usepackage{setspace}

\usepackage{sectsty,fix-cm}
\usepackage[svgnames]{xcolor}

\usepackage{fancyvrb,fancybox,calc}

\newenvironment{colframe}{%
  \begin{Sbox}
    \begin{minipage}
      {\columnwidth-\leftmargin-\rightmargin-2\fboxsep-2\fboxrule-4pt}

}{%

  \end{minipage}
  \end{Sbox}
  \begin{center}
    \fcolorbox{black}{LightSteelBlue}{\TheSbox}
  \end{center}

}

I have another tex file which is included like this way...
\flushbottom
\include{ProposedArch}
\flushbottom

which contains the code like it...
\begin{Verbatim}{frame=single}
   $ ifconfig eth0 down
\end{Verbatim}
    \end{colframe}

but it shows the error,
! Missing number, treated as zero.
<to be read again>
\let
1.5 \begin{colframe}
?

What is the problem? Which packages are being crashed with each other? I
have no idea, I have done minimal examples.

--
*Thanks and Regards,*
*Ashish Revar,*
*Nirma University,
ashishre...@gmail.com*
* <ashishre...@gmail.com>DreamLab | Technical Solutions<http://dreamlab.co.cc/>
9909298846*

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »