I know that this question is basically identical to that of Hide custom environment content based on boolean
Except I want to avoid using the environ package, which, otherwise, would be the best option in my opinion, and very simple to implement what I want.
I am using the xifthen package, to easily manage my booleans, I know I could use TeX privatives, i.e. \newif\if<name>, but it gets a little complicated when I want to create booleans as arguments without using \csname and expandafter, which I don't fully understand.
I am wanting to hide some content, based on a boolean, and in other environments change it 's formatting.
I tried at first:
\newboolean{full}
% ...
% a little later
% ...
\newenvironment{full}{%
\ifthenelse{\boolean{full}}{%
}{%
}{}
}
Which of course didn't work, so I tried:
\newboolean{full}
% ...
% a little later
% ...
\newenvironment{full}{%
\ifthenelse{\boolean{full}}\begingroup
}{%
\endgroup{}
}
Hoping that did the trick, but coming up with an Incomplete \iffalse error
I then tried a TeX based approach:
\newboolean{full}
% ...
% a little later
% ...
\def\full{\iffull\begingroup}
\def\endfull{\fi\endgroup}
resulting in the same error. Can someone lend me a hand? I've been searching the net for about an hour or so not getting anywhere.
I stress again, I want to avoid using other packages, I would like to using pure TeX/LaTeX commands here.
Thanks.
Edit
I have been using @MarcoDaniel for a while now, but decided to try and make it more my own, using more LaTeX then TeX code.
I have complicated it a bit, to make it more general so that I can have multiple environment working in a similar way, DRY programming, etc..
But It's not working, and I was wondering if people can see my mistake.
The currently used (fully working) code:
\newenvironment{full}{%
\ifthenelse{\boolean{full}}%
{\let\full@i\relax\let\endfull@i\relax}%
{\def\full@i{\setbox\z@\vbox\bgroup}%
\def\endfull@i{\egroup}}%
\full@i%
}{%
\endfull@i%
}
The code I'm trying (but failing) to get to work:
\newcommand{\BooleanHideEnvironment}[1]{%
\newenvironment{#1}{%
\ifthenelse{\boolean{#1}}{%
\newenvironment{#1@body}{}{}
}{%
\newsavebox{#1@bin}
\newenvironment{#1@body}{\savebox{#1@bin}\begingroup}{\endgroup}
}
\begin{#1@body}
}{\end{#1@body}}
}
\BooleanHideEnvironment{full}
\BooleanHideEnvironment{brief}
\BooleanHideEnvironment{refs}
Any further thoughts where I am going wrong?
To note, all the booleans are already defined, and this is located in a *.cls file, and like a *.sty file, does not require the \makeatletter and \makeatother.
You don't want to allocate a new box every time, you will run out of registers. the box is never used anyway so just use box
– parnmatt Oct 02 '12 at 14:24\z@as in the original. Also\savebox{#1@bin}takes the content as a macro argument not an environment that is why you need lrbox environment or the\setboxprimitive. Finally there are several%missing from ends of lines. This doesn't look like an answer, perhaps you should delete the text as an answer and post again as a new question.