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.

My objective is to create a long tabular list of PSTricks inputs and their corresponding outputs side by side.

The table consists of 3 columns, i.e., Number column, Input column, & Output column. The Number column contains hyperlinks to the source code files. For example: if a reader is interested to draw a figure of torus, he just need search in the table and click the number to open its corresponding source code file.

Shortly speaking, how to separate the input and output of LTXexample? My rough idea is as follows:

  1. I just pass in the PSTricks routines to a macro in the Input column.
  2. The macro then provides a saved box containing the output.
  3. Then I call another macro (like \usebox) to retrieve the saved box and insert it to the Output column.
  4. I do step 1-3 for each row. Hyperlink numbers can be easily made using \url (it is not a big problem).
share|improve this question
Is this a proper tabular you want to put things in or do you really really need input and output to be entirely separable, possibly on different pages, possibly the output after another LTXexample etc.? –  Ulrich Schwarz Dec 12 '10 at 13:40
Thank for commenting. Actually I just need an immediate output handle for each LTXexample call such that I make 3-column rows in a longtable. Each row is composed of LTXexample in the middle column and its corresponding output handle on the most right column. The most left column displays labels of increasing number. It is more than enough. –  xport Dec 12 '10 at 14:13
add comment

3 Answers

I wouldn't use a tabular for this. You will have problems with the page breaks. Also it will be difficult to adjust the spaces for the code and the output: sometimes you will probably have a small output but large code lines or the other way round. I would simply put the code and the output side by side with showexpl and use minipage+enumerate or something else to place the numbers.




share|improve this answer
add comment

Since there have been no LaTeX solution, I will post a ConTeXt solution to give some ideas.

The standard way of doing this soft of thing in ConTeXt is buffers. For example:

 This is a simple metapost example.
   draw fullcircle scaled 5cm ;



  \NC Input                  \NC Output               \NC \NR
  \NC \typebuffer[example1]  \NC \getbuffer[example1] \NC \NR


If the snippets are already stored in an external file, then another option is:

   \NC \typefile[example1.tex] \NC \externalfigure[example1.tex] \NC \NR

When \externalfigure, which is equivalent to \includegraphics in LaTeX, is given a TeX file, it typesets it in a box and includes the result.

share|improve this answer
Thank you. But it will not be usefull for me because I use latex. :-) Your name sounds like Indonesian name. –  xport Dec 14 '10 at 7:34
If this works for you, then it is relatively easy to port these commands to LaTeX. For the first approach, see this thread. For single page images, the second approach is basically equivalent to \input the file in a minipage and scaling the result. –  Aditya Dec 14 '10 at 11:01
add comment

Maybe a small step in the right direction: instead of producing output, we define two commands \LTXlastexample{in/out}put that still need the width they are to be typeset into. This will require you to output both parts before you issue the next LTXexample, and I've not given much thought to whether it will work beyond my example case, in a spirit of "what could possibly go wrong?"



    Hello, world


  \LTXlastexampleinput{5cm} &  \LTXlastexampleoutput{5cm}

share|improve this answer
how can we make two rows or more? –  xport Dec 12 '10 at 14:26
@xport: funny, having an LTXexample of this type in a tabular doesn't appear to work. –  Ulrich Schwarz Dec 14 '10 at 12:17
I got the solution. It is no longer funny. :-) –  xport Dec 16 '10 at 11:30
add comment

Your Answer


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.