如何消除伪代码中的自动缩进

如何消除伪代码中的自动缩进

代码中有一行自动缩进,如何消除缩进(即“\Endwhile”命令后面的那一行)?

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{capt-of}
\usepackage[table,xcdraw]{xcolor}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm}
\begin{algorithmic}
\Require Dataset $D = \{ (x(t_i), x(t_i), x(t_i))\}$
\While{$N \neq 0$}

\EndWhile \\

last line with indentation (How to make it no indented)

\end{algorithmic}
\end{algorithm}
\end{document}

答案1

快速破解:

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage{capt-of}
\usepackage[table,xcdraw]{xcolor}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\begin{algorithmic}
\Require Dataset $D = \{ (x(t_i), x(t_i), x(t_i))\}$
\While{$N \neq 0$}

\EndWhile \\
\hspace{-3ex} %% <-- a quick hack
last line with indentation (How to make it no indented)
\end{algorithmic}
\end{algorithm}
\end{document}

相关内容