[Tex/LaTex] Adding additional blank lines in Minted

mintedpython

I currently have two minted environments in each their minipage environment, so that they can be situated next to each other:

\begin{figure}[!h]
\centering
\begin{minipage}{0.45\linewidth}

\begin{python}
  from pycsp_import import *

  @process
  def producer(cout):
    for i in [1,2,3,4,5]:
      cout(i)
    retire(cout)

  @process
  def worker(cin):
    while True:
      print cin()

  c = Channel()

  Parallel(
    producer(-c),
    worker(+c)
  )
\end{python}

\end{minipage}
\qquad
\begin{minipage}{0.45\linewidth}

\begin{python}
  1
  2
  3
  4
  Exception













  .
\end{python}

\end{minipage}
\end{figure}

Is there a way to get rid of the need of the .. Can I somehow tell minted that there should be 19 lines, so that the two python environments are the same height?

Best Answer

If you want to do this you have to change the compilation by pygmentize. The required option is stripnl. For more details see: Available lexers

To set the option to the run you have to change the internal definition:

\makeatletter
\renewcommand\minted@pygmentize[2][\jobname.pyg]{
  \def\minted@cmd{pygmentize -l #2 -f latex -F tokenmerge
    \minted@opt{gobble} \minted@opt{texcl} \minted@opt{mathescape}
    \minted@opt{startinline} \minted@opt{funcnamehighlighting}
    \minted@opt{linenos} -P "verboptions=\minted@opt{extra}"
    -O stripnl=false -o \jobname.out.pyg #1}
  \immediate\write18{\minted@cmd}
  % For debugging, uncomment:
  %\immediate\typeout{\minted@cmd}
  \ifthenelse{\equal{\minted@opt@bgcolor}{}}
   {}
   {\begin{minted@colorbg}{\minted@opt@bgcolor}}
  \input{\jobname.out.pyg}
  \ifthenelse{\equal{\minted@opt@bgcolor}{}}
   {}
   {\end{minted@colorbg}}
  \DeleteFile{\jobname.out.pyg}}
\makeatother

However this influence all compilation by pygmentize. To avoid this you can declare a new option.

enter image description here

Related Question