我的算法非常复杂,我想让\onehalfspace
它们的行更易于阅读,同时保留文档的其余部分singlespace
。我该如何做才能让它自动为我的所有algorithm
环境执行此操作?
答案1
\onehalfspacing
您可以通过在环境后插入来更改行距。如果所有此类情况都algorithm
需要这样做,您可以使用\AtBeginEnvironment
类似etoolbox
\usepackage{etoolbox}
\AtBeginEnvironment{algorithmic}{\onehalfspacing}
在序言中。
必填代码:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{blindtext}
\usepackage{setspace}
\usepackage{etoolbox}
\AtBeginEnvironment{algorithmic}{\onehalfspacing}
\begin{document}
\blindtext
\begin{algorithm}%[H]
\caption{Example}
\label{lst:d}
\begin{algorithmic}[1]
\STATE ...
\STATE ...
\FORALL{$D_i$ in $PC$}
\STATE ...
\STATE ...
\IF{$D_i$ contains a disjunction}
\STATE Split $D_i$ at every disjunction
\STATE Transform every splitted part into a $RPTP$ and store it in $rptp$
\ELSE
\STATE Transform $D_i$ into a $RPTP$ and store it in $rptp$
\ENDIF
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{document}