6

I would like to insert some code inside the minted environment when using 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}

However, it just cannot be centralized even though I use the centering command. Could anyone shed some light on how to centralize it? Thank you!

Update: This is how it looks here:

enter image description here

7

Just put minted inside a minipage of sufficient width. Then put this inside a center environment.

(I am not sure why you are using figure. Do you need this to be a float?)

\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}

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.