I'd like to redefine the \verb|...|
command so that it had a light-gray background and a little bit darker border around it, and a little bit of padding to make this background "box" noticable. Anyone knows how to do that? If that is not possible to do easily, can I define a new command that acts like \verb|...|
and does that?
[Tex/LaTex] How to redefine the \verb|…| command
colormacrosverbatim
Best Answer
Update 2011-07-27
As promised the new version of my
newverbs
package provides two macros to collect verbatim arguments with the\verb|...|
syntax but also with{ .. }
. For typesettable verbatim use\collectverb{\macrowhichgetsitasargument}
.For the requested colored background and frame use the
\fcolorbox{<frame color>}{<background color>}{<text>}
macro.The
newverbs
package allows you to define variations of the\verb
command which code placed before and after it. You need to use a savebox for advanced formatting. (I'm planning to also support macros which receive the verbatim text as normal argument in the next version.)Example:
Use the
xcolor
package to add colors.The package already provides
\fverb
(draws a\fbox
around it) and\qverb
(adds quoting signs) by default.You could also use the
\verb
-like\lstinline
macro of thelistings
package. It accepts the manylistings
options.