2

I'm trying to get two listings side by side. One is shorter than the other, but I would like to have them aligned, meaning that the frame height of the short one should be longer to reach the baseline of the first. I am using minipages to put the listings in a single row.

My current code is:

\documentclass[11pt,a4paper,italian,oneside]{book}
\usepackage{listings}
\begin{document}

\begin{center}
\begin{minipage}[t]{.49\textwidth}
\lstinputlisting[breaklines, language=Python, caption=Struttura dati Kinematic, 
   label=kinematic,tabsize=3, captionpos=b, frame=single, basicstyle=\small]
   {listings/chapter02/kinematic.py}
\end{minipage}
\hfill
\begin{minipage}[t]{.49\textwidth}
\lstinputlisting[breaklines, language=Python, caption=Struttura dati SteeringOutput, 
   label=steeringoutput,tabsize=3,captionpos=b,frame=single, basicstyle=\small
   {listings/chapter02/steeringoutput.py}
\end{minipage}
\end{center}

\end{document}

(I know that I can define separately the formatting settings, this is a fast example :P)

For now the result is: enter image description here

I tried some of the parameters listed on the listings documentation but I did not succeeded. Any advice?

  • Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Aug 20 '14 at 13:33
  • 1
    That's not easily doable with listings. Besides, you may confuse your readers: they may think that those blank lines you padded the right-hand side listing at the end really are present in the code. – jub0bs Aug 20 '14 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.