LaTex排版技巧(一)

演示文稿

beamer

1.算法

宏包web

\usepackage{algorithmic}
\usepackage[boxed,ruled,lined]{algorithm2e}

代码算法

\begin{frame}[plain,t]
\frametitle{The feedback vertex set problem in undirected graphs}
\vspace{3ex}
\xiaowuhao
\begin{algorithm}[H]\label{alg}
    \scriptsize
    \caption{Primal-dual algorithm for the feedback vertex set problem  
        (first attempt)}
    \begin{algorithmic}[1]
        \label{alg1}
        \STATE $y \leftarrow 0 $
        \STATE $S \leftarrow \varnothing $

        \WHILE {there exists a cycle \textit{C} in \textit{G}}
        \STATE Increase ${y}_{C}$ until there is some $\ell \in C$ such that $\sum _{{C}^{\prime }\in \mathcal{C}:{\ell}\in {C}^{\prime }}{y}_{{C}^{\prime }}={w}_{\ell}$ 
        \STATE  $S \leftarrow S\cup \left\{\ell \right\}$
        \STATE Remove $\ell$ from $G$
        \STATE Repeatedly remove vertices of degree one from $G$
        \ENDWHILE
        \RETURN \textit{S}
    \end{algorithmic}
\end{algorithm}

\end{frame}

效果图:
这里写图片描述svg

2.优化问题

\begin{frame}[plain,t]
\frametitle{The set cover problem: a review}
\vspace{3ex}
\xiaowuhao
We observed in Section 1.5 that the set cover problem can be modelled as the following integer program:

\begin{alignat}{2}
\min\quad &\sum _{j=1}^{m}{w}_{j}{x}_{j} &{}& \tag{7.1}  \\
\mbox{s.t.}\quad \tag{7.2}
&\sum _{j:{e}_{i}\in {S}_{j}}{x}_{j}\ge 1 &\quad& i=1,\cdots,n, \\
&{x}_{j}\in \left\{0,1\right\} &{}& j=1,\cdots,m.\tag{7.3}
\end{alignat}

\end{frame}

效果图:
这里写图片描述优化

3.引用图片

\begin{frame}[plain,t]
\frametitle{The generalized Steiner tree problem}
\vspace{3ex}
\xiaowuhao

    \begin{figure}
		\centering
		\includegraphics[width=.7\textwidth]{figure//p4.png} %图片文件的相对路径
		\caption{Bad example for Algorithm 5. If the algorithm chooses the vertex $ {s}_{1},\cdots,{s}_{4} $ as its initial connected component $ C $, then it will eventually add all solid
			edges to $ F $, and $ |\delta (C) \cap F| = 4 $.} %caption是图片的标题
		%\caption*{heading}可去掉前面的 Figure 4
		\label{img} %此处的label至关于一个图片的专属标志,目的是方便上下文的引用
	\end{figure}

\end{frame}

效果图:
这里写图片描述spa