In the commenting of your question/in other answers usage of the comment package is already suggested.
Using the docstrip package might be a different, non-environment-based approach to the matter.
The docstrip package is a means for deriving different .tex-input-files from one (set of) master file(s). Within the master file(s) you can place so-called tags. These tags are used for determining those derived files where the tagged portions of text from the master file(s) will be copied to.
Both within the head of the master file and in another file you can have so-called \generate-directives for creating those files that are to be derived from the master file(s).
More info about the docstrip package can be found at CTAN.
If you save the following example as a file with a name both other than teacher.tex and other than students.tex and compile it with tex or pdftex or latex or pdflatex, two new files will be created, one of them is called teacher.tex, the other one is called students.tex.
%<*ignore>
% Section with docstrip directives for generating different
% .tex-input-files:
\input docstrip
\declarepreamble\teachers
____________________________
Course Guide, release only for teachers, with teaching notes embedded.
Use pdflatex/pdftexify for compiling this file.
\endpreamble
\declarepreamble\students
____________________________
Course Guide, release for students, no teaching notes embedded.
Use pdflatex/pdftexify for compiling this file.
\endpreamble
\generate{%
\nopostamble
%
\usepreamble\teachers
\file{teacher.tex}{\from{\jobname.tex}{teacher}}%
%
\usepreamble\students
\file{students.tex}{\from{\jobname.tex}{students}}%
}%
% Here you can probably insert \write18-calls suitable for your platform
% for calling pdflatex from console for compiling the files
% just generated -- something like:
% \immediate\write18{pdflatex teacher.tex}
% \immediate\write18{pdflatex students.tex}
% \immediate\write18{pdftexify teacher.tex}
% \immediate\write18{pdftexify students.tex}
%
\csname stop\endcsname % <- end this TeX-run in case you used (pdf)LaTeX
% for generating the files.
%
\bye % <- end this TeX-run in case you used (pdf)TeX for generating the
% % files.
%
%</ignore>
% Section containing the actual LaTeX document, with tags for
% generating different variants with different target groups
%<*teacher,students>
\documentclass{article}
\begin{document}
This is both for students and for teachers.
%<*teacher>
This is for teachers only.
%</teacher>
%<*students>
This is for students only.
%</students>
This is both for students and for teachers also.
\end{document}
%</teacher,students>
The content of teacher.tex will be:
%%
%% This is file `teacher.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% test.tex (with options: `teacher')
%% ____________________________
%%
%% Course Guide, release only for teachers, with teaching notes embedded.
%%
%% Use pdflatex/pdftexify for compiling this file.
%%
\documentclass{article}
\begin{document}
This is both for students and for teachers.
This is for teachers only.
This is both for students and for teachers also.
\end{document}
The content of students.tex will be:
%%
%% This is file `students.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% test.tex (with options: `students')
%% ____________________________
%%
%% Course Guide, release for students, no teaching notes embedded.
%%
%% Use pdflatex/pdftexify for compiling this file.
%%
\documentclass{article}
\begin{document}
This is both for students and for teachers.
This is for students only.
This is both for students and for teachers also.
\end{document}
commentpackage do what you need? (I think so.) – Harald Hanche-Olsen Jul 04 '18 at 14:19commentprovides you could have a look atmultiaudience. – TeXnician Jul 04 '18 at 14:21amscls-docis an example of a multi-version document. might be more complicated than you are looking for, but it definitely works, giving quite different outputs for four major user guides from a "single" base. (some "helper" files are needed where the requirements are significantly different.) – barbara beeton Jul 05 '18 at 19:56