I am trying to write if-else loop in an algorithm within the substeps. Somehow it doesn't appear as expected.


\lstset{language = Modelica,
       backgroundcolor = \color{white},
       aboveskip = 0pt, 
       belowskip = 0pt}

  {% \begin{breakablealgorithm}
     \refstepcounter{algorithm}% New algorithm
     \hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
     \renewcommand{\caption}[2][\relax]{% Make a new \caption
       {\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
       \ifx\relax##1\relax % #1 is \relax
       \else % #1 is not \relax
  }{% \end{breakablealgorithm}
     \kern2pt\hrule\relax% \@fs@post for \@fs@ruled

     \Statex {\footnotesize\thealgsubstate:}\space}}

\newcommand{\comment}{\newline \Comment}

\caption{Equations in a material stream}

\State Overall Material Balance
F = L + V

\State Component wise Material Balance
z_i F = x_i L + y_i V

\State Equilibrium equation:
y_i = K_i x_i

\State Vapor Phase Mole Fraction:
\beta = \frac{V}{F}

\State Summation equaton:
\sum_{i=1}^n y_i = 1

\sum_{i=1}^n x_i = 1

\State Phase mole fraction
        \If{$P \geq P_{bubble}$}
            x_i = z_i
            y_i = 0
        \ElsIf {$P \geq P_{bubble}$}
            x_i = \frac{L_i}{F_i}
            y_i = \frac{V_i}{F_i}
            y_i = z_i
            x_i = 0


In theenter image description here image, what appears at step 7 should appear at point a, what appears at step 8 should appear at point b and what appears at step 9 should appear at point c.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.