% This package implements a version of semi-automatic pronoun switching for writing
% gender-neutral (and possibly annoying) prose.
% The basic code is due to Josef (no last name) and Martin Scharrer on
% http://tex.stackexchange.com/questions/10787/
%
% Modified to handle anaphoric reference to the current gender plus
% all three case forms in both uppercase and lowercase.
% Includes an option to flag to turn off xspace, and a silly option for replacing
% all pronouns with 'they/them/their'.
%
% Copyright 2011 by Alan Munn
%
% This package may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This package has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this package is Alan Munn.
%
% This package consists of the file he-she.sty and documentation files
% he-she.tex and he-she.pdf
%
% Version 1.0 2011/02/13
%
% Option noxspace
%
% xspace can cause problems if the macro is e.g. enclosed in other markup such
% as \emph{}.  The noxspace option turns off the xspace and forces users to 
% insert a following space using "\ " explicitly.  Default is to enable xspace.
%
% With the default option, the \xspace can be suppressed with the \xspacefalse
% command as needed.
%
% Option they
%
% When you get tired of the silliness of alternating genders, you can switch to
% this option, which will replace all of the relevant pronouns with the third
% person plural pronoun form ('they/them/their').  Note that for the nominative
% this will cause your document to produce ungrammatical text, since there is 
% no way to fix the subject/verb agreement.
%
% As a result, this is probably not intended to be a robust alternative!
% You have been warned! (And you will be if you use it too.)
%
\ProvidesPackage{he-she}[2011/02/12 Semi-automatic pronoun switching with anaphora v1.0]
\RequirePackage{xspace}
\newif\ifxspace\xspacetrue
\newif\ifthey\theyfalse
\DeclareOption{noxspace}{\xspacefalse}
\DeclareOption{they}{%
\theytrue
\PackageWarning{he-she}{*** WARNING: Use of option `\CurrentOption` will screw up subject/verb agreement for most nominative pronouns. It is only present for for its comic value! USE AT YOUR OWN RISK! ***}
}
\DeclareOption*{%
 \PackageWarning{he-she}{Unknown option `\CurrentOption`}%
}
\ProcessOptions
% toggle for changing the gender
\newif\ifhe\hetrue
%
%
\ifthey
% Implement the (somewhat useless) 'they' option
%
\newcommand*{\heshe}{they\ifxspace\xspace\fi}
\newcommand*{\Heshe}{They\ifxspace\xspace\fi}
\newcommand*{\himher}{them\ifxspace\xspace\fi}
\newcommand*{\Himher}{Them\ifxspace\xspace\fi}
\newcommand*{\hisher}{their\ifxspace\xspace\fi}
\newcommand*{\Hisher}{Their\ifxspace\xspace\fi}
\newcommand*{\he}{they\ifxspace\xspace\fi}
\newcommand*{\He}{They\ifxspace\xspace\fi}
\newcommand*{\him}{them\ifxspace\xspace\fi}
\newcommand*{\Him}{Them\ifxspace\xspace\fi}
\newcommand*{\his}{their\ifxspace\xspace\fi}
\newcommand*{\His}{Their\ifxspace\xspace\fi}
%
\else
%
% Lowercase versions:
%
% Nominative lowercase switching form \heshe
\newcommand*{\heshe}{%
  \ifhe%
    he%
    \global\hefalse%
  \else%
    she%
    \global\hetrue%
  \fi%
  \ifxspace\xspace\fi
}
%
% Nominative lowercase anaphoric form \he
\newcommand*\he{%
\ifhe%
	she%
  \else%
  	he%
  \fi
  \ifxspace\xspace\fi
}
%
% Accusative lowercase switching form \himher
\newcommand*\himher{%
  \ifhe%
  	him%
    \global\hefalse%
  \else%
  	her%
    \global\hetrue%
  \fi%
  \ifxspace\xspace\fi
}%
%
% Accusative lowercase anaphoric form \him
\newcommand*\him{%
\ifhe%
	her%
  \else%
  	him%
  \fi
  \ifxspace\xspace\fi
}
%
% Genitive lowercase switching form \hisher
\newcommand*\hisher{%
  \ifhe%
  	his%
    \global\hefalse%
  \else%
  	her%
    \global\hetrue%
  \fi%
  \ifxspace\xspace\fi
}
%
% Genitive lowercase anaphoric form \his
\newcommand*\his{%
\ifhe%
	her%
  \else%
  	his%
  \fi
  \ifxspace\xspace\fi
}
%
% Uppercase versions:
%
% Nominative uppercase switching form \Heshe
\newcommand*{\Heshe}{%
  \ifhe%
    He%
    \global\hefalse%
  \else%
    She%
    \global\hetrue%
  \fi%
  \ifxspace\xspace\fi
}
%
% Nominative uppercase anaphoric form \He
\newcommand*\He{%
\ifhe%
	She%
  \else%
  	He%
  \fi
  \ifxspace\xspace\fi
}
%
% Accusative uppercase switching form \Himher
\newcommand*\Himher{%
  \ifhe%
  	Him%
    \global\hefalse%
  \else%
  	Her%
    \global\hetrue%
  \fi%
  \ifxspace\xspace\fi
}%
%
% Accusative uppercase anaphoric form \Him
\newcommand*\Him{%
\ifhe%
	Her%
  \else%
  	Him%
  \fi
  \ifxspace\xspace\fi
}
%
% Genitive uppercase switching form \Hisher
\newcommand*\Hisher{%
  \ifhe%
  	His%
    \global\hefalse%
  \else%
  	Her%
    \global\hetrue%
  \fi%
  \ifxspace\xspace\fi
}
%
% Genitive uppercase anaphoric form \His
\newcommand*\His{%
\ifhe%
	Her%
  \else%
  	His%
  \fi
  \ifxspace\xspace\fi
}
\fi
\let\she\he
\let\She\He
\let\her\him
\let\Her\Him
\let\hir\his
\let\Hir\His
\endinput