views:

316

answers:

3

The following latex does not compile because of the "[" after the "\item". I presume it is because LaTeX expects a "]" as per the "\item[option]" syntax. However, I just want to insert the "[" character into the text as the first character of the enumerated item.

\documentclass[oneside,12pt]{article}

\begin{document}

\begin{enumerate}

\item before

\item [ random text

\item after

\end{enumerate}

\end{document}

I would like the LaTeX to generate a document:

before

[ random text

after

One way I've come up with is to put a "\ " in front of the "[", however I'd appreciate thoughts on the least invasive way to do this.

Thanks!

A: 

You can't use [, it won't work.

The [ is a recognized command in LaTeX, but only within the math environment. So you need

\item $[$ random text
Uri
This may result in the choice of the wrong font.
starblue
I think Sykora's answer solves the font problem, so I'm marking that as the answer. $[$ is definitely a viable solution, though.
Brian M. Hunt
I don't know why this answer is being modded down. It works for me.
Brian M. Hunt
[ is not a command in LaTeX. It is not even a command in math mode. It's not a character with an category code. If the character immediately after the \item command is [, then \item branches and does something else first, otherwise it just continues outputting text.
dreamlax
+11  A: 

Just like whenever you want to put a special character (such as a space, or something else) after a command, you can use the {} to supress the next character.

\item{}[your random text
sykora
Another option is to insert some other command, such as \relax (which does nothing at all) between \item and the bracket.
Jouni K. Seppänen
A: 

I type it the following way \item[\mbox{$[0,1]$}]

L. Gawarecki