TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

And be equivalent to something like this

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

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.

                \renewcommand\item[2]{ \olditem\fbox{##2} }%

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

share|improve this question

migrated from stackoverflow.com Feb 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.

                \renewcommand\item[1]{ \olditem\fbox{##1} }%

Here we go
\item {Testing}
\item {$y = x^2$}

\item {Testing}
\item {$y = x^2$}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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