Task: I want to create a 'notes' command and an environment which can be hidden by a boolean flag.

Problem: These 'notes' can contain minted code blocks which mess up previous solutions found on the internet. Furthermore, we'd like to be able to enable / disable the flag locally.


  • we are creating a file containing multiple subfiles
  • we'd like to be able to set the flag when building a subfile separately


Current solution: So far, I've come up with this bit which works well – except that I cannot overwrite the flag locally.

    \newcommand{\notes}[1]{Notes: #1}%
    \NewEnviron{notesenv}{} % omitting the \BODY command creates a hidden environment

The flag cannot be overwritten locally as it needs to be set accordingly when making the definition. I guess I could copy the definition to every file, but is that really the only solution?

  • Welcome to TeX.SE! Did you try \newif? – luki Mar 19 '20 at 10:25
  • I did not before, but now that I do I get the same behaviour as previously. It properly hides normal text (like the ifthen package), but as soon as you plug in some code environment it all breaks. – Pr0gm4n Mar 19 '20 at 11:23

This solution does not work for your environment notesenv. But for the \notes macro, you could create a new conditional \ifincludenotes with \newif. Locally you can set it true or false.








  • Thanks for your reply, but as stated above this does not resolve the standing problem that I want to hide code, i.e. verbatim environments generated with minted. – Pr0gm4n Mar 19 '20 at 13:33

As a workaround, you can use \inputminted with NewEnviron.

For example:



  • I'm not sure this would actually work. Could you provide a full minimal document and a screenshot of the result to show that this solves the problem? – Marijn Feb 10 at 12:40

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.