I'm looking for a way to compile only what's inside a given command (or an environment). I'm doing a PhD and this way, I'll be able to have a full document with some poorly written sections, for myself, and a version with only the proper sections, for my advisor.

In the beginning, I started with


but it would be far more practical to specify what's fine rather than the opposite.

I had two ideas.

The first one was:






But it seems that LaTex don't expand \keep when it looks for \endblank and eventually everything is avoided and there is nothing to print.

The second idea I had was:







This one seems to work, but because \keep is supposed to work with pretty big chunks of text, I'm afraid I have done something really wrong.

So my questions are:

  • Is there a way to make the first idea work and ask LaTeX to expand some commands to look for the delimiters?

  • Is the second solution "stable" and proper to use in large files?

  • Is there a better/proper way to do that or is it something I'll have to do with some external preprocessing?

  • A bonus question: Is there a simple way I can make the second idea work with an environment \begin{keep}?

After writing this, I notice I should maybe have divided this question in two parts, sorry for that... Please, tell me if I should do it!

  • 3
    Do you know packages like comment or multiaudience, which allow you to basically produce two versions of your document? – TeXnician Aug 23 '18 at 17:25
  • You could use the environments defined in tex.stackexchange.com/questions/250024/… – Andrew Aug 23 '18 at 20:54
  • I saw them, but if I haven't miss anything and understood them correctly, all these packages and environments are made to make some texts appears or disappear. But in my case, I want to keep only the content inside the command/environment and make the rest appear or disappear. – Vinzza Aug 24 '18 at 8:58
  • The usual way to achieve this is to use \input and to comment out for your advisor all the drafts. – Keks Dose Aug 26 '18 at 16:38

Your Answer

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

Browse other questions tagged or ask your own question.