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

This question led to a new package:

I'm trying to work out options for configuring a large memoir to multiple audiences via multiple editions.

Obviously one method of doing this is by building a master set of sections and then combining them into several different master documents which are basically a string of \input{} commands.

Another might be to define a set of section id environments and then include or exclude them with \newcomment{} \commentson{} and commentsoff{}

Yet another way would be an inverse of this: to tag each section with one or more labels. Something like this:

\chapter{A Simple Introduction}
\chapter{A Complex Introduction}
\chapter{How to erase the system}

where I could then do something at the start like:


to build the "System Programmer" edition.

Is there a package that will do something like this?

Accepted @Leo Liu's answer. Bril.

share|improve this question
FWIW, in ConTeXt this feature is called modes. – Aditya May 17 '12 at 3:32
up vote 18 down vote accepted

There is a xcomment package, it isn't tagged, but useful for this kind of question. See also


Here is what you want:




     \ifcsname tagged@##1\endcsname





\begin{tagged}{a, x}
aaaa xxxx

\begin{tagged}{b, c, x}
bbbb cccc xxxx


It's not difficult to implement. Whitespace after commas is ignored.

share|improve this answer
That looks brilliant, and much simpler than I had feared. Going off to have a play with it, back soon... – Brent.Longborough Feb 13 '11 at 19:17
Accepted, +1. Brilliant. Worth an extra upvote just for the line \usepackage{etoolbox}. – Brent.Longborough Feb 13 '11 at 19:39
A previous version does not contain etoolbox. I used \@for and \@namedef, which is not more complex. I use etoolbox to ignore the extra spaces. However, unlike keyval, spaces before commas is not ignored. You can use \ForEach in forarray package or other trick to ignore more spaces. – Leo Liu Feb 13 '11 at 19:55

The `tagging' package is now on CTAN, providing the following commands:

\tagged{list}{yes}            % Conditional inclusion
\untagged{list}{no}           % Conditional exclusion
\iftagged{list}{yes}{no}      % Conditional inclusion/exclusion
\begin{taggedblock}{list}     % Conditionally included environment
    \end{taggedblock}         %
\begin{untaggedblock}{list}   % Conditionally excluded environment
    \end{taggedblock}         %
\usetag{list}                 % Turn tags on
\droptag{list}                % Turn tags off

My thanks to Leo Liu, for his original answer on which the work is based.

share|improve this answer
Good job. I've just seen this package on CTAN-ann mailing list. – Leo Liu Aug 29 '11 at 17:31
Thanks, @LeoLiu, the credit's largely yours... – Brent.Longborough Aug 29 '11 at 23:41
I was very happy when I found tagging. Does this package have the ability to list the tags in use? Somewhat along the lines of tex.stackexchange.com/questions/37928/… – A Feldman Mar 19 at 18:23
@AFeldman I'm sorry, I have good news: I'm in the process of freezing and deprecating tagging, in favour of Boris Veytsman's multiaudience, which I think does a better job. tagging will remain on CTAN, in order not to force current users to migrate, but there will no further development, and no bug or feature requests will be accepted. – Brent.Longborough Mar 19 at 20:25
@Brent.Longborough much obliged for the response. I will take a look at multiaudience. – A Feldman Mar 20 at 15:36

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.