7

I am creating SVG files from different stuff from my LaTeX document. For this, I am using the standalone package followed by pdf2svg.

This compiles:

\documentclass{article}
\usepackage{algorithmicx}
\usepackage{algpseudocode}

\begin{document}
    \begin{algorithmic}
        \Function {$foo$}{$id$}
        \EndFunction
    \end{algorithmic}
\end{document}

Using standalone instead of article crashes with:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.8             \Function
                 {$foo$}{$id$}

What can I do? I need to export my algorithms to PDF/SVG.

My versions:

  • standalone.cls 2012/05/20 v1.1a
  • algorithmicx.sty 2005/04/27 v1.2

UPDATE: 27.06.2012 The same is happening with align:

\begin{document}
    \begin{align*}
    a\\
    b
    \end{align*}
\end{document}

The v-box hack helps:

\begin{document}
\vbox{
    \begin{align*}
    a\\
    b
    \end{align*}
}
\end{document}
David Carlisle
  • 757,742
Dennis
  • 819
  • 9
  • 17

1 Answers1

6

Use either the preview or the varwidth class option of standalone. As described in the manual the default is crop (not preview) since v1.0 and this does not support paragraphs or lists (and the mentioned environments are apparently based on lists).

Martin Scharrer
  • 262,582
  • Fyi: the manual for v1.1a says in the Introduction: The class uses by default the preview package – Dennis Jun 28 '12 at 15:08
  • @Dennis: Mmm, maybe there is some old sentence somewhere. The description of the options however clearly states that crop is the default. – Martin Scharrer Jun 28 '12 at 18:59
  • you're right. Because of that sentence I'm using crop so far. So I can just skip it :) – Dennis Jun 28 '12 at 21:09
  • Unfortunately, this fix doesn't work for me. Maybe because I'm also using a class class option? But when I use \documentclass[preview, class=myclass]{standalone}, I keep getting the error as above. – Czechnology May 25 '17 at 20:58
  • @Czechnology: Please provide a minimal working example which causes this error for you. You can post a follow-up question for this. – Martin Scharrer May 27 '17 at 13:01