I want to write an algorithm in overleaf, but it comes up with errors [duplicate]












0
















This question already has an answer here:




  • i want to write an algorithm but things went wrong

    1 answer




begin{document}
usepackage{savesym}
usepackage{program}
savesymbol{AND}
savesymbol{OR}
savesymbol{NOT}
savesymbol{TO}
savesymbol{COMMENT}
savesymbol{BODY}
savesymbol{IF}
savesymbol{ELSE}
savesymbol{ELSIF}
savesymbol{FOR}
savesymbol{WHILE}


usepackage{algorithm}
usepackage{algorithmic}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}[1]
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}









share|improve this question















marked as duplicate by Stefan Pinnow, JouleV, samcarter, Kurt, Raaja Mar 9 at 19:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Your code is not compileable !

    – AndréC
    Mar 9 at 11:08











  • @AndréC i have forgot the end {document}

    – Iftikhar Ahmad
    Mar 9 at 11:12








  • 1





    First a document class, then loading packages, then begin the document and now you can start the algorithm.

    – Johannes_B
    Mar 9 at 11:12











  • @IftikharAhmad You can modify your question by clicking on the edit button

    – AndréC
    Mar 9 at 11:15






  • 2





    I am a bit confused. This isthe code from here tex.stackexchange.com/questions/456586/…, you just changed things, which are obviously responsible for the errors. Why don't you just go back to the answer Werner posted back then?

    – sheß
    Mar 9 at 14:41
















0
















This question already has an answer here:




  • i want to write an algorithm but things went wrong

    1 answer




begin{document}
usepackage{savesym}
usepackage{program}
savesymbol{AND}
savesymbol{OR}
savesymbol{NOT}
savesymbol{TO}
savesymbol{COMMENT}
savesymbol{BODY}
savesymbol{IF}
savesymbol{ELSE}
savesymbol{ELSIF}
savesymbol{FOR}
savesymbol{WHILE}


usepackage{algorithm}
usepackage{algorithmic}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}[1]
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}









share|improve this question















marked as duplicate by Stefan Pinnow, JouleV, samcarter, Kurt, Raaja Mar 9 at 19:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Your code is not compileable !

    – AndréC
    Mar 9 at 11:08











  • @AndréC i have forgot the end {document}

    – Iftikhar Ahmad
    Mar 9 at 11:12








  • 1





    First a document class, then loading packages, then begin the document and now you can start the algorithm.

    – Johannes_B
    Mar 9 at 11:12











  • @IftikharAhmad You can modify your question by clicking on the edit button

    – AndréC
    Mar 9 at 11:15






  • 2





    I am a bit confused. This isthe code from here tex.stackexchange.com/questions/456586/…, you just changed things, which are obviously responsible for the errors. Why don't you just go back to the answer Werner posted back then?

    – sheß
    Mar 9 at 14:41














0












0








0


0







This question already has an answer here:




  • i want to write an algorithm but things went wrong

    1 answer




begin{document}
usepackage{savesym}
usepackage{program}
savesymbol{AND}
savesymbol{OR}
savesymbol{NOT}
savesymbol{TO}
savesymbol{COMMENT}
savesymbol{BODY}
savesymbol{IF}
savesymbol{ELSE}
savesymbol{ELSIF}
savesymbol{FOR}
savesymbol{WHILE}


usepackage{algorithm}
usepackage{algorithmic}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}[1]
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}









share|improve this question

















This question already has an answer here:




  • i want to write an algorithm but things went wrong

    1 answer




begin{document}
usepackage{savesym}
usepackage{program}
savesymbol{AND}
savesymbol{OR}
savesymbol{NOT}
savesymbol{TO}
savesymbol{COMMENT}
savesymbol{BODY}
savesymbol{IF}
savesymbol{ELSE}
savesymbol{ELSIF}
savesymbol{FOR}
savesymbol{WHILE}


usepackage{algorithm}
usepackage{algorithmic}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}[1]
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}




This question already has an answer here:




  • i want to write an algorithm but things went wrong

    1 answer








algorithms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 11:07









AndréC

1




1










asked Mar 9 at 11:06









Iftikhar AhmadIftikhar Ahmad

1226




1226




