Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

If I use \\ or $\newline$ in beamer inside a tikzpicture, I get the following error:

Something's wrong--perhaps a missing \item. \end{frame}

What is correct use of it?

My tikz code is as follows:

\documentclass{beamer}
\usepackage{color}
\usepackage{enumerate}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{pgf}
\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{beamerthemesplit}
\usepackage{amsmath,hyperref}
\usetheme{CambridgeUS}
\usecolortheme{whale}
\useoutertheme{infolines}
\useinnertheme{circles}
\usefonttheme[onlylarge]{structuresmallcapsserif}
\setbeamercolor{title}{fg=red!80!black,bg=red!20!white}
\setbeamertemplate{footline}[page number]{}
\setbeamertemplate{navigation symbols}{}

\begin{document}

\begin{frame}{A}
\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=7 cm,
                semithick, scale = 0.4, transform shape]


\node[initial,state] (A)                    {$s_0$};
\node[state]         (B) [above right of=A] {$s_1$};
\node[state]         (C) [below right of=A] {$s_2$};
\node[state]         (D) [below right of=B] {$s_3$};
\node[state]         (E) [above right of=D] {$s_4$};
\node[state]         (F) [below right of=D] {$s_5$};


  \path (A) 
    edge [left] node [blue, pos=0.5, sloped, above] {$0 \rightarrow [x = x.0.0]$} (B)
    edge [left] node [cyan, pos=0.8]{$1 \rightarrow [x = x.0.1]$} (C)(B) 
    edge [loop above] node [align=center] {$0 \rightarrow$ \\ $[x = x.0]$ }   (B)
    edge [bend right,left] node  {$1 \rightarrow [x = x.1]$ }   (C)
    edge [] node [red, pos=0.2] {$\$  \rightarrow  [x = x.0.\$]$ } (D);   

\end{tikzpicture}
\end{frame}



\end{document}
share|improve this question

closed as too localized by percusse, lockstep, morbusg, diabonas, Paul Gaborit Sep 24 '12 at 14:31

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Currently, your code doesn't involve Beamer. Please add a minimal working example that includes all important aspects of the situation. –  Andrew Uzzell Sep 17 '12 at 18:24
    
Once having changed the unknown stealth' arrow tip, your code compiles fine. :) –  Claudio Fiandrino Sep 17 '12 at 18:31
    
Even after removing stealth', I am getting the same error. :( –  tikzlearner Sep 17 '12 at 18:34
4  
Please, could you provide a minimal working examples starting with \documentclass and ending with \end{document}? –  Claudio Fiandrino Sep 17 '12 at 18:41
    
Sorry for that. I have edited the question. –  tikzlearner Sep 17 '12 at 18:47

1 Answer 1

Change the line

edge [loop above] node [align=center] {$0 \rightarrow$ $\\$ $[x = x.0]$ }   (B)

to

edge [loop above] node [align=center] {$0 \rightarrow$ \\ $[x = x.0]$ }   (B)

\\ should not be in math mode, i.e., inside a pair of $\\$.

share|improve this answer
    
Then I got an error as follows: Something's wrong-perhaps a missing \item. \end{frame} –  tikzlearner Sep 17 '12 at 19:00
    
I am able to compile your MWE with the change without any error (just a few warnings about font substitution). –  Guido Sep 17 '12 at 19:06
    
I am still getting the same error :-( –  tikzlearner Sep 17 '12 at 19:11
    
Have you considered using an array? –  Guido Sep 17 '12 at 19:59

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