
我正在準備演示文稿,並且正在使用投影機模板。我必須增加特定演算法的字體大小(這不是全域變更)。乳膠代碼是:
\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}
我不知道該怎麼做。有人可以幫我嗎?提前致謝。
答案1
為了更改特定框架的字體大小,您可以在框架的開頭發出任何字體大小更改命令(類似於中討論的內容)如何在文件中的一小部分文字中使用特定字體?)。如果您對您想要的特定尺寸感興趣,請參閱\Large 等字體大小是多少磅(pt)?
下面我重新建立了您的設置沒有更改字體大小,因為否則演算法不適合。不過,我已經指出了可以放置字體大小指令的位置。其他變更包括重新定義控制結構的功能方式 - 您似乎在分組之後{
......}
來界定範圍。
\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}