I am using pandoc to convert Markdown documents containing code blocks to PDF, and the intermediate TeX surrounds the code with \begin{verbatim}...\end{verbatim}. How can I stylize and format these sections to have a background color or a frame around it? I've tried fancyvrb, but the background color does not extend behind the text itself.
I've tried using the verbatim package and after reading the manual was able to modify \verbatim@processline to change the font color or add text in front of each line: \def\verbatim@processline{\fbox{\$ \the\verbatim@line}\par}. I would like to this for the entire chunk and modify other properties (frame, centering, etc) in the future. I thought the best way to do this would be to add a \begin{shaded} into \verbatim and add \end{shaded} into endverbatim. However, I run into an error when I do that:
\makeatletter
\def\verbatim{{\begin\{shaded\}}\begingroup\@verbatim
\frenchspacing\@vobeyspaces\verbatim@start}
\def\endverbatim{\endtrivlist\endgroup{\end\{shaded\}}}
\makeatother
And the error message:
! Missing \endcsname inserted.
<to be read again>
\protect
l.1 \begin{verbatim}
- Is there a way to insert enclose the verbatim text in an environment that I can stylize later?
- If not, is there a better way of stylizing the
verbatimenvironment? I cannot change tolistingsor similar packages that use\begin{lstlisting}since pandoc automatically inserts\begin{verbatim}?
MWE:
\documentclass{beamer}
\usepackage{xcolor, framed}
\definecolor{shadecolor}{RGB}{255,0,0}
\begin{document}
\begin{frame}[fragile]
\begin{verbatim}
Shade this text block
Shade this too
\end{verbatim}
\begin{shaded}
\begin{verbatim}
Shaded text here
And also here
\end{verbatim}
\end{shaded}
\end{frame}
\end{document}
verbatimenvironment? For example, are you using any particular characters that are otherwise disallowed? Or are you merely interested in atypewriterstyle formatting of the text? – Werner Mar 15 '18 at 23:30verbatimenvironment when converting from Markdown – Chris Mar 15 '18 at 23:32verbatimin the preamble that Pandoc lets you add.) – ShreevatsaR Mar 16 '18 at 00:34--listingsargument while calling pandoc which uses the listings package instead ofverbatimand that helped my issue a lot! – Chris Apr 18 '18 at 03:12