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