3

I want to put a listing next to a schematic in one figure. The template of the journal, I am writing my article for, suggests using subfloats.

Here is my latex sourcecode,

\lstset{
    numbers=left,   
    firstnumber=1,
    numberfirstline=true
    numbers=left,% display line numbers on the left side 
    numberstyle=\scriptsize,% use small line numbers 
    numbersep=10pt,% space between line numbers and code 
    breaklines=true,% automatic line breaking     
    columns=flexible,
    frame=tb,
    mathescape=true,
    xleftmargin=2em,
    framexleftmargin=2em,
    morekeywords={input, output, clb, pinlist, subblock, tcon, parameter}
}
\newsavebox{\tconlist}
\begin{lrbox}{\tconlist}% Store first listing
\small
\begin{lstlisting}
.parameter $sel_0$
.parameter $sel_1$

.input i0
pinlist: i0p
.input i1
pinlist: i1p
.input o0
pinlist: o0p

.output o1
pinlist: o1p

.tcon i0p o0p $\neg sel_0$
.tcon i0p o1p $\neg sel_1$
.tcon i1p o0p $sel_0$
.tcon i1p o1p $sel_1$
\end{lstlisting}
\end{minipage}
\end{lrbox}

\begin{figure}
\subfloat{\usebox{\tconlist}}
\hfill
\subfloat{\includegraphics[width=0.25\textwidth, trim = 60mm 80mm 145mm 35mm, clip]{2x2crossbar_schema}} 
\caption{A schematic of a $2{\times}2$~crossbar switch functionality represented by 4 TCONs and the corresponding TCON netlist}
\label{fig:2x2crossbar}
\end{figure}

This results in the following image, enter image description here

How can I align the two floats to the top of the page?

2

By default, minipages are vertically centered. That is, their anchor point is given halfway up/down the minipage. Since you're placing the lstlisting inside a minipage, it makes sense that it's anchored in the middle.

What you're looking for is either a [t]op or [b]ottom-aligned minipage:

\newsavebox{\tconlist}
\begin{lrbox}{\tconlist}% Store first listing
\small\begin{minipage}[b]{<len>}% Perhaps also try [t]
\begin{lstlisting}
%...
\end{lstlisting}
\end{minipage}
\end{lrbox}

Your Answer

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

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