# [Tex/LaTex] Making the font size smaller in this mdframed, and turning into a reusable environment

environmentsfontsizemdframedtabbing

I am very close to getting the mdframed setting that I want:

\documentclass[a4paper,10pt]{book}

\usepackage[paper=a4paper,twoside=true,lmargin=4cm,
rmargin=4cm,bindingoffset=0cm]{geometry}

\usepackage{mdframed}

\begin{document}

\noindent Surrounding text.

\begin{mdframed}
\begin{tabbing}
some great \=code\\
\>next line
\end{tabbing}
\end{mdframed}

\noindent Surrounding text.

\end{document}


Two questions:

1. How do I make the font size within the mdframed environment \small?

2. How can I turn this into a reusable environment, such that I won't have to begin and end both the mdframed and tabbing environments every time?

Another approach without additional packages is to define a new environment; in the following example, the environment myenv does what you want and hasan optional argument to pass options to mdframed:

\documentclass[a4paper,10pt]{book}
\usepackage[framemethod=tikz]{mdframed}

\newenvironment{myenv}[1][]
{\begin{mdframed}[font=\small,#1]\begin{tabbing}}
{\end{tabbing}\end{mdframed}}

\begin{document}

\noindent Surrounding text.

\begin{myenv}
some great \=code\\
\>next line
\end{myenv}

\noindent Surrounding text.

\begin{myenv}[backgroundcolor=red!20]
some great \=code\\
\>next line
\end{myenv}

\end{document}