Quantcast
Channel: How can I put every `verbatim` environment inside a `Shaded` environment by changing the preamble only? - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 4

How can I put every `verbatim` environment inside a `Shaded` environment by changing the preamble only?

$
0
0

Unfortunately, I have a lot of TeX code which should look different that it does not, but I cannot modify its code body. However, I can modify the preamble and for example, I have learned that I can redefine \texttt to make every

\texttt{text}

into

\colorbox{shadecolor}{\texttt{text}}

by running

\let\oldtexttt\texttt\renewcommand{\texttt}[1]{\colorbox{shadecolor}{\oldtexttt{#1}}}

in the preamble. That might not be perfect, but it works great. However, now I want to put every verbatim environment inside a Shaded environment. Obviously I cannot use \renewcommand for this again. Is there something else I can use to make every

\begin{verbatim}text\end{verbatim}

into

\begin{Shaded}\begin{verbatim}text\end{verbatim}\end{Shaded}

by changing the preamble only?

Screenshots:

What it looks like:

screenshot

What it should look like:

screenshot

MCVE:

\documentclass[12pt]{article}\usepackage{xcolor}\usepackage{framed}\definecolor{shadecolor}{RGB}{200,200,0}\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}\begin{document}\begin{verbatim}text\end{verbatim}\end{document}

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images