LaTeX forum ⇒ OthersHow to resolve the error: “Missing { inserted” in WriteLatex Topic is solved

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

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

Postby FernandoRAJ » Wed Sep 10, 2014 11:49 pm

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

  1. \begin{algorithm}
  2. \uIf{$|F_d(D'(C_{\hat{i}})) - F_d(D(C_{\hat{i}}))| > \sigma$ OR numSeqNoise > $\mu$}{
  3. SplitCluster($C_j$)\;
  4. }
  5. \uElseIf{$|F_d(D'(C_{\hat{i}})) - F_d(D(C_{\hat{i}}))| > \tau$}{
  6. numSeqNoise++\;
  7. }
  8. \uElseIf{$j \neq \hat{i}$}{
  9. Remove $S_{R}$ from cluster $C_j$\;
  10. Place $S_{R}$ in cluster $C_\hat{i}$\;
  11. }\uElse{
  12. Replace $S_{R}$ in cluster $C_\hat{i}$\;
  13. }
  14. \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? ;)

User avatar
Johannes_B
Site Moderator
Posts: 3582
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 11, 2014 12:11 am

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

Postby FernandoRAJ » Thu Sep 11, 2014 12:51 am

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: 3582
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 11, 2014 9:35 am

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
  1. \documentclass{article}
  2. \usepackage{algorithm2e}
  3. \begin{document}
  4. \begin{algorithm}
  5. \uIf{$|F_d(D'(C_{\hat{\imath}})) - F_d(D(C_{\hat{\imath}}))| > \sigma$
  6. %\textup{\bfseries
  7. OR
  8. %}
  9. $\mathrm{numSeqNoise} > \mu$}{
  10. SplitCluster($C_j$)\;
  11. }
  12. \uElseIf{$|F_d(D'(C_{\hat{\imath}})) - F_d(D(C_{\hat{\imath}}))| > \tau$}{
  13. numSeqNoise++\;
  14. }
  15. \uElseIf{$j \neq \hat{\imath}$}{
  16. Remove $S_{R}$ from cluster $C_j$\;
  17. Place $S_{R}$ in cluster $C_{\hat{\imath}}$\;
  18. }\uElse{
  19. Replace $S_{R}$ in cluster $C_{\hat{\imath}}$\;
  20. }
  21. \end{algorithm}
  22. \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: 8523
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Sep 15, 2014 2:49 pm

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 3305 times


If you would have further questions, let us know.

Stefan
Site admin


Return to “Others”

Who is online

Users browsing this forum: No registered users and 1 guest