2

This question already has an answer here:

I have the following problem: I am writing a couple of algorithms using algorithm2e. I have a bunch of longer if statements and longer if conditions. The lines are broken, but the new lines are not indented properly:

\begin{document}

  \begin{algorithm}[H]
    \SetAlgoLined
    \KwInput{Parameters...}

    \KwOutput{$\emptyset$}

    \If{the lines through $x_{1}, x_{2}$ and $y_{1}, y_{2}$ intersect in a single point $z$
        which lies on the circle $C$
       }
    {
      Do something \;
    }
    \caption{Algoritm test...}
  \end{algorithm}

\end{document}

I could force line breaks at certain positions using \, but that does not fix the indentation problems either. I saw the solution provided here: How to break lines in conditions using algorithm2e?

But I don't understand what is happening in that code and I was not able to reproduce the result with my problem. How can I indent the code correctly (is it possible to use something like an mbox?)?

marked as duplicate by LaRiFaRi, Svend Tveskæg, user13907, Werner, Symbol 1 Jul 21 '15 at 14:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Have you tried to use 'mbox' command? – C.Colden Jun 17 '13 at 15:19
  • Obviously, but without achieving the desired effect... – hfhc2 Jun 18 '13 at 20:58
  • @LaRiFaRi That is the one that OP commented on. You answered this question any got checked, so what is the deal now? – Symbol 1 Jul 21 '15 at 14:39
  • @Symbol1 I posted the same thing as in the linked answer. As I wrote in the second line, I just wanted to clarify what the OP wants. As the problem is solved now, but there is no new information at all, we can close. I could even delete my answer. Don't know. Do you want me to retract it? Do you think others will benefit from this? – LaRiFaRi Jul 21 '15 at 14:42
  • @LaRiFaRi (that is a quick comment.) Now I see that you answered 1 hr ago and got checked within. So it seems OP is like "whatever things cannot be better"... – Symbol 1 Jul 21 '15 at 14:51
0

Works for me as described in https://tex.stackexchange.com/a/101023. If this is what you want, we should close as duplicate. If not, you have to explain better, what you want, what you have tried, and where you got stuck.

% arara: pdflatex    

\documentclass{article}
\usepackage{algorithm2e}
\SetKwInput{KwInput}{Input} % just a guess
\SetKwInput{KwOutput}{Output} % just a guess
\usepackage{showframe} % for demonstration
\usepackage{microtype}

\begin{document}
    \begin{algorithm}[H]
        \SetAlgoLined
        \KwInput{Parameters...}     
        \KwOutput{$\emptyset$}
        \If{the lines through $x_{1}, x_{2}$ and $y_{1}, y_{2}$ intersect in a single point $z$ which lies\\
            \mbox{}\phantom{\textbf{if}} on the circle $C$
        }
        {
            Do something;
        }
        \caption{Algoritm test...}
    \end{algorithm} 
\end{document}

enter image description here

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