Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using and enjoying the algorithmicx package, but would like to adjust the size of its indentations.

In the algorithms package, I could do this with \algsetup{indent=1em}, but that doesn't seem to work here.

Any thoughts?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

You can renew the internal command \algorithmicindent:

\algrenewcommand\algorithmicindent{2.0em}%

Change the 2.0em to whatever you wish.

Here is a MWE extracted from the documentation and adapted:

\documentclass{article}
\usepackage{algorithmicx}
\usepackage[ruled]{algorithm}
\usepackage{algpseudocode}
\usepackage{algpascal}
\usepackage{algc}
\newcommand{\euk}{Euclid}
\algrenewcommand\algorithmicindent{2.0em}%
\begin{document}
\begin{algorithmic}[1]
\algrenewcommand{\algorithmiccomment}[1]{\hskip3em$\rightarrow$ #1}
\State $x\gets x+1$\Comment{Here is the new comment}
\end{algorithmic}
\alglanguage{pseudocode}
\begin{algorithm}[H]
\caption{\euk's algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{\euk}{$a,b$}\Comment{The g.c.d. of a and b}
   \State $r\gets a\bmod b$
   \While{$r\not=0$}\Comment{We have the answer if r is 0}
      \State $a\gets b$
      \State $b\gets r$
      \State $r\gets a\bmod b$
   \EndWhile\label{euclidendwhile}
   \State \Return $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}
share|improve this answer
1  
Awesome, thank you! –  Richard Mar 12 '12 at 20:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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