How to print


in one line instead of two line?


1 Answer 1


You should define your own command for placing algorithmic content on a single line. As a suggestion, consider:

    \STATE\algorithmicfor\ {#1}\ \algorithmicdo\ {#2} \algorithmicend\ \algorithmicfor%

which prints the regular algorithmic package keywords used in the construction of a for statement (\algorithmicfor, \algorithmicdo, etc.), but does all of this in a single \STATE statement (or line).

Here is a complete minimal example illustrating the result:

enter image description here


    \STATE\algorithmicfor\ {#1}\ \algorithmicdo\ {#2} \algorithmicend\ \algorithmicfor%

    \STATE \ldots
        \STATE $\mathcal{C}_{ij}:=\mathcal{C}_{ii}\cdot\mathcal{C}_{ij}$;%
    \STATE \ldots
    \STATE \ldots

  • A version that makes an if one one line: newcommand{\LineIf}[2]{ \State \algorithmicif\ {#1}\ \algorithmicthen\ {#2} \algorithmicend\ \algorithmicif }
    – dtech
    Commented Sep 18, 2013 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .