I am writing an algorithm, where the Input has two lines. I first tried with itemize
environment, later substitued with algorithmic
for uniform look-and-feel. The problem is, the counter in the actual algorithm now starts with 3. To solve, I put it within another algorithmic
(those lines are marked with % Comment out this line
). This solves the numbering issues, but adds the issue of indentation (now it looks likes those are the lines under Output).
I have this minimal working example:
\documentclass{article}
\usepackage{algorithm}
%\usepackage{algorithmic}
\PassOptionsToPackage{noend}{algpseudocode}
\usepackage{algpseudocode}%
\makeatletter
\def\BState{\State\hskip-\ALG@thistlm}
\makeatother
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\Input{\item[\algorithmicinput]}%
\algnewcommand\Output{\item[\algorithmicoutput]}%
\begin{document}
\begin{algorithm}
\caption{Caption}\label{label}
\begin{algorithmic}[1]
\Input
{\begin{algorithmic}[1]
\item Something in line 1
\item Something in line 2
\end{algorithmic}
}
\Output {Suppose something is in here}
\begin{algorithmic}[1] % Comment out this line
\State Here goes the actual algorithm
\State Now the next step
\State This step, and we are done
\State \Return {Here you go}
\end{algorithmic} % Comment out this line
\end{algorithmic}
\end{algorithm}
\end{document}
Questions (all about indentation):
- Notice the lines within Input do not have equal indentation (line 2 is shifted to the left a bit more). How can I fix that?
- How can I reduce the indentation the steps in the actual algorithm given the current version?
- (Alternate to 2, getting an answer to at least one would suffice). The indentation in question 2 goes away if the marked lines are commented out. In this case, how can I reset the algorithm number back to 1?