# How to use \scalebox around my environment?

I tried putting scalebox{.2} while defining my new environment, but it is not being applied:

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}

\usepackage{graphicx}

\makeatletter

\newenvironment{myenvironment}[0]
{scalebox{.2}\{myenvironment start\par\verbatim}
{\endverbatim\endgraf myenvironment end\}}

\makeatother

\begin{document}

\begin{myenvironment}
test
\end{myenvironment}

\end{document}


How to use \scalebox around my environment?

• – user Aug 21 '17 at 15:46

Two ways to do this with the verbatimbox package. Note that approach two requires a scalable font, which is why I added the lmodern package.

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}

\usepackage{graphicx,verbatimbox}

\begin{document}

\begin{verbbox}
test
of my
\%\@# verbatim stuff
\end{verbbox}
\noindent\scalebox{.2}{\theverbbox}

versus normal size

\begin{verbnobox}[\fontsize{2pt}{2.5pt}\selectfont]
test
of my
\%\@# verbatim stuff
\end{verbnobox}

Back to normal
\end{document}


• Thanks, but when I use the font size directive I got these warnings depending on the font size: LaTeX Font Warning: Font shape T1/cmtt/m/n' in size <2> not available(Font) size <5> substituted on input line 94. However while using the scalebox it does not show these things. – user Aug 21 '17 at 14:34
• @user Note that I added \usepackage{lmodern} to the preamble. – Steven B. Segletes Aug 21 '17 at 14:58
• Thanks! I added it to my preamble and fixed the warnings. – user Aug 21 '17 at 15:08

Or use the environ package.

\documentclass{article}

\usepackage{graphicx}
\usepackage{environ}

\NewEnviron{test}{%
\scalebox{5}{\BODY}}

\begin{document}
This is nuts
\begin{test}
This is nuts
\end{test}

\end{document}

• While the OP's question did not use the words, his/her MWE indicated verbatim content. – Steven B. Segletes Aug 21 '17 at 14:33
• Ah, hadn't noticed that... – JPi Aug 21 '17 at 14:35
• Well, this works with not font size warnings, but I could not put the verbatim on it. I tried: \NewEnviron{myenvironment}{\scalebox{.2}{\par\verbatim \BODY \endverbatim\endgraf}}` – user Aug 21 '17 at 14:37
• Ha, just came across this question: tex.stackexchange.com/questions/51239/… Seems to answer yours. – JPi Aug 21 '17 at 14:39