# Applying commands within custom list environment

I am trying to redefine an enumerate environment that would look something like this in use:

\begint{customItemize}
\item $-6x^{2}-2x=-2x(3x+1)$
\item $-5x+15=-5(x-3)$
\end{customItemize}


And be equivalent to something like this

\begin{enumerate}
\item \fbox{$-6x^{2}-2x=-2x(3x+1)$}
\item \fbox{$-5x+15=-5(x-3)$}
\end{enumerate}


In addition to \fbox, I might like to be able to use other (custom) commands. It is important that this happens within the environment, so that the

\item Some stuff
\item Some more stuff


part of the code is easily copy/pasted to other list environments.

Can this be done?

I've tried something like this, but it's not working and I think it is because I don't know how to deal with parameters of \item.

\newenvironment{customItemize}{%
\let\olditem\item%
\renewcommand\item[2]{ \olditem\fbox{##2} }%
\begin{enumerate}}{\end{enumerate}%
}


Math mode is breaking somehow within fbox... but I'm kinda clueless as to how to proceed. Again, I think it is something that I don't understand about the "arguments" for \item

-

## migrated from stackoverflow.comFeb 21 '13 at 14:15

This question came from our site for professional and enthusiast programmers.

The problem isn't with the math mode. It is with the fbox. The way \item traditionally works is to put some sort of identifying blivet at the head of the line, and then the text that follows the \item is printed. But to use an fbox, you need all of that text to be an argument to \fbox, meaning, enclosed in braces {}. Without the braces, only a the first character of the text is taken as the argument to \fbox, which is not what you want. (I also corrected a typo in your environment definition). So, the way to do it is enclose the text of the item in braces {}. This will make your environment work, and (while non-standard) won't break from being copied and pasted into another environment. I show it below, with both items (non-math and math) being placed first in your environment, and then in the normal itemize environment.

\documentclass{article}
\newenvironment{customItemize}{%
\let\olditem\item%
\renewcommand\item[1]{ \olditem\fbox{##1} }%
\begin{enumerate}}{\end{enumerate}%
}

\begin{document}
Here we go
\begin{customItemize}
\item {Testing}
\item {$y = x^2$}
\end{customItemize}

\begin{itemize}
\item {Testing}
\item {$y = x^2$}
\end{itemize}

\end{document}

-