# Escaping square braces [closed]

I want to use some text as the optional parameter to some command. The text includes square braces ([ and ]), but since the optional parameter goes within square brackets, unexpected things happen.

More info: I want an itemized list whose bullets are citations like [GMR85]. I used this command:

\begin{itemize}
\item[[GMR85]] ...
\end{itemize}


but it takes the first ] as the end of optional parameter.

Any way to escape ] ?

Edit: I specially want this to work in beamer. My current result is like:

Note how ] is not included the label.

## EDIT 2

This bug has been solved in the latest versions of beamer.

-

## closed as off-topic by LaRiFaRi, Mico, barbara beeton, Torbjørn T., JesseJul 19 '15 at 9:14

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Use {description} rather than {itemize} with lexicon-like lists. – Charles Stewart Dec 7 '10 at 13:23
Also, why don't you use the bibliography environment? – Caramdir Dec 7 '10 at 17:51
@Caramdir: I always use the bibliography environment, but let's just say that there are technical reasons I don't want to do that now. (It's a long story!). As a short answer, you can just assume that I want an enumerate listing whose labels include brackets. (while they aren't citations.) – M.S. Dousti Dec 7 '10 at 18:26
@Charles: Sorry, but even {description} environment does not work in the beamer. (Screenshot: s1.bild.me/bilder/311010/1151044untitled.PNG) – M.S. Dousti Dec 7 '10 at 18:37
I'm voting to close this question as off-topic because this problem has been fixed in a newer version of beamer. – LaRiFaRi Jul 19 '15 at 7:57

group the citation...

\documentclass{article}
\begin{document}

\begin{itemize}
\item[{[GMR85]}] ...
\end{itemize}
\end{document}


The Beamer package makes things a little bit more difficult.

\documentclass{beamer}
\begin{document}

\def\braces#1{[#1]}

\begin{frame}{frame title}
\begin{itemize}
\item[\braces{GMR95}] ...
\end{itemize}
\end{frame}

\end{document}


This works fine for me.

-
Thanks Matten, but it does not work either (I tried) – M.S. Dousti Dec 7 '10 at 13:01
It does not work? I'll put a complete example in my answer, I have compiled it and it works fine for me... – Matten Dec 7 '10 at 13:04
itemize will cause the bullet cross beyond the left margin. See my answer (not really answer actually, just a comparison) :-) – xport Dec 7 '10 at 17:43
@Matten: Sorry, I should have described more. I'm using it in a beamer slide, and it does not work in that case (but works fine when you use the article documentclass). Can you test it in the beamer too? (screenshot of my result: s1.bild.me/bilder/311010/1151044untitled.PNG). – M.S. Dousti Dec 7 '10 at 18:35
hey Sadeq.. I supplied another approach for your beamer problem. Please see my second code example! – Matten Dec 7 '10 at 18:55

Based on Charles Stewart's comment and Matten's answers, I make the following comparion. I suggest to follow the Stewart's suggestion. If we insist on using itemize environment instead of description, the bullet item will expands to the left crossing the left margin.

\documentclass[dvipsnames]{article}
\usepackage{xcolor}
\usepackage[showframe=true,margin=30mm]{geometry}
\usepackage{showexpl}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\SX@codeInput}{xleftmargin=0pt,xrightmargin=0pt}{}
{\typeout{***Successfully patched \protect\SX@codeInput***}}
{\typeout{***ERROR! Failed to patch \protect\SX@codeInput***}}
\makeatother
\lstset{%
literate={ï}{}0
{»}{}0
{¿}{}0,
breaklines=true,
breakindent=0pt,
basicstyle=\ttfamily\scriptsize,
keywordstyle=\color{blue}\sffamily\bfseries,
stringstyle=\rmfamily,
showstringspaces=false,
backgroundcolor=\color{Yellow!30},
frame=single,
framerule=0.4pt,
rulecolor=\color{red},
framesep=3pt,
xleftmargin=3.4pt,
xrightmargin=3.4pt,
tabsize=2,%
explpreset={pos=b}%
}
\begin{document}

\begin{LTXexample}
\begin{description}
\item{[GMR85]} I am happy.
\item{[GMR86]} Are you happy?
\end{description}
\end{LTXexample}

\begin{LTXexample}
\begin{itemize}
\item[{[GMR85]}] I am happy.
\item[{[GMR86]}] Are you happy?
\end{itemize}
\end{LTXexample}

\end{document}

-
paralist also fixes the margin behavior. – Caramdir Dec 7 '10 at 17:53