我algorithm
不仅将环境用于伪代码,还将其与需要步骤配方列表的任何东西保持一致。在下面的 MWE 中,我创建了一个algorithm
环境,并且希望前几行是纯文本。到目前为止一切顺利,换行似乎很好地遵循了边距,但是当换行到第二行时,它有一个奇怪的缩进。
其次,在枚举环境中,每个项目的文本似乎都强加了与纯文本不一致的边距。
我的代码是:
\documentclass[11pt, oneside]{article}
\usepackage[ruled,vlined]{algorithm2e}
\begin{document}
\begin{algorithm}
\footnotesize
Here I have some text that I need to have within the algorithm that
sets up the problem, and the text stretches over two lines.
\textbf{Note that the second line has a weird indentation.}
\BlankLine
For all the of the seconds in the day:
\begin{enumerate}
\item This is a very long line that briefly describes the
computation I am going to use. \textbf{The margin for some
reason is different than the text above!}
$$ {\omega}_{ik} = 42$$
where $\omega$ and all these Greek letters mean nothing since
this is just a MWE, but again note that the text does not end at
the same spot as the first block of text in the environment.
\end{enumerate}
\caption{\footnotesize My Little Algorithm}
\end{algorithm}
\end{document}
答案1
我建议您使用minipage
如下环境来介绍专用于文本的环境。
\documentclass[11pt, oneside]{article}
\usepackage[ruled,vlined]{algorithm2e}
\begin{document}
\begin{algorithm}
\footnotesize
\begin{minipage}{.92\linewidth}
Here I have some text that I need to have within the algorithm that
sets up the problem, and the text stretches over two lines.
\textbf{Note that the second line has a weird indentation.}
\BlankLine
For all the of the seconds in the day:
\begin{enumerate}
\item This is a very long line that briefly describes the
computation I am going to use. \textbf{The margin for some
reason is different than the text above!}
$$ {\omega}_{ik} = 42$$
where $\omega$ and all these Greek letters mean nothing since
this is just a MWE, but again note that the text does not end at
the same spot as the first block of text in the environment.
\end{enumerate}
\end{minipage}
\caption{\footnotesize My Little Algorithm}
\end{algorithm}
\end{document}