我有以下 MWE:
\documentclass{beamer}
\usepackage{tikz}
\usepackage[ruled,linesnumbered]{algorithm2e}
\begin{document}
\begin{frame}[t]{}
\begin{minipage}{0.5\textwidth}
\begin{algorithm}[H]
algo1-line1\\
algo1-still line 1 but in the next line\\
algo1-line2\\
algo1-line 3
\end{algorithm}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{algorithm}[H]
algo2-line1\\
algo2-line2\\
algo2-still line 2 but in the next line\\
algo2-line 3
\end{algorithm}
\end{minipage}
\end{frame}
\end{document}
我的目标是让两种算法并列,并让线路“同步”,即以下是我想要的输出:
(1) algo1-line1 algo2-line1
algo1-still line 1 but in the next line
(2) algo1-line2 algo2-line2
algo2-still line 2 but in the next line
(3) algo1-line 3 algo2-line 3
有人能帮我解决这个问题吗?提前谢谢
答案1
也许你可以把宽度缩小一点
\documentclass{beamer}
\usepackage{tikz}
\usepackage[ruled,linesnumbered]{algorithm2e}
\begin{document}
\begin{frame}[t]{}
\begin{minipage}{0.45\textwidth}
\begin{algorithm}[H]
algo1-line1\\
algo1-still line 1 but in the next line\\
algo1-line2\\
algo1-line 3
\end{algorithm}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
\begin{algorithm}[H]
algo2-line1\\
algo2-line2\\
algo2-still line 2 but in the next line\\
algo2-line 3
\end{algorithm}
\end{minipage}
\end{frame}
\end{document}