# Algorithms on flash cards

I'm trying to put together flash cards with algorithms on it. I get the following error:

! LaTeX Error: Not in outer par mode.

I've got two question:

• What is the reason for this error?
• How can I fix it?

I've got the error using the following code:

\documentclass[grid,avery5371]{flashcards}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[ruled,vlined,rightnl,linesnumbered]{algorithm2e}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\cardbackstyle[\LARGE\bfseries]{plain}

\begin{document}

\begin{flashcard}[graph]{\textsc{dfs}}
\begin{algorithm}
\caption{DFS(G)}
\For{u $\in$ G.V}{
u.color $\gets$ \textsc{white} \\
u.$\pi$ $\gets$ \textsc{nil} \\
}
\For{u $\in$ G.V}{
\If{u.color = \textsc{white}}{
\textsc{dfs-visit}(G, u)
}
}
\end{algorithm}
\end{flashcard}

\end{document}

• Aha. Algorithm2e produces a float, unless you use [H]. Unfortunately, I'm having problems with flashcard even without the algorithm code. – John Kormylo Jul 2 '17 at 4:05
• I had to manually load the avery5371.cfg file (not provided with MikTeX). – John Kormylo Jul 2 '17 at 15:57

At first I thought the text was too big, but \cardheight corresponds to two grid cells.

\documentclass[grid,avery5371]{flashcards}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[ruled,vlined,rightnl,linesnumbered]{algorithm2e}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}

\cardbackstyle[\LARGE\bfseries]{plain}

\usepackage{graphicx}

\begin{document}

\begin{flashcard}[graph]{\textsc{dfs}}
\scalebox{.8}{\begin{algorithm}[H]
\caption{DFS(G)}
\For{u $\in$ G.V}{
u.color $\gets$ \textsc{white} \\
u.$\pi$ $\gets$ \textsc{nil} \\
}
\For{u $\in$ G.V}{
\If{u.color = \textsc{white}}{
\textsc{dfs-visit}(G, u)
}
}
\end{algorithm}}
\end{flashcard}

\end{document}