Writing Algorithms In Latex

I am trying to create pseucarry out code in my paper. Here is the snippet and also image choose what I desire. Can some one please assist me to format it.

eginalgorithmcaptionEuclid’s algorithmlabeleuclideginalgorithmic<1>ProcedureEuclid$a,b$CommentThe g.c.d. of a and bState $stringlengets size of string$State $igets patlen$top: eIfi > stringlen return false; State $jgets patlen$ loop: eIf j == 0 rerevolve j+1; eIfstring(i) > pat(j) State $jgets $j -1$ State $igets $i -1$ State goto loop State Cshed. State $jgets patlen$ EndWhilelabeleuclidendwhileEndProcedureendalgorithmicendalgorithmit need to look favor this:

*

Right now it looks messed up. Any help is appreciable ..


You watching: Writing algorithms in latex

*

*

This is what can be done with algorithmicx:

*

Code:

documentclassarticleusepackageamsmathusepackagealgorithmusepackagealgpseudocodemakeatletterdefBStateStatehskip-ALG
thistlmmakeatotheregindocumenteginalgorithmcaptionMy algorithmlabeleuclideginalgorithmic<1>ProcedureMyProcedureState $sibbap.orgtitstringlen gets sibbap.orgtlength of sibbap.orgtitstring$State $i gets sibbap.orgtitpatlen$BState emphtop:If $i > sibbap.orgtitstringlen$ Return falseEndIfState $j gets sibbap.orgtitpatlen$BState emphloop:If $sibbap.orgtitstring(i) = sibbap.orgtitpath(j)$State $j gets j-1$.State $i gets i-1$.State sibbap.orgtbfgoto emphloop.State sibbap.orgtbfclose;EndIfState $i gets i+max(sibbap.orgtitdelta_1(sibbap.orgtitstring(i)),sibbap.orgtitdelta_2(j))$.State sibbap.orgtbfgoto emphtop.EndProcedureendalgorithmicendalgorithmenddocument

*

See more: Add Days To A Date In Python Datetime Add Day In Python, Add Days To A Date In Python

Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation need helps protect this question from spam and also non-answer activity.

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


*

*

website design / logo design © 2021 Stack Exadjust Inc; user contributions licensed under cc by-sa. rev2021.8.18.40012


Your privacy

By clicking “Accept all cookies”, you agree Stack Exadjust deserve to save cookies on your gadget and also discshed information in accordance through our Cookie Policy.