# Problem in package algorithmic

This is my code :

\begin{algorithmic}
\STATE Sort increasingly the $a_{i}, i=1,...,n$
\STATE $a_{n+1}\gets \infty$
\STATE $m \gets 1$
\STATE $\Tilde{x} \gets \infty$
\WHILE{$\Tilde{x} \geqslant a_{m+1} \mbox{ and } m \leqslant n-1$} \do
\STATE $\Tilde{x} \gets \mbox{ solution of } \sum_{i=1}^{m} \left( \frac{(x-a_{i})^{+}}{h_{i}} \right)^{p} = \mathcal{C}^{p} \mbox{ with p=1 or 2 }$
\STATE $m \gets m+1$
\ENDWHILE
\STATE $\Bar{x} \gets \Tilde{x}$
\end{algorithmic}


I want to get the new line in the two instructions of while and also adding a caption. thank you

• Welcome to TeX SX! What is the \Tilde command? – Bernard Jan 21 '19 at 18:28
• please extend your code fragment to complete but small document, which we can test. – Zarko Jan 21 '19 at 18:29

Is it something like this you want?

\documentclass{article}
\usepackage{amsmath, amssymb} \usepackage{algorithm, algorithmic}
\usepackage{caption}

\begin{document}

\begin{algorithm}
\caption{My funny algorithm}
\label{fun}
\begin{algorithmic}
\STATE Sort increasingly the $a_{i}, i=1,...,n$
\STATE $a_{n+1}\gets \infty$
\STATE $m \gets 1$
\STATE $\tilde{x} \gets \infty$
\WHILE{$\tilde{x} \geqslant a_{m+1} \mbox{ and } m \leqslant n-1$} %\do
\STATE $\tilde{x} \gets \mbox{ solution of } \sum_{i=1}^{m} \left( \frac{(x-a_{i})^{+}}{h_{i}} \right)^{p} = \mathcal{C}^{p} \mbox{ with p=1 or 2 }$
\STATE $m \gets m+1$
\ENDWHILE
\STATE $\Bar{x} \gets \tilde{x}$
\end{algorithmic}
\end{algorithm}

\end{document}


• @abdelkarimlamghari If Bernard's answer solves your issue, you should upvote and accept his answer. – user156344 Jan 22 '19 at 2:43
• i try that; but they show me : Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score. – abdelkarim lamghari Jan 23 '19 at 0:47