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.
Circumstances:
- we are creating a file containing multiple subfiles
- we'd like to be able to set the flag when building a subfile separately
Research:
- Hide custom environment content based on boolean
ifthen(doesn't exclude the code properly but would allow for local settings of the flag)\usepackage{ifthen} \newboolean{shownotes} % %\setboolean{shownotes}{true} \setboolean{shownotes}{false} % \newcommand{\notes}[1]{ \ifthenelse{\boolean{shownotes}}{#1}{} }comment(but\excludecomment{notesenv}doesn't do the job) andenviron(but\NewEnviron{notesenv}{\ifthenelse{\boolean{shownotes}}{\BODY}{}}also doesn't do the job)
- https://www.reddit.com/r/LaTeX/comments/1d4p2a/how_to_hide_an_environment_ie_proof/
- http://www.ryanmartinphd.com/custom-environment-in-latex-that-can-be-hidden/
- Suppressing remarks when not needed
Current solution: So far, I've come up with this bit which works well – except that I cannot overwrite the flag locally.
\ifthenelse{\boolean{shownotes}}{%
\newcommand{\notes}[1]{Notes: #1}%
\newenvironment{notesenv}{Notes:}{}
}{%
\newcommand{\notes}[1]{}
\usepackage{environ}
\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?
\newif? – luki Mar 19 '20 at 10:25