I'm already aware that two minipages with [t] align at the baseline of the top line, not at the top of their respective boxes/containers; however, this is somewhat different: when I use a small minipage with one letter, and a minipage with lstlisting, and try to align them on top as on the below MWE, I get this (using lua-visual-debug
):
I really don't understand - what is that pushing the listing minipage down, a linebreak? Where did that come from? How could I get these two items aligned on top (such that the A
remains where it is - and the listing+minipage move vertically up to match it)?
By the way, notice that in the MWE below - the second example, with two minipages with lstlisting each, works without a problem:
\documentclass{article}
%\usepackage{lua-visual-debug}
\usepackage{listings}
\begin{document}
Test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test ...
\begin{minipage}[t]{1em}
A
\end{minipage}
\hfill
\begin{minipage}[t]{\dimexpr\textwidth-2\parindent-2.2em}%
\begin{lstlisting}
sslg kaha kshd kajshd
asl q7ey q[peo [pdv
sdfk a9su qpowie e
asj asy dqoi poai
\end{lstlisting}
\end{minipage}
Test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test sentence test ...
% http://tex.stackexchange.com/questions/36712/how-to-place-two-code-/36737
\begin{minipage}[t]{0.45\linewidth}
\begin{lstlisting}[caption={Some XML Caption}]
.. xml code ...
.. xml code ...
.. xml code ...
.. xml code ...
.. xml code ...
.. xml code ...
\end{lstlisting}
\end{minipage}
%
\begin{minipage}[t]{0.45\linewidth}
\begin{lstlisting}[caption={Some Javascript Caption}]
... javascript code ...
... javascript code ...
... javascript code ...
\end{lstlisting}
\end{minipage}
\end{document}