
我想minted
在使用時在環境中插入一些程式碼beamer
。
\documentclass[14pt]{beamer}
\usepackage{minted}
\begin{document}
\begin{frame}[fragile]{}
\begin{figure}
\centering
\begin{minted}[mathescape,
gobble=2,
linenos,
fontsize=\tiny,
framesep=2mm]{ocaml}
let process il =
let module IV = Instr_visitor in
let visit i t = instrument i t in
IV.map_instr IU.is_mem_write visit il
|> insert_instr_list BEFORE !il_update
\end{minted}
\end{figure}
\end{frame}
\end{document}
但是,即使我使用該centering
命令,它也無法集中。有人能闡明如何集中它嗎?謝謝你!
更新:這就是它的樣子:
答案1
只要放入足夠寬度的minted
裡面即可minipage
。然後將其放入center
環境中。
(我不確定你為什麼要使用figure
。你需要它是一個浮動嗎?)
\documentclass[14pt]{beamer}
\usepackage{minted}
\begin{document}
\begin{frame}[fragile]{}
\begin{center}
\begin{minipage}{0.5\textwidth}
\begin{minted}[mathescape,
gobble=2,
linenos,
fontsize=\tiny,
framesep=2mm]{ocaml}
let process il =
let module IV = Instr_visitor in
let visit i t = instrument i t in
IV.map_instr IU.is_mem_write visit il
|> insert_instr_list BEFORE !il_update
\end{minted}
\end{minipage}
\end{center}
\end{frame}
\end{document}