TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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

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:


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
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

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