I know we can comment out a block of text in Latex using \begin{comment} and \end{comment} commands. However, when I call this recursively (or in a nested fashion) as shown below, it fails:
\begin{comment} % block 1
some text
\begin{comment} % block 2
some text
\end{comment} % block 2
some text
\end{comment} % block 1
The above code should comment entire text but gives error. I need the above code for example, when I decide later to remove block 1 comment, but still want to keep block 2 commented.
This is just a simple example. We can as well have another block 3 within block 1 and then decide to keep block 3 commented but remove blocks 1 and 2.

commentnot see the\end{comment}of block 2 by changing it to something different of\end{comment}(\ end{comment}, for example). In fact, adding a comment at the end of the line, like in your example, is enough to make the\end{comment}unseen. I think this is much easier than trying to balance the\begins and\ends. In fact, balancing verbatim environments (such ascomment) is usually a problem... – Phelype Oleinik Aug 27 '19 at 23:27\end{comment}does not seem to work. Also, changing to\ end{comment}gives error as there is no corresponding\end{comment}for\begin{comment}– omsrisagar Aug 28 '19 at 17:46commentpackage (for any other package this may not apply) checks for a line containing exactly\end{comment}. Anything else will not be "seen" and will be considered part of the comment. Taking the example from your question: if you compile it, it will throw an error, will it not? Because neither\end{comment}is seen because of the comments at the end of the lines. If you remove the% block 1comment from the\end, everything will be considered as a comment. Also, changing the block 2\endto\ endwill hide it and only the second\endwill be seen. It should work... – Phelype Oleinik Aug 28 '19 at 23:03