I want to write an algorithm in overleaf, but it comes up with errors [duplicate]
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}
algorithms
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.
|
show 2 more comments
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}
algorithms
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 theedit
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
|
show 2 more comments
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}
algorithms
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
algorithms
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 theedit
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
|
show 2 more comments
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 theedit
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
|
show 2 more comments
1 Answer
1
active
oldest
votes
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}
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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}
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
add a comment |
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}
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
add a comment |
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}
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}
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
add a comment |
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
add a comment |
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