2

I want to define an environment to format test directions. So I do this:

\documentclass{minimal}
\usepackage{lipsum}

\newenvironment{directions}
{   
    \noindent \fbox{    
    \begin{minipage}[t]{\textwidth}
}
{       
    \end{minipage}
}
}

\begin{document}

    \begin{directions}

        \lipsum[1]

    \end{directions}

\end{document}

Text in that environment does not appear in the compiled document, and I get a forgotten \endgroup error (and also an extra } inserted error). I'm pretty sure I've closed all the braces; where did I go wrong?

  • 1
    What are the brackets }{ in minipage supposed to match? After commenting them out, the example compiles. – homocomputeris Dec 21 '18 at 13:50
5

your \framebox is not properly closed. in the first part of new environment you should collect content of new environment in some \savebox and than it use in the second part inside of \framebox. see the following example:

\documentclass{minimal}
\usepackage{lipsum}

    \newsavebox\directbox
\newenvironment{directions}
    {
    \begin{lrbox}{\directbox}
    \begin{minipage}{\linewidth}
    }{
    \end{minipage}\end{lrbox}
    \framebox{\usebox\directbox}
      }


\begin{document}
    \begin{directions}
        \lipsum[1]
    \end{directions}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.