algorithm2e“输入”对齐问题

algorithm2e“输入”对齐问题

如果您查看下面的图片,您会发现在输入的第 4 行,对齐由于某种原因而重置,我不确定为什么。有人可以告诉我如何解决这个问题吗?

在此处输入图片描述

    \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}

答案1

您的问题是您\\在定义的 内部使用\Input。如果您改用\newline,则可以正常工作。

梅威瑟:

\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} 

输出:

在此处输入图片描述

相关内容