Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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

1 Answer 1

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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