Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to print


in one line instead of two line?

share|improve this question
Welcome to! Please always add a full, but minimal working example (MWE) that illustrates your problem. – Martin Scharrer Jul 11 '11 at 15:20

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

share|improve this answer
Thank you very much – Mohammad Jul 12 '11 at 14:47
A version that makes an if one one line: newcommand{\LineIf}[2]{ \State \algorithmicif\ {#1}\ \algorithmicthen\ {#2} \algorithmicend\ \algorithmicif } – dtech Sep 18 '13 at 15:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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