
Ich formatiere meine Abschlussarbeit. Beim Formatieren stehe ich vor dem Problem, einen langen Algorithmus auf zwei Seiten aufzuteilen. Unten ist der Dummy-Algorithmuscode. Ich habe alle in der Abschlussarbeit verwendeten Pakete angegeben, damit die hier bereitgestellte Lösung keinem der verwendeten Pakete widerspricht. Ursprünglich habe ich eine andere Dokumentklasse – „\documentclass[12pt,openright,twoside]{ducs}“.
Bevor ich diese Frage gepostet habe, habe ich verschiedene Lösungen ausprobiert, die unter den folgenden Links bereitgestellt werden:
Dividieren Sie den Algorithmus innerhalb von If EndIf
Einen Algorithmus auf zwei Seiten aufteilen
algorithm2e auf mehrere Seiten aufgeteilt
Ich habe versucht, das Problem durch die Verwendung kleinerer Schriftgrößen zu lösen, aber mein Problem ist immer noch nicht gelöst. Ich bin jetzt völlig verwirrt.
\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}