我已经使用了建议的策略这里(\parbox
)打破我的\If
封锁的长期条件:
\documentclass{article}
\usepackage{mathptmx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fdsymbol}
\usepackage{algorithm}
\usepackage{algorithmicx,algpseudocode}
\usepackage[top=2cm, left = 2cm, right = 2cm, bottom = 2cm]{geometry}
\algnewcommand\algorithmicforeach{\textbf{for each}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\INPUT{\item[\algorithmicinput]}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\OUTPUT{\item[\algorithmicoutput]}
\let\oldReturn\Return
\renewcommand{\Return}{\State\oldReturn}
\makeatletter
\newcommand{\algrule}[1][.2pt]{\par\vskip.5\baselineskip\hrule height #1\par\vskip.5\baselineskip}
\makeatother
\begin{document}
\begin{algorithm}[tbp]
\caption{ttt}
\begin{algorithmic}[1]
\INPUT $x$
\OUTPUT $y$
\algrule[1pt]
\If{$\sigma \in \Sigma_{\text{for}}$ \parbox[t]{.3\linewidth}{ $\vee (\forall \sigma^{'} \in \Sigma_{\omega\omega}^{i}) \sigma^{'} \in \Sigma_{c}$ \\ $\vee (\nexists \sigma^{'} \in \Sigma_{\omega\omega}^{i}) \text{pr}(\sigma^{'}, \sigma)$ \\ $\vee [(\Sigma_{\omega\omega}^{i} = \emptyset) \wedge (\sigma \in \Sigma_c)]$}}
\State \text{do something}
\EndIf
\Return z
\end{algorithmic}
\end{algorithm}
\end{document}
1-then
必须放在条件的最后一行(而不是第一行)。
2- 第一个条件和 之间有一个不寻常的空格then
。
请问我该如何解决这些问题?
答案1
为什么不使用一些\newline
s 和\hspace
s 来代替 a ,因为\parbox
在这种情况下很难管理?
\documentclass{article}
\usepackage{mathptmx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fdsymbol}
\usepackage{algorithm}
\usepackage{algorithmicx,algpseudocode}
\usepackage[top=2cm, left = 2cm, right = 2cm, bottom = 2cm]{geometry}
\algnewcommand\algorithmicforeach{\textbf{for each}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\INPUT{\item[\algorithmicinput]}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\OUTPUT{\item[\algorithmicoutput]}
\let\oldReturn\Return
\renewcommand{\Return}{\State\oldReturn}
\makeatletter
\newcommand{\algrule}[1][.2pt]{\par\vskip.5\baselineskip\hrule height #1\par\vskip.5\baselineskip}
\makeatother
\begin{document}
\begin{algorithm}[tbp]
\caption{ttt}
\begin{algorithmic}[1]
\INPUT $x$
\OUTPUT $y$
\algrule[1pt]
\If{$\sigma \in \Sigma_{\text{for}}$ $\vee (\forall \sigma^{'} \in \Sigma_{\omega\omega}^{i}) \sigma^{'} \in \Sigma_{c}$ \newline
\hspace*{1.5cm} $\vee (\nexists \sigma^{'} \in \Sigma_{\omega\omega}^{i}) \text{pr}(\sigma^{'}, \sigma)$ \newline
\hspace*{1.5cm} $\vee [(\Sigma_{\omega\omega}^{i} = \emptyset) \wedge (\sigma \in \Sigma_c)]$}
\State \text{do something}
\EndIf
\Return z
\end{algorithmic}
\end{algorithm}
\end{document}