TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I saw in another question about how to create a condition, of which the best practice recommended was \iftoggle. I want to create a macro that will allow the creation of a teacher's note, a section with a definable look and feel which will conditionally compile away if I define that this is not the teacher's edition.

The error, it turns out, was that I didn't realize I had to usepackage in order to use the etoolbox. Here is the (now working) code. How can I define a border and a shading to embed in the teacher macro, and is there a better way of doing this?

\documentclass[11pt]{book}              % Book class in 11 points
\parindent0pt  \parskip10pt             % make block paragraphs
\raggedright                            % do not right justify

\title{\bf Document Title}    % Supply information
\author{Author}              %   for the title page.
\date{\today}                           %   Use current date. 


\newcommand{\teacher}[1] {


% Note that book class by default is formatted to be printed back-to-back.
\begin{document}                        % End of preamble, start of text.
\frontmatter                            % only in book class (roman page #s)
\maketitle                              % Print title page.
\tableofcontents                        % Print table of contents
\mainmatter                             % only in book class (arabic page #s)
\part{A Part Heading}                   % Print a "part" heading
\chapter{A Main Heading}                % Print a "chapter" heading
Most of this example applies to \texttt{article} and \texttt{book} classes
as well as to \texttt{report} class. In \texttt{article} class, however,
the default position for the title information is at the top of
the first text page rather than on a separate page. Also, it is
not usual to request a table of contents with \texttt{article} class.

\section{A Subheading}                  % Print a "section" heading
The following sectioning commands are available:
\begin{quote}                           % The following text will be
 part \\                                %    set off and indented.
 chapter \\                             % \\ forces a new line
 section \\ 
 subsection \\ 
 subsubsection \\ 
 paragraph \\ 
\end{quote}                             % End of indented text
But note that---unlike the \texttt{book} and \texttt{report} classes---the
\texttt{article} class does not have a ``chapter" command.

share|improve this question
When you ask a question and answers are provided, don't change the question completely to ask something different. I can't tell you what to do, I'm just giving my opinion. – Werner Sep 11 '13 at 19:22
Sorry, I was editing the question while you were answering it – Dov Sep 11 '13 at 19:23
up vote 7 down vote accepted

I propose you another approach using the comment package:





\section{Test section}


\section{Another test section}



This produces the complete version:

enter image description here

Simply un-commenting out the line \excludecomment{teacher}, gives you the student version:

enter image description here

I used tcolorbox to produce a nice frame with a shaded background around the teacher section.

share|improve this answer
Thanks, this is a great solution, but see my followup next question (which references this one). Is there any way to override this state when running LaTeX? I would like to have a makefile that generates all versions of the document. – Dov Sep 11 '13 at 19:21

Please always post a complete small document and/or show the full error message, however you don't really need a boolean toggle for this. You simply want a command that eats its argument or uses it so just have


then \teacher{stuff} is the same as stuff and when you want the other version just move the % up to comment out the first version, so then \teacher{stuff} will do nothing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.