将长算法拆分成两页

将长算法拆分成两页

我正在格式化我的论文。在格式化过程中,我遇到了一个问题,即如何将一个长算法分成两页。下面是虚拟算法代码。我给出了论文中使用的所有包,以便此处提供的任何解决方案都不会与任何使用的包相矛盾。最初我有一个不同的文档类 - '\documentclass[12pt,openright,twoside]{ducs}'。

在发布这个问题之前,我尝试了以下链接提供的各种解决方案:

If EndIf 中的除法算法

将算法分成两页

algorithm2e 分为几页

我尝试使用较小的字体来解决它,但问题仍然没有解决。我现在完全糊涂了。

\documentclass{article}
\usepackage{ragged2e}
\usepackage{placeins}
\usepackage{enumitem}
%\usepackage[algo2e]{algorithm2e}
\usepackage{graphicx}
%\usepackage{subfigure}
\usepackage{multirow}
\usepackage{multicol}
%\usepackage{titlesec}
\setcounter{secnumdepth}{5}
\usepackage{longtable}
\usepackage{subfloat}
\usepackage{tabularx}
\usepackage{subfig}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{longtable}
\usepackage[lined,linesnumbered,ruled,resetcount,longend]{algorithm2e}
\usepackage{textgreek}
%\usepackage{enumerate}
\usepackage{caption}
\usepackage{csquotes}
\usepackage[T1]{fontenc}
\usepackage{scalerel}
\usepackage[utf8]{inputenc}
\usepackage[german,french,italian,welsh,greek,russian,portuguese,spanish,english]{babel}
\usepackage[tablename=Table]{caption}
\usepackage[dvipsnames,table,xcdraw]{xcolor}

\usepackage[UTF8]{ctex}
\newcommand{\nextnr}{\stepcounter{AlgoLine}\ShowLn}
\usepackage{epsfig}
\usepackage{times}
\usepackage{rotating}
\usepackage{comment}
%\usepackage{algorithm}
%\usepackage{algpseudocode}
%\algrenewcommand\textproc{}
\usepackage{epsfig}
\usepackage{amssymb}
\usepackage[black-square]{QED}
\usepackage{slashbox}
\usepackage{caption}
\captionsetup{font={small, singlespacing}}
%\usepackage {subcaption}
\usepackage{psfig}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{psfig}
\usepackage[a4paper,left=1.5in, right=1.1in, top=1.0in, bottom=.90in]{geometry}
\usepackage[numbers]{natbib}
\usepackage[T1]{fontenc} % important if your docs contain special characters
\usepackage{epstopdf}%
\usepackage{units} % for solidus fractions %
\usepackage{array,booktabs,ragged2e}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{placeins}
\usepackage{float, caption}
\floatstyle{boxed} 
\usepackage{framed}
\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{myFigureBoxStyle}{tikzsetting={draw=black, line width=1pt}}%
\makeatletter
\newcommand\fs@myRoundBox{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@plain
\def\@fs@pre{\begin{mdframed}[style=myFigureBoxStyle]}%
\def\@fs@mid{\vspace{\abovecaptionskip}}%
\def\@fs@post{\end{mdframed}}\let\@fs@iftopcapt\iffalse}
\makeatother
\usepackage{footnote}

\usepackage{threeparttable}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{L}{>{\centering\arraybackslash}m{6cm}}
\newcolumntype{L}{>{\centering\arraybackslash}m{6cm}}
\newcolumntype{C}{>{\centering\arraybackslash}m{3cm}}

\usepackage{longtable}
\makesavenoteenv{tabular}
\usepackage{color} %May be necessary if you want to color links
\usepackage[breaklinks=true]{hyperref}
\hypersetup{
linktoc=all, %set to all if you want both sections and subsections linked
}

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{2}

%\floatname {algorithm}{Procedure}
%\renewcommand {\algorithmicrequire} {\textbf{Input:}}
%\renewcommand {\algorithmicensure} {\textbf{Output:}}
\newtheorem{defn}{Definition} 
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newfont{\mycrnotice}{ptmr8t at 7pt}
\newfont{\myconfname}{ptmri8t at 7pt}
\let\crnotice\mycrnotice%
\let\confname\myconfname%
\graphicspath{ {images/} }

\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{assertion}[theorem]{Assertion} 
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{example}[theorem]{Example}
\newtheorem{figger}[theorem]{Figure}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{prop}[theorem]{Proposition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{definition}{Definition}[section]
\renewcommand {\nomenclature} {Notations}
\renewcommand\floatpagefraction{.9}
\renewcommand\topfraction{.9}
\renewcommand\bottomfraction{.9}
\renewcommand\textfraction{.1} 
\setcounter{totalnumber}{50}
\setcounter{topnumber}{50}
\setcounter{bottomnumber}{50}

\hyphenation{semi-blind Bi-directional}
\usepackage{url}
\urlstyle{same}
\listfiles
\begin{document}
\begin{algorithm}[H]

\SetKwInOut{KwIn}{Input}
\SetKwInOut{KwOut}{Output}
\KwIn{Text Input.}
\KwOut{Text Output.}

\nextnr \For{each condition1 }{
Obtain TR
}
\nextnr \For{each condition2 }{
\nextnr Obtain TR corresponding to the code.
\end{algorithm}
\begin{algorithm}[H]
\nextnr \uIf{ condition3 }{
goto step 11.
}

\Else{
\uIf{condition4}{
go to step 7.
}
\Else{
Find the compound score.
Append TR.
%\end{enumerate}
}
}
\nextnr \uIf{ condition5}{
go to step 8.
}
\Else{
go to step 9.
}
\nextnr Obtain TR. \\

\nextnr Find the sum. \\
\nextnr \uIf{condition 6 }{
Find the score, \textit{score}.\\
}
\Else {
Find the compound score.\\
}

\nextnr \uIf{condition7}{
Obtain TR.
}
\Else{
Obtain TR1
}
Go to step 12. \\
\nextnr Replace the first TR \\

\nextnr Replace code with the TR.

}

\caption{Algo Demo}

\end{algorithm}
\end{document}

相关内容