marked as duplicate by Stefan Pinnow, JouleV, samcarter, Kurt, Raaja Mar 9 at 19:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Stefan Pinnow, JouleV, samcarter, Kurt, Raaja Mar 9 at 19:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Your code is not compileable !

    – AndréC
    Mar 9 at 11:08











  • @AndréC i have forgot the end {document}

    – Iftikhar Ahmad
    Mar 9 at 11:12








  • 1





    First a document class, then loading packages, then begin the document and now you can start the algorithm.

    – Johannes_B
    Mar 9 at 11:12











  • @IftikharAhmad You can modify your question by clicking on the edit button

    – AndréC
    Mar 9 at 11:15






  • 2





    I am a bit confused. This isthe code from here tex.stackexchange.com/questions/456586/…, you just changed things, which are obviously responsible for the errors. Why don't you just go back to the answer Werner posted back then?

    – sheß
    Mar 9 at 14:41



















  • Your code is not compileable !

    – AndréC
    Mar 9 at 11:08











  • @AndréC i have forgot the end {document}

    – Iftikhar Ahmad
    Mar 9 at 11:12








  • 1





    First a document class, then loading packages, then begin the document and now you can start the algorithm.

    – Johannes_B
    Mar 9 at 11:12











  • @IftikharAhmad You can modify your question by clicking on the edit button

    – AndréC
    Mar 9 at 11:15






  • 2





    I am a bit confused. This isthe code from here tex.stackexchange.com/questions/456586/…, you just changed things, which are obviously responsible for the errors. Why don't you just go back to the answer Werner posted back then?

    – sheß
    Mar 9 at 14:41

















Your code is not compileable !

– AndréC
Mar 9 at 11:08





Your code is not compileable !

– AndréC
Mar 9 at 11:08













@AndréC i have forgot the end {document}

– Iftikhar Ahmad
Mar 9 at 11:12







@AndréC i have forgot the end {document}

– Iftikhar Ahmad
Mar 9 at 11:12






1




1





First a document class, then loading packages, then begin the document and now you can start the algorithm.

– Johannes_B
Mar 9 at 11:12





First a document class, then loading packages, then begin the document and now you can start the algorithm.

– Johannes_B
Mar 9 at 11:12













@IftikharAhmad You can modify your question by clicking on the edit button

– AndréC
Mar 9 at 11:15





@IftikharAhmad You can modify your question by clicking on the edit button

– AndréC
Mar 9 at 11:15




2




2





I am a bit confused. This isthe code from here tex.stackexchange.com/questions/456586/…, you just changed things, which are obviously responsible for the errors. Why don't you just go back to the answer Werner posted back then?

– sheß
Mar 9 at 14:41





I am a bit confused. This isthe code from here tex.stackexchange.com/questions/456586/…, you just changed things, which are obviously responsible for the errors. Why don't you just go back to the answer Werner posted back then?

– sheß
Mar 9 at 14:41










1 Answer
1






active

oldest

votes


















2














As we wrote in the comments, your document has many issues. You should probably familiarize yourself with the common structure for LaTeX documents. As Johannes_B wrote: "First a document class, then loading packages, then begin the document and now you can start the algorithm." More details here.



Your particular example is easy to fix once you stick to these rules.



%this comes first
documentclass{article}

%then this
usepackage{algpseudocode}
usepackage{algorithm}
%I dont know what all this is for
%usepackage{program}
%usepackage{savesym}
%savesymbol{AND}
%savesymbol{OR}
%savesymbol{NOT}
%savesymbol{TO}
%savesymbol{COMMENT}
%savesymbol{BODY}
%savesymbol{IF}
%savesymbol{ELSE}
%savesymbol{ELSIF}
%savesymbol{FOR}
%savesymbol{WHILE}

%everything you begin, you also have to end
begin{document}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}
end{document}


enter image description here






share|improve this answer





















  • 1





    I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

    – JouleV
    Mar 9 at 14:50


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














As we wrote in the comments, your document has many issues. You should probably familiarize yourself with the common structure for LaTeX documents. As Johannes_B wrote: "First a document class, then loading packages, then begin the document and now you can start the algorithm." More details here.



Your particular example is easy to fix once you stick to these rules.



%this comes first
documentclass{article}

%then this
usepackage{algpseudocode}
usepackage{algorithm}
%I dont know what all this is for
%usepackage{program}
%usepackage{savesym}
%savesymbol{AND}
%savesymbol{OR}
%savesymbol{NOT}
%savesymbol{TO}
%savesymbol{COMMENT}
%savesymbol{BODY}
%savesymbol{IF}
%savesymbol{ELSE}
%savesymbol{ELSIF}
%savesymbol{FOR}
%savesymbol{WHILE}

