Closed jkuczm closed 8 years ago
Instead of \colorbox
you can use an environment, for example tcolorbox.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=2cm]{geometry}
\usepackage{mmacells}
\usepackage{tcolorbox}
\begin{document}
\mmaSet{morefv={gobble=2}}
\mmaDefineMathReplacement{ρ}{\rho}
\mmaDefineMathReplacement{λ}{\lambda}
\begin{tcolorbox}[colback=black!5!white,sharp corners,boxrule=0pt]
\begin{mmaCell}[morepattern={z, z_}]{Input}
\mmaDef{ρ}[z_] := \mmaSub{ρ}{0} z Exp[-\mmaUnd{λ} Abs[z]]
\end{mmaCell}
\end{tcolorbox}
\end{document}
If you want to use boxed cell more than once, you could define your own boxedMmaCell
environment. Since mmaCell
is a verbatim-like environment based on fancyvrbs Verbatim
, we need to use \VerbatimEnvironment
command when defining new mmaCell
-based environments.
\newenvironment{boxedMmaCell}[2][]
{%
\VerbatimEnvironment%
\begin{tcolorbox}[colback=black!5!white,sharp corners,boxrule=0pt]%
\begin{mmaCell}[#1]{#2}%
}
{%
\end{mmaCell}%
\end{tcolorbox}%
}
\begin{boxedMmaCell}[morepattern={z, z_}]{Input}
\mmaDef{ρ}[z_] := \mmaSub{ρ}{0} z Exp[-\mmaUnd{λ} Abs[z]]
\end{boxedMmaCell}
Wow, many thanks! Works perfect.
In #20 @Nithilher wrote:
I have one small request. I would like to set the Input Code of mathematica in borderless boxes of full width (\ŧextwidth) with a light gray as background color. However, when putting your code within
\colorbox{bg}{...}
, I get an error:yields
Is there a simple way to achive this?