0

I am typing an algorithm using the following preamble

\usepackage{algorithm}
\usepackage{algpseudocode}
\algnewcommand{\LeftComment}[1]{\(\triangleright\) #1}%
\algrenewcommand\algorithmicindent{0.6em}%

The whole algorithm has a indentation to the left as shown in the image below. How can I remove this indent?

enter image description here

This is the algorithm code

{\begin{algorithm}[H]
  \floatname{algorithm}{Alg.}
  \caption{Projected SGD for Model A, Batch Size=1}\label{alg:tellmain}
  \begin{algorithmic}%[1]
    \State Given: $\cF, \cFc$. Hyperparameters: $\alpha, \eta, \rS$.
    \For{each fact $f' \in \cF$}
    \State Mark $f'$ as seen.
    \For{$\rS$ steps}
    \State Sample $\fc = (\bar{t}, \bar{r})$ from $\cFc$.
    \State Set $f = f'$ with $p=0.5$,
    \State $\qquad$or sample $f$ from seen facts.
    \State Let $\vvv = \sigma(\ip{\rc}{\tc} - \ip{\r}{\t})$.
    \State \LeftComment{Fix $\e$ and optimize ${J}$}.
    \State {\small $\grad{\r}{\Jr} = {-\t}\vvv, \ \grad{\rc}{\Jr} = {\tc}\vvv$}
  \State {\small$ (\r; \rc) = \proj((\r; \rc) - \eta ((\grad{\r}{\Jr}; \grad{\rc}{\Jr}) + 2\alpha (\r; \rc)))$}
    \State \LeftComment{Fix $\r$ and optimize ${J}$}
    \State {\small$\grad{\t}{\Je} = {-\r}\vvv, \ \grad{\tc}{\Je} = {\rc_1}\vvv$}
    \State {\small $(\t; \tc) = \proj((\t; \tc) - \eta ((\grad{\t}{\Jr}; \grad{\tc}{\Jr}) + 2\alpha (\t; \tc)))$}
    \EndFor
    \EndFor
  \end{algorithmic}
\end{algorithm}}
1

I am not sure there is an easy way. Here is a hack:

\usepackage{xpatch}

\makeatletter
\xpatchcmd{\algorithmic}
  {\ALG@tlm\z@}{\leftmargin\z@\ALG@tlm\z@}
  {}{}
\makeatother

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.