1

I have a lstlisting environment in one column and an included picture in the other. according to the MWE, the following is printed:

enter image description here

MWE:

\documentclass[10pt]{article}
\usepackage[margin=0.75in, top=1in]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{kotex, titlesec, titletoc, fancyvrb, graphicx, caption, fancyhdr, float,
enumerate, listings, multirow, xcolor}
\lstset{showstringspaces=false}
\input{arduinoLanguage}
    % .tex file provides additional settings specifically for Arduino language

\begin{document}
\section{•}

\section{•}
\vspace{-15pt}
\begin{center}
\begin{tabular}{p{0in} p{.45\textwidth} p{0in} p{.45\textwidth}}
&\lstinputlisting[language=Arduino,caption={\scshape Lab 08 -- 2}]
{"Code/Group35_Lab08-2/Group35_Lab08-2.ino"}&&
\centering\includegraphics[scale=.65]{"Images/2"}
\captionof{figure}{Serial Monitor Result of \scshape Lab 08 -- 2}
\end{tabular}
\end{center}

\end{document}

How can I have the lstlisting environment stay at the top of the tabular environment, right next to the picture?

  • Do you have tried anything with minipage? – Sebastiano Dec 1 '18 at 13:04
  • No, the code I use needed tabular before for equal height reasons. But this question is as theoretical as it is practical - why does this happen in the first place? – Paul Kim Dec 2 '18 at 18:28
  • Just to add, with a few tweakings in the minipage environment, the vertical alignment issue can be solved; however, I'm still looking for the answer to this question. Is it just a bug, or is there a reasonable explanation to this? – Paul Kim Dec 4 '18 at 16:46
  • Your code can not be compiled and tested - we have neither the image nor the file you input and the • will probably give errors. – Ulrike Fischer Dec 5 '18 at 9:01
  • Welll actually the error should spawn from \input{arduinoLanguage} and the lstinputlisting setting of language=Arduino. So if you can't compile it, delete the \input line, and change the language option to one natively supported by the listings package. The dots are just placeholders - they shouldn't be causing a problem. (It's actually a Texmaker IDE setting for a specific macro) – Paul Kim Dec 5 '18 at 10:00