¿Alguien puede ayudar a escribir el algoritmo que se muestra en la figura en LaTex?

¿Alguien puede ayudar a escribir el algoritmo que se muestra en la figura en LaTex?

Estaba intentando escribir el algoritmo que se muestra en1en látex.

A continuación se muestra el código que probé. Sin embargo, no devuelve ninguna sangría como la necesitaba. Agradezco la ayuda.

\documentclass[11pt]{article}
\usepackage[margin=4cm]{geometry}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage[norelsize, linesnumbered, ruled, lined, boxed, commentsnumbered]{algorithm2e}

%\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%
%\algblockdefx[ARBITRARY]{Arbitrary}{endArbitrary}[1]{#1}

\begin{document}


\begin{algorithm}[H]
 \SetAlgoLined
 \LinesNumbered
 \SetKwInOut{Input}{Input}
 \Input{$x,y,z,$}
 \SetKwProg{Function}{function}{}{end}
 \SetKwRepeat{Do}{do}{while}
 %\Function{function($ inp$) : int}{
     \Do{done = false}{ something }
        \Do{done2 =true} {something2}
% }
 \caption{Algorithm}
\end{algorithm}

Probé el bucle do- while como se muestra a continuación. Lamentablemente, algunos problemas de formato, incluidos los de entrada, salida y título, no funcionan.

\documentclass{article}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{blkarray}
\usepackage{algpseudocode}
\usepackage{amsmath}

\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%


\begin{document}
\begin{algorithmic}
\SetAlgoLined
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\DontPrintSemicolon
  \Do
    \State r s t $\boldsymbol{J}_{dh}$
        \Do 
    \State Compute $\boldsymbol{J}_{dh}$ %$m,n,p,q,\boldsymbol{J}_{dh}$ 
            \Do
        \State $m,n,o,\boldsymbol{J}_{dh}$
                \Do
                \State $ m, n \boldsymbol{J}_{dh} $
                \doWhile {$k<k_{max}$} 
            \doWhile{$\Delta_\alpha<tol$}
    \doWhile{$\varepsilon <2\pi$}
  \doWhile{$z<z_f$} % <--- use \doWhile for the "while" at the end
\end{algorithmic}
\end{document}

Gracias

Respuesta1

Aquí hay un boceto de una forma de hacerlo algorithm2e. Lo incluí xcolor, soulcon fines de demostración en caso de que desee resaltar una línea específica.

Pista: El entorno matemático que utilizo aquí es sólo un boceto, es decir, necesita mejoras.

algo

\documentclass[11pt]{article}
\usepackage[linesnumbered,lined,ruled,commentsnumbered]{algorithm2e}
\usepackage{xcolor, soul}% <<<
\sethlcolor{yellow}% <<<


\begin{document}

  \begin{algorithm}[h]
    \caption{Algorithm}

    \While{$Z < Z_f$}{
        r, s, t;
        
        \While{$eps < 2 pi$}{
            \hl{m, n, P};% <<< if you need to highlight something
            
            \While{}{
                \While{$k < k_{max}$}{
                    m, n, Td;
                }
                $theta =$;
                $psi =$;
            
            }
        }
    }
    plot(something);
  \end{algorithm}

\end{document}

información relacionada