Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
1  
you are a god amongst men! It works just as expected. –  Mads Ohm Larsen Apr 30 '12 at 20:22
add comment

If you used

 \begin{minipage}[t]{0.45\linewidth}
                 %%%

they would line up on the first line even if different sizes/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.