# Displaying two XML listings side by side. [duplicate]

I have two XML outputs from a program that I would like to include in a LaTeX document. I would like them to appear side-by-side each in its own box. So that a reader can compare the two outputs while reading the document. Can't seem to find a way to do this, without making images for each output and adding both as images/graphics. Could there be a better option?

-

## marked as duplicate by Jubobs, Papiro, moewe, Svend Tveskæg, lockstepAug 16 '14 at 13:08

Your title and tag doesn't really fit the question text. Shouldn't it be titled like "Displaying two XML listings side by side"? – Martin Scharrer May 26 '11 at 10:13
Thanks, Title Edited – user739807 May 26 '11 at 10:25

You need to use some verbatim environment or macro to display source code. The listings package is good for this and provides syntax highlighting, but unfortunately not for XML.

You should place each code then into a minipage environment with a width slightly smaller than .5\textwidth. Something along:

\begin{center}
\begin{minipage}{.48\textwidth}
\lstinputlisting[breaklines]{file1.xml}
\end{minipage}
\hfill
\begin{minipage}{.48\textwidth}
\lstinputlisting[breaklines]{file1.xml}
\end{minipage}
\end{center}


The exact code depends if you need it as a floating environment, need captions etc.

-
Oh Great, the side-by-side works. I need to add a Caption for each file as well as a box around the code. – user739807 May 26 '11 at 10:26
@user739807: You could either use the title or caption option. The option frame=single should add the box. All options are comma separated inside the [ ] argument. – Martin Scharrer May 26 '11 at 10:37
I was about to comment that one should add a \noindent before the first minipage, especially if the above starts on it's own line,but I noticed you've put everything in a centered environemnt. Does this negate the need for noindent ? i.e. does centre gobble he preceeding space ? – Carel Aug 30 '15 at 21:48
@Carel: AFAIK center does generate no indent as it is a trivlist 1. It would be strange centering it with a parindent added first. That's also the reason to use {center} instead of \centering. – Martin Scharrer Sep 1 '15 at 12:37