3

I'm preparing a presentation and I'm using a beamer template. I must to increase the font size of a specific algorithm (it's not a global change). The latex code is:

\begin{frame}{Serial Breadth-First Search}
\begin{algorithm}[H]
\begin{algorithmic}[1]
\Require Graph G, Node root
\Worklist $wl$ = \{ root \};
\State root.level = 0;
\While{($wl \neq \emptyset$)}
    \State $u = DEQUEUE(wl)$;
    \ForEach{($v \in Vertices(G)$ such that $(u, v) \in Edges(G)$)} \{ 
        \hspace{.3cm} \textit{// Neighbors of u}
            \If{(v.level $>$ u.level + 1)} \{
                \State v.level = u.level + 1;
                \State $ENQUEUE(wl, v)$; 
            \EndIf
    \EndFor \State \} \}
\EndWhile \State \}
\end{algorithmic}
\end{algorithm}
\end{frame}

I don't know how to do it. Could someone help me? Thanks in advance.

2

In order to change the font size for a specific frame, you can issue any one of the font size changing commands at the beginning of the frame (similar to what is discussed in How do I use a particular font for a small section of text in my document?). For an interest in the specific size you're after, see What point (pt) font size are \Large etc.?

Below I've recreated your setup without changing the font size since the algorithm wouldn't fit otherwise. However, I've indicated where you can place your font size command. Other changes include redefining the way the control structures function - you seem to be after a grouping { ... } to delimit the scope.

enter image description here

\documentclass{beamer}

\usepackage{algorithm,algpseudocode}

\algrenewtext{For}[1]{\algorithmicfor\ (#1)\ \{}
\algrenewtext{EndFor}{\}}
\algrenewtext{If}[1]{\algorithmicif\ (#1)\ \algorithmicthen\ \{}
\algrenewtext{EndIf}{\}}
\algrenewtext{While}[1]{\algorithmicwhile\ (#1)\ \algorithmicdo\ \{}
\algrenewtext{EndWhile}{\}}
\algnewcommand{\Worklist}{\item[\textbf{Worklist:}]}

\begin{document}

\begin{frame}{Serial Breadth-First Search}
  % \tiny \scriptsize \footnotesize \small % <------ make font smaller
  % \normalsize % <--------------------------------- normal font size
  % \large \Large \LARGE \Huge % <------------------ make font larger
  \begin{algorithmic}[1]
    \Require Graph G, Node root
    \Worklist $wl$ = \{ root \};
    \State root.level = 0;
    \While{$wl \neq \emptyset$}
      \State $u = DEQUEUE(wl)$;
      \For{$v \in Vertices(G)$ such that $(u, v) \in Edges(G)$}
        \hspace{.3cm} \textit{// Neighbors of u}
        \If{v.level $>$ u.level + 1}
          \State v.level = u.level + 1;
          \State $ENQUEUE(wl, v)$;
        \EndIf
      \EndFor
    \EndWhile
  \end{algorithmic}
\end{frame}

\end{document}
  • It didn't work for me. Could it be because the beamer template I'm using? – tnas Jan 25 '17 at 18:06
  • @tnas: When you use my minimal example and add (say) \LARGE where I suggest, does it increase the font size? If it doesn't work in your instance, I'd suggest providing a complete, minimal working example (MWE) that replicates your problem. – Werner Jan 25 '17 at 18:30
  • I'm using this template: lumc. It's compiled with lualatex. – tnas Jan 25 '17 at 19:17

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.