2

I have a long set of notes as a book class where each chapter is added to the master document with \input{}. Each chapter file has sections, subsections, itemizes, enumerates, and body text.

I would like to remove all body text so that I can generate class outlines for students to follow along in class and add their own notes. I can do this with a regex like ^[A-Za-z].*$, but is there a way to do this on the fly, all within \LaTeX\?

(I could do this with a batch script to copy the files to a new folder and a good text editor for the regex, but it seems that I should be able to do this within \LaTeX\, I just can't figure it out.)

Edit: It looks like there's an l3regex package (I added the tag), but I can't figure out how to do this from the man file.

Edit 2: I should have included a MWE. Here is what I have.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

\author{Me}
\title{Class Notes}

\begin{document}

\maketitle

\section{One}

Render-farm narrative post-nodality order-flow woman drugs nodal point voodoo god. Smart-A.I. network garage katana lights urban nodality camera systemic j-pop saturation point. Disposable voodoo god DIY girl Shibuya into cardboard papier-mache tube youtube vehicle. 

\begin{itemize}
    \item keep
    \item these
    \item bullet
    \item points
\end{itemize}

\section{Two}

Faded lights jeans convenience store dome savant cartel shrine drugs RAF papier-mache rifle augmented reality youtube. Modem tanto chrome girl sensory corrupted numinous Legba faded katana weathered paranoid narrative sentient. Systemic systema wristwatch towards stimulate post-neural cardboard saturation point franchise corrupted monofilament DIY corporation dolphin assassin. Singularity ablative computer engine knife office bridge shoes tube. Wristwatch euro-pop voodoo god tower chrome vehicle engine kanji systemic tank-traps j-pop into. Otaku motion Legba dead range-rover receding convenience store. Papier-mache systemic uplink beef noodles girl warehouse franchise weathered modem physical youtube lights. 8-bit meta-BASE jump into shrine dissident Kowloon katana receding soul-delay girl. 

\end{document}

I want to turn this on the fly into this.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

\author{Me}
\title{Class Notes}

\begin{document}

\maketitle

\section{One}


\begin{itemize}
    \item keep
    \item these
    \item bullet
    \item points
\end{itemize}

\section{Two}


\end{document}
  • 1
    Something like the comment package seems the obvious solution although it does require suitable markup. – cfr Aug 16 '15 at 22:10
  • 2
    Can't help wondering from your notes what you might be using them to teach ;). – cfr Aug 16 '15 at 22:15
  • 1
    In one sense, yes, you 'should' be able to script it: after all, TeX is Turing complete. And you probably can. That doesn't mean it is a good idea. If it were me, I'd use a shell script (or some Windows equivalent - I don't know if Windows runs to shells). I think that will be more robust, more efficient, more flexible and easier to use and maintain. Personally, I think you are trying to bang in nails with a screwdriver - sure you can probably do it, if you really want to, but, me, I'd use this thing called a 'hammer' instead ;). – cfr Aug 16 '15 at 22:47
  • 1
    That is, this is easy if you use tools designed for the job. Why do you want to make it difficult?! Note that l3regex.sty is experimental. That means that the syntax and functionality is likely to change. It isn't stable. Expect bugs, breakage etc. But, more than that, you have to come up with a way of running your entire document contents through a command. I'm not saying you can't do this. Many things can be done. The question is whether a reasonably sane person would want to do them rather than using this nice hammer they've been given. – cfr Aug 16 '15 at 22:52
  • 1
    @cfr -- OK, thanks! I will post my batch script solution for posterity. – Richard Herron Aug 16 '15 at 22:58
1

One way is to use e.g. use the package iften with \newboolean{short}, and doing \ifthenelse{\boolean{short}}{short version}{longwinded text pertaining to the non-short alternative} to include/exclude/taylor parts of the text, depending on the value of short.

Another option could be to use beamer, and generate an article/book and slides from the same source.

I've been known to massage LaTeX source with Perl scripts, but gave up that perversion. For now...

|improve this answer|||||
0

As much as it pains me, I will have to run a batch script for every change to the underlying files, then run a find and replace. But I think @cfr is right that this is easier than mucking with l3regex.

Here is a simple Windows batch script that mirrors the files.

mkdir "..\Mirrored"
ROBOCOPY "." "..\Mirrored" /mir

With a modern text editor you can do the find and replace to find ^[A-Za-z].*$ and replace it with . I use Sublime Text 3 on this machine, which isn't batch script-able. But I'll update this with a Vim script when I get to my other Windows machine with Vim.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.