[Tex/LaTex] \newenvironment issues with environment comment

boxescommentsmemoir

I am trying to setup the formatting for a LaTeX document (it's got the class memoir), so that it would be fairly simple to add to it in the future.

Two of the features I'd like are:
Be able to mark certain parts of the text, so that I can produce two versions of the output, one with the complete text, and one without the marked parts of the text. My original idea was to use:

\newenvironment{\marked}{\begin{comment}}{\end{comment}}

and then just change it to

\newenvironment{\marked}{}{}

when I want the full text. However this won't work unless I add a comment block (\begin{comment}…\end{comment}) after I use the marked environment.

To have boxed areas of text. I can achieve this though using:

\begin{center}
    \colorbox{yellow}{
        \parbox{0.8\textwidth}{
            ...text here...
        }
    }
\end{center}

I would like to create another environment for this, but I'm not sure how to go about it as the text to be contained within the environment will be between open parentheses.

Also – how would I go about adding padding to the inside of my box?

I'm sorry if these questions are overly simple. The only languages I've used before to format stuff are HTML and CSS.

Best Answer

The memoir class has a facility just for that:

\newcomment{marked}
\commentson{marked}
%\commentsoff{marked}

It's sufficient to uncomment the third line to exclude the contents of all marked environments. Look at page 284 of memoir's documentation.

For the environment form of a colored background box:

\newsavebox{\coloredbgbox}
\newenvironment{yellowbox}
  {\begin{lrbox}{\coloredbgbox}\begin{minipage}{0.8\textwidth}}
  {\end{minipage}\end{lrbox}%
   \begin{center}\colorbox{yellow}{\usebox{\coloredbgbox}}\end{center}}

With this definition, you can write

\begin{yellowbox}
Text to be produced on a yellow background as wide as 80\%
of the normal line width.
\end{yellowbox}

However, it's better to split different topics into different questions.