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.

In my LaTeX documents I tend to use a huge number of examples based on \usepackage{gb4e} (\begin{exe} \ex bla bla bla \end{exe}). I would like to compile a PDF file that lists all the examples in a long text (and nothing else). This file should be compiled in addition to the standard PDF (which includes the examples, too).

Does anyone know how to create this kind of pdf?

P.S. The answer to the question Produce PDFs with only the figures/tables without captions and with only the captions without figures/tables might lead to a solution but I am not able to apply it to this problem as my knowledge of LaTeX is rather limited.

share|improve this question
    
It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that shows a small sample document, and an example of the desired output you wanted to get from that document. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving the problem. –  Peter Grill Nov 18 '12 at 20:04
add comment

1 Answer

up vote 6 down vote accepted

This is a two-part answer: (a) What you ask for; (b) what you (probably) need.

Let's start with what you ask: To extract the contents of all gb4e example environments, you can use the extract package. Briefly, you name one or more environment names and it writes the contents to a file of your choice (here, myexamples.tex):

\usepackage[active, generate=myexamples, extract-env={exe}]{extract}

(If you omit the option active, extract does nothing.) This will dump just the examples in a raw file, which you can easily \input into a separate wrapper file with a proper title, margins, etc:

\documentclass{article}
\usepackage{gb4e}

\begin{document}
  \section{All my examples, nothing else}
  \begin{exe}
  \input{myexamples}
  \end{exe}
\end{document}

Disclaimer: Not tested; this is to give you the general idea. Try it out, read the extract documentation, and check back if there are problems you can't solve. You may also want to look at this for other ways to achieve the same thing.

Now for what you need: You're looking for a way to pull your examples out of a long text, probably in preparation for creating a handout. If you dump the examples, clean them up into a handout, and then change some examples in either the original text or in the handout, you'll have to re-synchronize and will eventually miss something. That's the problem with working with a copy.

A more viable solution would be to consider the beamer package, which has a built-in mechanism for allowing selected parts of your document source to be typeset: You can produce a full paper, a handout, or a slide presentation from the same document. If beamer is not your cup of tea, look for another solution along these lines (selective typesetting from a single source document), instead of dumping and editing a separate copy of your examples.

share|improve this answer
    
It took me quite some time to figure how the extract usepackage is working. But now that I got it, the extract-usepackage proves itself to be remarkably helpful. So thank you so much for this answer. Here my minimal working solution. Just in case other users are trying desperately as well. \documentclass[14pt]{book} \usepackage[active, copydocumentclass=true, generate=myitems, extract-env={exe}]{extract} \usepackage{gb4e} \begin{extract} \usepackage{gb4e} \end{extract} \begin{document} \begin{exe} \ex asdf \end{exe} \end{document} –  Philip Dec 25 '12 at 16:01
add comment

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.