0

I am looking for the way to write a algorithm as: (without numbering). Please help me to write it in latex. Thanks in advance

Algorithm:
Input: A, B,C.
Initialize \alpha, \beta,u
Employ the A
While |u^(k+1)-u^k |≥ \epsilon
    Compute \alpha as \hat {\alpha} by Eq. \eqref{eq:1}.
    Compute \beta as \hat {\beta} by Eq. \eqref{eq:2}.
    Compute u as \hat u by Eq. \eqref{eq:3}.
End
Output: \alpha, \beta.
  • 2
    What do you mean without numbering ? Could you provide a MWE showing the problems you are facing ? – Nicolas Nov 6 '15 at 15:24
  • If you are using the algorithm2e package (which I suppose you are, given your question tags), the default option is without numbering. – usernumber Nov 6 '15 at 15:32
4

Here is a sample code for your algorithm using the package algorithm2e as suggested by your tags:

\documentclass[12pt]{article}
\usepackage[plainruled]{algorithm2e}
\usepackage{amsmath}

\begin{document}
    \begin{algorithm}[ht!]
    \KwIn{%
         $A, B \text{ and } C$
         }%

         {\bf Initialization:} $\alpha, \beta \text{ and } u$ ;

    \While{$|u^{k+1}-u^k | \geq \epsilon$}{%

        compute $\alpha$ as $\hat{\alpha}$ with Eq. \eqref{eq:1};

        compute $\beta$ as $\hat{\beta}$ with Eq. \eqref{eq:2};

        compute $u$ as $\hat{u}$ with Eq. \eqref{eq:3}.
        }

     \KwOut{%
        $\alpha \text{ and } \beta$
        }%

     \caption{Some algorithm}%
     \label{algo:solution}%
     \end{algorithm}
\end{document}

And here is what the output looks like:

Output from code

There are many different options within algorithm2e to configure the layout of the algorithm. You can for instance replace the option plainruled by plain in order to remove the horizontal lines. More information is available in the package documentation here. See section 7.3.

As for the numbering of the algorithm, if you completely remove the number, you will not be able to label it and reference it in the text. Have a look at section 9.2 and the command \SetAlgoRefName in order to customize the referencing.

| improve this answer | |
  • Thank Nicolas. Is it possible to remove the vertical and horizontal dash (between while-end, and upper of input and Algorithm1? Besides, please remove the Algorithm1 caption, just use Algorithm – user3051460 Nov 7 '15 at 1:22
  • I just edited the answer. Hope it helps. – Nicolas Nov 7 '15 at 18:00

Your Answer

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

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