13

If you look at the image below you will see that on the 4th line of the input, the alignment resets for some reason and I'm not sure why. Could someone show me how to fix this?

enter image description here

    \begin{algorithm}[H]
        \SetKwInOut{Input}{input}
        \SetKwInOut{Output}{output}

        \Input{A set of men $M$ such that for all $m \in M$, $m$ is free and has a preference list containing each woman $w \in W$ \\
        A set of women $W$ such that for all $w \in W$, $w$ is free and has a preference list containing each man $m \in M$}
        \Output{A perfect matching between $M$ and $W$ with no strong instability}
    \end{algorithm}
16

Your problem is that you're using \\ inside the defined \Input. If you use \newline, instead, it works fine.

MWE:

\documentclass{article}
\usepackage[titlenumbered,ruled]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
    \SetKwInOut{Input}{input}
    \SetKwInOut{Output}{output}

    \Input{A set of men $M$ such that for all $m \in M$, $m$ is free and has a preference list containing each woman $w \in W$ \newline 
    A set of women $W$ such that for all $w \in W$, $w$ is free and has a preference list containing each man $m \in M$}
    \Output{A perfect matching between $M$ and $W$ with no strong instability}
    \caption{Modified Gale-Shapley algorithm allowing indifferences}
\end{algorithm}
\end{document} 

Output:

enter image description here

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.