11

I wish to typeset a document and only include occurrences of one specific environment for the output.

One thing I tried was using the comment package and putting \begin{comment}just after \begin{document} and \end{comment} just before \end{document}. Then I redefined the environment I wanted to include to begin with \end{comment} and end with \begin{comment}. This way only this environment should be uncommented. It compiled fine but gave no page as output.

Another option might be to use the tagging package, but as far as I understand this lets you exclude certain parts. I want to do the opposite, only include certain parts.

EDIT: The background is that I am working on a thesis in linguistics with a large number glossed and numbered examples (sentences with detailed morpheme-by-morpheme translations). There are around hundred of them in total spread around the text and they are all in an example environment from the covington package. I want to generate a document containing only the examples to proofread them extra carefully and to check them against the recordings they are transcribed from.

5
  • 2
    Why don't you just comment the rest out? Please provide a Minimal Working Example which illustrates the problem you are experiencing and gives us some idea of what you are trying to do.
    – cfr
    Commented May 30, 2014 at 0:33
  • Have a look at the package: extract.
    – Pierre
    Commented May 30, 2014 at 0:51
  • @cfr: Commenting stuff out is not always an option, especially if you are deciding during compile time whether to include some material or not - for instance via a command line option. Commented May 30, 2014 at 6:06
  • @PeterGrill Sure. My point was just that the question wasn't really detailed enough to give a clear picture of what might or might not work as a solution.
    – cfr
    Commented May 30, 2014 at 21:01
  • 1
    @cfr I'll expand the question a bit to make it clearer.
    – Andreas
    Commented May 31, 2014 at 13:12

2 Answers 2

10

You can use xcomment package. Put the environment to be typeset inside the argument of \xcomment macro like:

\xcomment{enumerate}   %% only enumerate environment is typeset

Code:

\documentclass{article}
\usepackage{xcomment}
 \xcomment{enumerate}   %% only enumerate environment is typeset
\begin{document}
  \begin{enumerate}
    \item Enumerate item
  \end{enumerate}
  \begin{itemize}
    \item itemize item
  \end{itemize}
  \begin{figure}
    A figure
  \end{figure}
  \begin{table}
    A table
  \end{table}      
\end{document}

enter image description here

3
  • 2
    There is also the package extract
    – Pierre
    Commented May 30, 2014 at 0:50
  • Doesn't seem to work if there is an itemize within an enumerate - don't know if the OP requires that though. Commented May 30, 2014 at 6:03
  • Works perfectly for my purposes. Surprisingly simple solution.
    – Andreas
    Commented May 30, 2014 at 9:57
3

If your document is not that big, you can selectively de-activate environments using the environ package:

\documentclass{article}
\usepackage{environ}

% environ: 2013/04/01 v0.3 and earlier
\makeatletter
\providecommand{\env@itemize@save@env}{}
\providecommand{\env@itemize@process}{}
\providecommand{\env@figure@save@env}{}
\providecommand{\env@figure@process}{}
\providecommand{\env@table@save@env}{}
\providecommand{\env@table@process}{}
\makeatother

\RenewEnviron{itemize}{}% De-activate itemize
\RenewEnviron{figure}[1][]{}% De-activate figure
\RenewEnviron{table}[1][]{}% De-activate table

\begin{document}

\begin{enumerate}
  \item Enumerate item
\end{enumerate}

\begin{itemize}
  \item itemize item
\end{itemize}

\begin{figure}
  A figure
\end{figure}

\begin{table}
  A table
\end{table}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .