OthersHow to resolve the error: “Missing { inserted” in WriteLatex

Information and discussion about other LaTeX editors not listed above
Post Reply
FernandoRAJ
Posts: 2
Joined: Wed Sep 10, 2014 11:42 pm

How to resolve the error: “Missing { inserted” in WriteLatex

Post by FernandoRAJ »

When I use ShareLatex or MikTex to compile the following Latex code:

Code: Select all

   \begin{algorithm}
        \uIf{$|F_d(D'(C_{\hat{i}})) - F_d(D(C_{\hat{i}}))| > \sigma$ OR numSeqNoise > $\mu$}{
  	      SplitCluster($C_j$)\;
        } 
        \uElseIf{$|F_d(D'(C_{\hat{i}})) - F_d(D(C_{\hat{i}}))| > \tau$}{
  	      numSeqNoise++\;
        } 
  	    \uElseIf{$j \neq \hat{i}$}{
  		    Remove $S_{R}$ from cluster $C_j$\;
  		    Place $S_{R}$ in cluster $C_\hat{i}$\;
  	     }\uElse{
    	    Replace $S_{R}$ in cluster $C_\hat{i}$\;
         }
    \end{algorithm}
it compiles normally, but when I try to use WriteLatex, then the following error always happens:
Missing { inserted.
<to be read again>
\gdef
l.485 }
\uElse{
The line where the error is pointed out is "}\uElse{".

Somebody can help me? ;)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to resolve the error: “Missing { inserted” in WriteLatex

Post by Johannes_B »

This seems to be a crosspost to How to resolve the error: “Missing { inserted.” inside an algorithm2e.

Please read what our administrator thinks about crossposts -> Gimme Pizza.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
FernandoRAJ
Posts: 2
Joined: Wed Sep 10, 2014 11:42 pm

Re: How to resolve the error: “Missing { inserted” in WriteL

Post by FernandoRAJ »

Thank you, very much, for answers! It works!!
I would like to apologize for my mistake, but I will not do (crosspost) again.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to resolve the error: “Missing { inserted” in WriteLatex

Post by Johannes_B »

Crossposts are ok for me, but please cross reference the posts so a helper can check the progress.

Henri Menke already solved your problem, it was a missing pair of braces (C_{\hat{\imath}}). His tip of using imath to produce a dotless i is a very good one. He made some more improvements to your code, for example setting »numSeqNoise« upright in the first line and including the binary oparator > in the math-environment. Otherwise it is a textual > with the corresponding spacing which wouldn't make much sense.

You might even want to typeset the OR upright and maybe even bold.


Here is Henris code for future reference

Code: Select all

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}
  \uIf{$|F_d(D'(C_{\hat{\imath}})) - F_d(D(C_{\hat{\imath}}))| > \sigma$ 
%\textup{\bfseries 
OR
%} 
$\mathrm{numSeqNoise} > \mu$}{
    SplitCluster($C_j$)\;
  } 
  \uElseIf{$|F_d(D'(C_{\hat{\imath}})) - F_d(D(C_{\hat{\imath}}))| > \tau$}{
    numSeqNoise++\;
  } 
  \uElseIf{$j \neq \hat{\imath}$}{
    Remove $S_{R}$ from cluster $C_j$\;
    Place $S_{R}$ in cluster $C_{\hat{\imath}}$\;
  }\uElse{
    Replace $S_{R}$ in cluster $C_{\hat{\imath}}$\;
  }
\end{algorithm}
\end{document}
Hint, you can click on »open in writelatex« to see the output.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How to resolve the error: “Missing { inserted” in WriteLatex

Post by Stefan Kottwitz »

Hi Fernando,

welcome to the forum!

I tested you code too. Nice suggestion to use a dot less i with the hat, otherwise the hat should be shifted.

To have a look at the output (we like screenshots too :) )
algorithm.png
algorithm.png (30.78 KiB) Viewed 95986 times
If you would have further questions, let us know.

Stefan
LaTeX.org admin
Post Reply