在算法中插入缩进,位于同一 \State 的换行符处

在算法中插入缩进,位于同一 \State 的换行符处

我有以下代码:

\documentclass[12pt,a4paper,twoside]{book}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm*}[t!]
\caption{caption}
\begin{algorithmic}[1]
\Require{require} 
\State {testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt} 
\Return{return a}
\end{algorithmic}
\end{algorithm*}
\end{document}

如何在 \State 中断行并以与上一行相同的缩进量开始新行?

答案1

它是自动完成的:

\documentclass[12pt,a4paper,twoside]{book}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithm*}[t!]
\caption{caption}
\begin{algorithmic}[1]
\Require{require}
\State {test tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt
        tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt tttt}
\Return{return a}
\end{algorithmic}
\end{algorithm*}
\end{document}

在此处输入图片描述

相关内容