尝试获取此
Algorithm 1 : Name of algorithm
Input: Input number 1
Input number 2
Input number 3 that extend the length desired
so can it brought to the next line
Output: Output
Begin
Some intelligent algorithm
End
到目前为止我已经
\newlength\mylen
\newcommand\myinput[1]{%
\settowidth\mylen{\KwIn{}}%
\setlength\hangindent{\mylen}%
\hspace*{\mylen}#1\\}
\begin{algorithm}
\caption{Algorithm caption}\label{alg:cap}
\begin{algorithmic}
\KwIn{data:first long input}
\myinput{Second input line}
\myinput{third input line}
\myinpur{fourth input line that is really long and needs to be broken down}
\KwOut{the output line}
\end{algorithmic}
\end{algorithm}
根本不起作用
答案1
您可以使用algpseudocodex
。
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocodex}
\algrenewcommand\algorithmicrequire{\textbf{Input:}}
\algrenewcommand\algorithmicensure{\textbf{Output:}}
\begin{document}
\begin{algorithm}
\caption{Algorithm caption}\label{alg:cap}
\begin{algorithmic}
\Require{data:first long input\\%
data:first long input\\%
Second input line\\%
third input line\\%
fourth input line that is really long and needs to be broken down}
\Ensure{the output line}
\end{algorithmic}
\end{algorithm}
\end{document}