Reducing space in Algorithm environment

312 views
Skip to first unread message

Suman Roy

unread,
Dec 9, 2018, 12:04:31 PM12/9/18
to LaTeX Users Group
I am trying to typeset the following code in two column style. The code is written using algorithm environment. The problem is the block is covering an entire column. I need to push some more material in the empty space available in the same column. Can you please suggest me how to reduce space above and below this piece of Latex code?

Thanks,
--Suman

================================================================================================

\begin{algorithm}%[H]
{\small
\SetAlgoLined
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\SetKwInOut{Assign}{Assign}
\SetKwInOut{Initialization}{Initialization}
\SetKwInOut{Iteration}{Iteration}
\SetKwInOut{Require}{Require}
\SetKwInOut{End}{End}
\SetKwInOut{Solution}{Solution}
%\Require{} ${\mathbf \alpha}, \beta, {\mathbf \gamma}_d$, Corpus{\small 
\Input{${\mathbf \alpha}, \beta, {\mathbf \gamma}_d$, Corpus (labeled and unlabeled)}
%\Output{Ticket-topic matrix $\mat{U} \in {\mathbb R}_{\geq 0}^{n \times k}$, term-topic matrix $\mat{V} \in {\mathbb R}_{\geq 0}^{m \times k}$ and concept-topic matrix $\mat{W} \in {\mathbb R}_{\geq 0}^{h \times k}$}
\Initialization{ Initialize ${\bf \alpha} = (\alpha_1, \alpha_2, \ldots, \alpha_k)$\; 
                             \hspace*{2.2cm}${\beta}$\;
  \hspace*{2.2cm}$\gamma = (\gamma_1, \gamma_2, \ldots, \gamma_d)$\;
Initialize $D \times T$ matrix ${\mathbf \Theta}$, $D \times T \times S$ matrix ${\mathbf \Pi}$, $T \times S \times V$ matrix $\Phi$;}
\For{i = 1 to {\em max} Gibbs sampling iterations}
     { \For{all documents $d \in \{1,2, \ldots, D\}$}
        { \For {all words $w_t,\, t \in \{1,2, \ldots, N_d\}$}
{Exclude $w_t$ associated with topic $j$ and sentiment label $k$ from variables $N_{d,j}, N_{d,j,k}$, $N_{j,k,i}, N_j,k$ and $N_d$\;
Sample a new topic sentiment pair $\bar{z}$ and $\bar{l}$ using Eqn.~\ref{computedJointpWTS}\;
       Update variables $N_{d,j}, N_{d,j,k}$, $N_{j,k,i}, N_j,k$ and $N_d$ using the new topic label $\bar{z}$ and sentiment label $\bar{k}$\;
}
}
\For{every 5 iterations}
{Update hyperparameter $\bar{\alpha}$ with the maximum likelihood estimation according to Eqn~\ref{mAlpha} as discussed below}
\eIf{number of iterations $\geq$ {\em max} Gibbs sampling iterations}
{Update the matrices $\Theta, \Pi$ and $\Phi$ with new sampling results given by Eqns~\ref{Mtheta},~\ref{Mpi} and~\ref{Mvarpsi}  }{{\rm True}}
}
%\End{}
%\Return{\mat{V}, \mat{W}$\;}
}
 \caption{Gibbs sampling procedure for LJST}
\label{GibbsLJST}
\end{algorithm}


Werner Grundlingh

unread,
Dec 9, 2018, 6:04:18 PM12/9/18
to latexus...@googlegroups.com
I can't replicate your behaviour. This code generates this output:

image.png

The algorithm is contained within a single column. Can you be more specific in what you're after or provide a complete, minimal example that replicates your behaviour?

--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to latexusersgro...@googlegroups.com.
To post to this group, send email to latexus...@googlegroups.com.
Visit this group at https://groups.google.com/group/latexusersgroup.
For more options, visit https://groups.google.com/d/optout.

Suman Roy

unread,
Dec 11, 2018, 1:51:01 AM12/11/18
to latexus...@googlegroups.com
Hi Werner,

Thank you for you reply. As you can see that the algorithm occupies the whole of the column. I want to insert more text in the same column, which I cannot do. 

Hope I have been able to explain my problem.

regards,
--Suman
Reply all
Reply to author
Forward
0 new messages