.png)
Gostaria de saber como iniciar um código em um número específico; isso é necessário quando o algoritmo é dividido em duas páginas.
Um pequeno exemplo que gostaria de começar na linha 39 em vez da linha 1. Existe uma maneira de fazer isso?
\documentclass[paper=a4,toc=bibliography,nonchapterprefix,parskip=true]{scrreprt}
\usepackage[linesnumbered]{algorithm2e}
\begin{document}
\IncMargin{1em}
\begin{algorithm}
\SetKwData{Left}{left}
\SetKwData{Up}{up}
\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\Indm
\Input{A bitmap $Im$ of size $w\times l$}
\Output{A partition of the bitmap}
\Indp
\BlankLine
\For{$i\leftarrow 2$ \KwTo $l$}{
\Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}\;
\Up$\leftarrow$ \FindCompress{$Im[i-1,]$}\; }
\lForEach{element $e$ of the line $i$}{\FindCompress{p}}
\end{algorithm}
\DecMargin{1em}
atenciosamente!
Responder1
O algorithm2e
pacote tem uma noresetcount
opção, mas isso tem o efeito de numerar todos os algoritmos continuamente.
Você pode definir uma \rememberlines
macro que armazenará o número da linha atual no final de um algorithm
ambiente e uma \resumenumbering
macro que utilize esse valor.
\documentclass[paper=a4,toc=bibliography,parskip=true]{scrreprt}
\usepackage[linesnumbered]{algorithm2e}
\newcommand{\rememberlines}{\xdef\rememberedlines{\number\value{AlgoLine}}}
\newcommand{\resumenumbering}{\setcounter{AlgoLine}{\rememberedlines}}
\begin{document}
\IncMargin{1em}
\begin{algorithm}
\SetKwData{Left}{left}
\SetKwData{Up}{up}
\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\Indm
\Input{A bitmap $Im$ of size $w\times l$}
\Output{A partition of the bitmap}
\Indp
\BlankLine
\For{$i\leftarrow 2$ \KwTo $l$}{
\Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}
\Up$\leftarrow$ \FindCompress{$Im[i-1,]$}}
\lForEach{element $e$ of the line $i$}{\FindCompress{p}
}
\rememberlines
\end{algorithm}
\begin{algorithm}
\resumenumbering
\SetKwData{Left}{left}
\SetKwData{Up}{up}
\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\Indm
\Input{A bitmap $Im$ of size $w\times l$}
\Output{A partition of the bitmap}
\Indp
\BlankLine
\For{$i\leftarrow 2$ \KwTo $l$}{
\Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}
\Up$\leftarrow$ \FindCompress{$Im[i-1,]$}}
\lForEach{element $e$ of the line $i$}{\FindCompress{p}
}
\end{algorithm}
\end{document}