# 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 algorithmlabeleuclideginalgorithmic<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
thistlmmakeatotheregindocumenteginalgorithmcaptionMy algorithmlabeleuclideginalgorithmic<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

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