多列中的算法大小调整

多列中的算法大小调整

我面临以下问题,

1)该算法正在走出页面

2)我想使用\mathcal但它并没有准确显示出来....

3)如果我使用这些> <符号,$但它给出错误,显示$它不能在算法中使用(这只发生在代码的倒数第三行,在中间我用任何符号都可以$正常工作)

在此处输入图片描述

\documentclass[letterpaper, 12 pt, conference]{ieeeconf}  

\usepackage{graphicx} 
\usepackage{bm}
\usepackage{dirtytalk}
\usepackage[lined,boxed,ruled,commentsnumbered]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{fullwidth}
\renewcommand{\baselinestretch}{1}
\usepackage{soul,microtype}
\usepackage{booktabs,multirow}
\usepackage{graphicx}
\setlength{\algoheightrule}{1pt} 
\setlength{\algotitleheightrule}{0.5pt} 
\usepackage{mathptmx} 
\usepackage{times} 
\usepackage{amsmath} 



\begin{algorithm}
\caption{YS}
\label{EDTLA}
%\SetAlgoVlined
\LinesNumbered
\DontPrintSemicolon
\Begin{
Initial things\;
Generate initial population\;
Evaluate the function\;
\BlankLine
\BlankLine
\For{All cells  i=1:\( \mathcal{A}_k^\mathcal{U} \)}{
\For{All tissues j=1:$\mathcal{N}$}{
Randomly generated values}
\For{p=1:popsize}{
 function is evaluated by each individual (a) using eq--
\While{(termination criterion not met)}{
Generating new population\;
\If{P_c>rand}{
crossover (a,b)}
\If{P_m>rand}{
mutate (a,b)}
Newpop(popsize,K)\;
Evaluate thefunction using new assign values(a)\;
\eIf{F(a)>F(b)}{
Replace the existing population with new}{
Discard b}
}}}}
\end{algorithm}

答案1

您需要附上全部数学环境中的数学表达式(使用$...$\(...\)):

\documentclass[letterpaper, 12 pt, conference]{ieeeconf}

\usepackage{graphicx}
\usepackage{bm}
%\usepackage{dirtytalk}
\usepackage[lined,boxed,ruled,commentsnumbered]{algorithm2e}
\usepackage{algpseudocode}
%\usepackage{fullwidth}
\renewcommand{\baselinestretch}{1}
\usepackage{soul,microtype}
\usepackage{booktabs,multirow}
\usepackage{graphicx}
\setlength{\algoheightrule}{1pt}
\setlength{\algotitleheightrule}{0.5pt}
\usepackage{mathptmx}
\usepackage{times}
\usepackage{amsmath}

\usepackage{lipsum}

\begin{document}
\begin{algorithm}
\caption{YS}
\label{EDTLA}
%\SetAlgoVlined
\LinesNumbered
\DontPrintSemicolon
\Begin{
Initial things\;
Generate initial population\;
Evaluate the function\;
\BlankLine
\BlankLine
\For{All cells  i=1:$\mathcal{A}_k^\mathcal{U}$}{
\For{All tissues j=1:$\mathcal{N}$}{
Randomly generated values}
\For{p=1:popsize}{
 function is evaluated by each individual $(a)$ using eq--
\While{(termination criterion not met)}{
Generating new population\;
\If{$P_c>rand$}{
crossover $(a,b)$}
\If{$P_m>rand$}{
mutate $(a,b)$}
Newpop(popsize,K)\;
Evaluate the function using new assign values $(a)$\;
\eIf{$F(a)>F(b)$}{
Replace the existing population with new}{
Discard $b$}
}}}}
\end{algorithm}

\lipsum[1-3]
\end{document}

在此处输入图片描述

相关内容