6

I would like to use the command \setstrech from the setspace package, but loading the package seems to clash with the document class imsart that I am using. Both seem to be defining \singlespacing and perhaps other common commands. Is there a simple way around this, say by telling Latex to override the package definitions with those of the documnetclass?

Example code that need to function without setspace package, the imsart can be found here:

\documentclass[aos,preprint]{imsart}
% link to imsart:
% http://www.e-publications.org/ims/support/ims-instructions.html


\usepackage{algorithm}
\usepackage{algpseudocode}
\newcommand{\algorithmicoutput}{\textbf{Output:}}
\algnewcommand{\IIf}[1]{\State\algorithmicif\ #1 \algorithmicthen}

% \usepackage{setspace}

\begin{document}

\begin{algorithm}
    \setcounter{algorithm}{2}
    \caption{Simple Algorithm}
    % \setstretch{1.25}
    \begin{algorithmic}[1]

        \State \makebox[2.00in][l]{Initialize $x$} $x^{(5)} \gets \mathcal L( u^{(2)}, A^{(3,4)})$
        \State \makebox[2.00in][l]{Update $y$} $y^{(5)} \gets \mathcal L( x^{(5)}, A^{(6,7)})$

    \end{algorithmic}

\end{algorithm}

\end{document}
8
  • 5
    Don't load setspace. The imsart class is for submissions to some journal, so you shouldn't monkey with the spacing they want.
    – egreg
    Mar 15, 2018 at 0:00
  • 3
    You should definitely follow egreg's advice. :-) However, if you must monkey around, try issuing the instruction \RequirePackage{setspace} immediately before the \documentclass instruction. No guarantees this won't break something else though.
    – Mico
    Mar 15, 2018 at 0:10
  • @egreg, thanks, I just need to change the spacing between lines in the algorithm environment which I think they would be fine with. I remember a long time ago I settled on \setstrech{1.2} as a solution. Is there a simple way of doing it within the algorithm without loading the package.
    – passerby51
    Mar 15, 2018 at 0:17
  • @passerby51 Please, add a small example of code to play with.
    – egreg
    Mar 15, 2018 at 0:27
  • @egreg, sample code added.
    – passerby51
    Mar 15, 2018 at 4:29

1 Answer 1

5

You can simply change the \linespread value within the algorithm. (I've used a larger value to show the effect).

\documentclass[aos,preprint]{imsart}
% link to imsart:
% http://www.e-publications.org/ims/support/ims-instructions.html


\usepackage{algorithm}
\usepackage{algpseudocode}
\newcommand{\algorithmicoutput}{\textbf{Output:}}
\algnewcommand{\IIf}[1]{\State\algorithmicif\ #1 \algorithmicthen}




\begin{document}

\begin{algorithm}
    \setcounter{algorithm}{2}
    \caption{Simple Algorithm}
    \linespread{2.25}\selectfont
    \begin{algorithmic}[1]

        \State \makebox[2.00in][l]{Initialize $x$} $x^{(5)} \gets \mathcal L( u^{(2)}, A^{(3,4)})$
        \State \makebox[2.00in][l]{Update $y$} $y^{(5)} \gets \mathcal L( x^{(5)}, A^{(6,7)})$

    \end{algorithmic}

\end{algorithm}

\end{document}

enter image description here

2
  • 1
    \linespread{1.25}\selectfont is simpler.
    – egreg
    Mar 15, 2018 at 17:04
  • You're right. I'll update the answer.
    – Alan Munn
    Mar 15, 2018 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .