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 want to compile a pseudocode for an algorithm into a separate pdf and then include it into my main document as a figure. However, the compiled pseudocode gets compiled into a pdf with margins and I have not been able to crop it (other than manually) to fit into a tighter box. I used pdfcrop to try to get rid of the white space, but it only removes white space at the top, left, and right, but not the bottom. I would like to be able to compile it so that it has no margins and not to have to do it manually every time I change a comma in the pseudocode.
Here is an example:

\documentclass[10pt]{article}
\usepackage{algorithm}
\usepackage{algorithmic}
\begin{document}
  \begin{algorithm}[h!]
    \begin{algorithmic}
    \caption{Precomputing densities}
    \label{alg:densities}
      \FOR{$i = 1 \to n$}
        \STATE $\mathrm{sums}[i][i] \gets 0$
      \ENDFOR
    \end{algorithmic}
  \end{algorithm}
\end{document}

Any advice?

share|improve this question
    
Does this post help? –  cmhughes Nov 3 '11 at 15:45
    
Tried using preview: produces an "Undefined control sequence." on the line with \begin{algorithm}. –  lynxoid Nov 3 '11 at 15:49
2  
Your trimming via pdfcrop probably includes the page number. Use \pagestyle{empty} for such stand-alone instances. –  Werner Nov 3 '11 at 15:53
    
That's it - removing the page number allows pdfcrop to crop it properly! Thanks a lot! –  lynxoid Nov 3 '11 at 15:57
    
My hunch was to instead use the document class standalone but when I try it I get "LaTeX Error: Not in outer par mode." –  N.N. Nov 3 '11 at 16:00

1 Answer 1

up vote 13 down vote accepted

Have you tried this with

\pagestyle{emtpy}

just below \begin{document}? This may get rid of something in the footer that pdfcrop is having trouble with.

share|improve this answer
    
It worked - removed the page number and pdfcrop cropped it alright. Thanks! –  lynxoid Nov 3 '11 at 15:57
    
That was my first ever post! You're very welcome. Glad I could help. –  qubyte Nov 3 '11 at 16:03

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.