# Alternate he / she in text

This question led to a new package:
he-she

I have seen a book that instead of using the masculine pronoun (he, his, etc.) alternates the gender ('he' then 'she' then next time 'he' again).

Is there a way to do this with LaTeX - to use a placeholder that alternates between two predefined words?

(I'm looking for a pointer as to where to start.)

EDIT: There is a useful discussion in the comments to Martin's answer for how to relax the strict he/she alternate (which can be confusing if applied too strictly).

-
I fully support the use of singular they instead. It avoids the problems with the gendered words; it's used in actual speech; it's the clearest option; and it's attested as far back as 1300, having been used by such notable authors as Chaucer and Shakespeare. Prescriptivism can go hang :-) –  Antal S-Z Feb 12 '11 at 4:59
If you (unlike me) don't like Antal's suggestion, here's another one: Just use "she". This is also a lot clearer than switching. –  Hendrik Vogt Feb 12 '11 at 7:50
Just use he for every odd and she for every even chapter (or vice versa). It's the most simplest, least intrusive method which still is 100% "political correct". –  Martin Scharrer Feb 12 '11 at 22:33
Based on the discussion below, I've now implemented my solution as a package: he-she. –  Alan Munn Feb 15 '11 at 13:19
@Alan thanks for this - Also I have never put latex code into a package, your package provides a great example for me as to how to go about it. –  Tom Feb 16 '11 at 9:57

Following up on the discussion about how to get this to work in practice, here's a modification to Josef's solution which allows one to use anaphoric pronouns linked to the current state. Pronominal anaphora is quite complicated, so even this solution would only work for a limited set of cases, but it would still be a bit of an improvement.

Update: I've implemented this solution as the he-she package.

The problem arises in sentences like the following:

1. If someone thinks \heshe is sick, he should go to the doctor.

(As Norman notes, it's perfectly colloquiual English to use 'they' for these sorts of pronouns, but since that's not up for debate here, we'll soldier on :-) )

In sentence (1) we need the pronoun in the main clause to match in gender with the pronoun in the 'if'-clause. If we use the \heshe macro we won't know what the gender is, however, since it will change depending on how many times it has previously been used.

So we really need two macros: one for the switch, and one for anaphoric reference to the current gender state. I've implemented this simply by creating one extra macro within Josef's solution (of course the same idea works for Martin's as well.)

    \documentclass{article}
\usepackage{xspace}
\newif\ifhe\hetrue
\newcommand*\heshe%
{%
\ifhe%
he%
\global\hefalse%
\else%
she%
\global\hetrue%
\fi%
\xspace
}%
\newcommand*\he%
{\ifhe%
she
\else%
he%
\fi
\xspace
}
\begin{document}

If someone thinks \heshe is sick \he should go to a doctor immediately.
When \he goes to the the doctor, \heshe can figure out the problem.
\end{document}


This is a more linguistically useful version than restricting the scope of the change to a single sentence, since in the second sentence of the source example, there are two instances of a pronoun: the first is anaphoric to the previous sentence (and so should match in gender, but the second can be assigned a new gender.)

-
The \xspace must be the last command in the macros. It looks ahead (using \@ifnextchar, i.e. \futurelet) to see if it has to produce a space or not. Here it only sees \global, \else or \fi. –  Martin Scharrer Feb 12 '11 at 22:30
@Martin Thanks. I had just copied Josef's code. (Ironically, there are no places in which the nominative pronoun woul be followed by punctuation anyway except in the very prescriptive (and linguistically crazy) "John is taller than he."). –  Alan Munn Feb 12 '11 at 22:53
Ironic indeed. In that case it a normal \space should do it. –  Martin Scharrer Feb 12 '11 at 22:56
Hmm..what about "He, being taller than her, was able to reach the cookie jar." –  BeSlayed Feb 13 '11 at 14:21
@BeSlayed I knew claiming 'no places' would come back to bite me. :-) Since the \xspace does no real harm, it's fine to leave it in. (It does, however, pose other problems: for example \emph{\heshe}, will yield ' he , ' which is undesirable.) –  Alan Munn Feb 13 '11 at 14:45

You can do this by defining an if-switch which toggles every time it is used:

\newif\iffemale
\usepackage{xspace}

\newcommand*\heorshe{%
\iffemale
she
\global\femalefalse% next one is male
\else
he
\global\femaletrue% next one is female
\fi
\xspace
}

% Capitalized version:
\newcommand*\Heorshe{%
\iffemale
She
\global\femalefalse
\else
He
\global\femaletrue
\fi
\xspace
}


edits: Added missing \global and \xspace.

-
Haha latex is cool! Thank you Martin, just testing it now, I thought it would be a lot more complicated - I need to look up that \newif command. I have never seen that before. Thanks! –  Tom Feb 10 '11 at 20:19
I was going to add a similar answer but using counters instead of booleans. Yours is much clear. –  fabikw Feb 10 '11 at 20:21
That is not enough because you will need pronouns, posessive pronouns and all kind of other elements that depend on a gender. And they have to be aligned within once sentence. Therefore you have to switch at the end of a sentence and not at every use. I think it would be cool to have an \either{this/that} macro that picks either the first or the second choice and reverses that choice at the end of a sentence. This way you need just one macro (or maybe a second for the switching) and don't specialized macros for every case. –  Christian Lindig Feb 10 '11 at 20:23
@Leo My idea is that you write a sentence like this: \either{He/She} left the house and went to \either{his/her} car. To make any sense, I believe you have to consistently pick the first or the second choice within the sentence. However, in the next sentence you might pick the other choice (again, consistently). But might have misunderstood the intention of the question and @Tom wants to switch choices really at every possible occasion. That would lead to very difficult to read text. I'd design \either in a way that the switch is toggled at every \par. –  Christian Lindig Feb 10 '11 at 20:46
Thinking about it, I realize that it is probably better to use a star to mean "change the gender". I.e. \He did \his job so well that \he* got what \he* expected would give "She did her job so well that he got what she expected"... ok, that sounds odd, but it is because I needed to pu enough * in a short space. –  Bruno Le Floch Feb 11 '11 at 0:42

I tried hard but Martin was faster ;-)

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xspace}
\newif\ifhe\hetrue
\newcommand*\heshe%
{%
\ifhe%
he%
\global\hefalse%
\else%
she%
\global\hetrue%
\fi%
\xspace
}%
\begin{document}
First \heshe is a man, but then \heshe turns into a woman. And back again: \heshe
\end{document}

-
+1 I didn't know about xspace either –  Tom Feb 10 '11 at 20:37
Ok, but you remembered to add \xspace. :-) –  Martin Scharrer Feb 10 '11 at 20:39
You need to add \global like in my code. Otherwise the gender will be local inside environments. –  Martin Scharrer Feb 10 '11 at 21:11
Yep, you are right. I will edit my answer. –  Josef Feb 10 '11 at 22:53
Wouldn't it be more sensible to put the \xspace at the end of the macro (before }) instead of inside each branch of the if? –  Paŭlo Ebermann Feb 11 '11 at 19:21

It's not an answer to your question, really, as much as a clever evasion, but The Joy of TeX deals with it by inventing new epicene pronouns, which I at least think counts as stylish (if perhaps not to be too eagerly imitated).

Thus E, Em, and Eir instead of he/she, him/her, and other abominations.

Just so I'm not being completely irrelevant, an alternative technique to the fine existing answers:

\documentclass{article}
\usepackage{xspace}
\def\heshei{he\xspace
\global\let\heshe\hesheii
}
\def\hesheii{she\xspace
\global\let\heshe\heshei
}