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.

Below is part of the code for my notes. I would like to "easily" create a new document displaying only the definitions, theorems, and lemmas. I can copy and paste this and just delete what I do not want, but if there is an easier way, that would be great.

\documentclass[12pt,letterpaper]{article}

\usepackage{amsmath}    % just math
\usepackage{amssymb}    % allow blackboard bold (aka N,R,Q sets)
\usepackage{amsthm} % allows thm environment
\usepackage{mathrsfs}
\usepackage{graphicx, framed} % allows graphics
\usepackage[none]{hyphenat} % allows graphics
\usepackage[usenames,dvipsnames]{color}
\usepackage{color}
\usepackage{wrapfig}
\definecolor{Def}{rgb}{0.85,0.65,0.13}
\definecolor{Ex}{rgb}{0,0.39,0}
\definecolor{Nt}{rgb}{1,0.08, 0.58}
\definecolor{Tm}{rgb}{0,0,0.80}
\definecolor{Pf}{rgb}{1,0.55,0}
\definecolor{white}{rgb}{1,1,1}
\linespread{1.6}    % double spaces lines

\textwidth 6.5truein  % These 4 commands define more efficient margins
\textheight 9.4truein
\oddsidemargin 0.0in
\topmargin -0.6in

\parskip 5pt  % Also, a bit of space between paragraphs

\newtheorem{theorem}{\color{Tm}{\textbf{\underline{Theorem}}}}
\newtheorem{cor}{\color{Tm}{\textbf{\underline{Corollary}}}}
\newtheorem{prop}{\color{Tm}{\textbf{\underline{Proposition}}}}
\newtheorem{claim}{\color{Tm}{\textbf{\underline{Claim}}}}
\theoremstyle{definition}\newtheorem{definition}{\color{Def}{\textbf{\underline{Definition}}}}
\newtheorem{lemma}{\color{Tm}{\textbf{\underline{Lemma}}}}
\newtheorem{exer}{\color{Plum}{\textbf{\underline{Exercise}}}}
\theoremstyle{definition}\newtheorem{note}{\color{Nt}{\textbf{\underline{Note}}}}
\theoremstyle{definition}\newtheorem{example}{\color{Ex}{\textbf{\underline{Example}}}}
\newtheorem{sidebar}{\color{Aquamarine}{\textbf{\underline{Sidebar}}}}
\newtheorem{pf}{\color{BurntOrange}{\textbf{\underline{Proof}}}}

\newcommand{\QEDend}{\linebreak \begin{flushright}\textbf{QED}\end{flushright}}
\newcommand{\QEDish}{\linebreak \begin{flushright}\textbf{$\approx$QED}\end{flushright}}
\newcommand{\bb}[1]{\mathbb{#1}}
\newcommand{\mcal}[1]{\mathcal{#1}}
\newcommand{\scr}[1]{\mathscr{#1}}
\newcommand{\R}[1]{$\mathbb{R}$}
\newcommand{\C}[1]{$\mathbb{C}$}
\newcommand{\N}[1]{$\mathbb{N}$}
\newcommand{\Q}[1]{$\mathbb{Q}$}
\newcommand{\lp}[1]{$\left({#1}\right)$}
\newcommand{\la}[1]{$\left|{#1}\right|$}
\newcommand{\as}[1]{\color{white}{*}\color{black}{}}
\newcommand{\ind}{\hspace*{30pt}}
\newcommand{\done}{\hfill \mbox{\raggedright \rule{0.1in}{0.1in}}}

\newcommand{\bigdotcup}{\ensuremath{\mathop{\makebox[-0.6pt]{\hspace{16pt}{\(\cdot\)}}\bigcup}}}

\newcommand{\dotcup}{\ensuremath{\mathop{\makebox[-0.6pt]{\hspace{13pt}{\(\cdot\)}}\bigcup}}}

\raggedright

\parindent 30pt


\newcommand{\ftheorem}[1]{\begin{framed}\begin{theorem}#1\end{theorem}\end{framed}}
\newcommand{\fdef}[1]{\begin{framed}\begin{definition}#1\end{definition}\end{framed}}
\newcommand{\fnote}[1]{\begin{framed}\begin{note}#1\end{note}\end{framed}}
\newcommand{\flemma}[1]{\begin{framed}\begin{lemma}#1\end{lemma}\end{framed}}
\newcommand{\fex}[1]{\begin{framed}\begin{example}#1\end{example}\end{framed}}
\newcommand{\fcor}[1]{\begin{framed}\begin{corollary}#1\end{corollary}\end{framed}}




\begin{document}
\linespread{1.5}    % 1.5 space lines


\section{Course Notes}

%January 23, 2012

\subsection{Metric Spaces}

\begin{definition}The metric space $M$ is a \underline{complete metric space} if every Cauchy sequence is convergent in $M$.
\end{definition}

\begin{example}
$\bb{R}$ is a complete metric space\done
\end{example}

\begin{example}
$C[0,1]$ is a complete metric space with $d(f,g) = \sup \mid f(t) - g(t) \mid$, $t \in [0,1]$.\done
\end{example}

\begin{theorem}
Any closed subset $A$ of a complete metric space $M$ is complete.
\end{theorem}

\begin{proof}
Let $A \subset M$ be closed and $<x_n>$ be any Cauchy sequence in $A$. Since $M$ is a complete metric space, $<x_n>$ is convergent in $M$, so $x_n \rightarrow x \in M$. Since $A$ is closed, $x \in A$. Thus, $A$ is complete.
\end{proof}

\end{document}`
share|improve this question
2  
Please consider adding a minimum working example (MWE) of your code, with more information on what you're trying to achieve. The first and second sentences of your current posting, I'm afraid to say, sound a bit contradictory. Plus, are you using a package such as amsthm or ntheorem? –  Mico Feb 27 '12 at 2:01
    
Mico, I have added some sample code showing the packages I am using and rephrased my question. Sorry about the confusion. –  Tyler Clark Feb 28 '12 at 23:29
add comment

1 Answer

up vote 3 down vote accepted

Well, there is still some missing info in your MWE, rendering it a MNWE;). But try this:

\documentclass{amsart}

\usepackage[active,
            generate=short,
            extract-cmd={section},
            extract-env={definition,theorem}]{extract}

\begin{extract*}
  \usepackage{amsthm}

  \newtheorem{theorem}{Theorem}
  \theoremstyle{definition}
  \newtheorem{definition}{Definition}
  \newtheorem{example}{Example}
\end{extract*}

as the preamble, compile your file and look into the file short.tex. See the documentation of the extract package for more info (this is important - this package messes with internals of LaTeX and will not work for any commands, for example!). Short info: the extract* environment puts its contents into the generated file (and processes them as usual as well); generate defines the name of the generated file, and extract-cmd and extract-env specify what to extract.

Also, consider avoiding \underline and using \emph instead.

share|improve this answer
    
This works wonderfully. Thank you! –  Tyler Clark Feb 29 '12 at 1:51
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.