%everything you begin, you also have to end
begin{document}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}
end{document}


enter image description here






share|improve this answer





















  • 1





    I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

    – JouleV
    Mar 9 at 14:50
















2














As we wrote in the comments, your document has many issues. You should probably familiarize yourself with the common structure for LaTeX documents. As Johannes_B wrote: "First a document class, then loading packages, then begin the document and now you can start the algorithm." More details here.



Your particular example is easy to fix once you stick to these rules.



%this comes first
documentclass{article}

%then this
usepackage{algpseudocode}
usepackage{algorithm}
%I dont know what all this is for
%usepackage{program}
%usepackage{savesym}
%savesymbol{AND}
%savesymbol{OR}
%savesymbol{NOT}
%savesymbol{TO}
%savesymbol{COMMENT}
%savesymbol{BODY}
%savesymbol{IF}
%savesymbol{ELSE}
%savesymbol{ELSIF}
%savesymbol{FOR}
%savesymbol{WHILE}

%everything you begin, you also have to end
begin{document}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}
end{document}


enter image description here






share|improve this answer





















  • 1





    I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

    – JouleV
    Mar 9 at 14:50














2












2








2







As we wrote in the comments, your document has many issues. You should probably familiarize yourself with the common structure for LaTeX documents. As Johannes_B wrote: "First a document class, then loading packages, then begin the document and now you can start the algorithm." More details here.



Your particular example is easy to fix once you stick to these rules.



%this comes first
documentclass{article}

%then this
usepackage{algpseudocode}
usepackage{algorithm}
%I dont know what all this is for
%usepackage{program}
%usepackage{savesym}
%savesymbol{AND}
%savesymbol{OR}
%savesymbol{NOT}
%savesymbol{TO}
%savesymbol{COMMENT}
%savesymbol{BODY}
%savesymbol{IF}
%savesymbol{ELSE}
%savesymbol{ELSIF}
%savesymbol{FOR}
%savesymbol{WHILE}

%everything you begin, you also have to end
begin{document}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}
end{document}


enter image description here






share|improve this answer















As we wrote in the comments, your document has many issues. You should probably familiarize yourself with the common structure for LaTeX documents. As Johannes_B wrote: "First a document class, then loading packages, then begin the document and now you can start the algorithm." More details here.



Your particular example is easy to fix once you stick to these rules.



%this comes first
documentclass{article}

%then this
usepackage{algpseudocode}
usepackage{algorithm}
%I dont know what all this is for
%usepackage{program}
%usepackage{savesym}
%savesymbol{AND}
%savesymbol{OR}
%savesymbol{NOT}
%savesymbol{TO}
%savesymbol{COMMENT}
%savesymbol{BODY}
%savesymbol{IF}
%savesymbol{ELSE}
%savesymbol{ELSIF}
%savesymbol{FOR}
%savesymbol{WHILE}

%everything you begin, you also have to end
begin{document}
begin{algorithm}
caption{Initialization} label{algorithm: cds bw}
textbf{Input:}
V, E, S, Stextsubscript{ai}, P, Ptextsubscript{ai}, Rtextsubscript{s}, ptextsubscript{a},rtextsubscript{asp},
$a in V$, ${stextsubscript{i} in stextsubscript{ai}}$ , $r in R$\
hspace*{algorithmicindent} textbf{Output:}
Wtextsubscript{r} ($r in R$), Ptextsubscript{va} ($a in V$)
begin{algorithmic}
State $UA gets V$
State $T gets 0$
State $Makspan gets 0$
State $SrtS gets Sort(S)$
State $rXs gets SrtS$
For{$s in S$}
State $Wr gets Compute$
EndFor
For{ $a in V$}
State $Ptextsubscript{va} gets Compute$
EndFor
end{algorithmic}
end{algorithm}
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 9 at 14:49









JouleV

6,21121650




6,21121650










answered Mar 9 at 14:35









sheßsheß

2,20311435




2,20311435








  • 1





    I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

    – JouleV
    Mar 9 at 14:50














  • 1





    I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

    – JouleV
    Mar 9 at 14:50








1




1





I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

– JouleV
Mar 9 at 14:50





I edited your answer: TeX to LaTeX. If you are answering about overall TeXs, i.e. TeX, LaTeX and ConTeXt, be free to roll back!

– JouleV
Mar 9 at 14:50



Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?