# Set up a system to alternate between genders per paragraph

In RPG writing it has become traditional to swap he and she on a per paragraph basis. Something like "He can use the smite evil ability one a day at first level. (Blah blah blah, paragraph break) when the paladin gets to 4th level she can use the ability three times a day."

Now, this isn't that hard to write, but often paragraphs get moved around and such. Is there a way I could type \hir and \sie into my text, then have LaTeX figure out what order the paragraphs are in, and swap them into he, she, him, her, alternating male and female each paragraph?

• Is this what you are looking for he-she package by Alan Munn – texenthusiast Feb 27 '13 at 5:10
• @texenthusiast Damn, and today I learn there is no problem so obscure that I don't have to check for an existing question. That is quite close, but it alternates per use, when I want per-paragraph. – Canageek Feb 27 '13 at 5:15
• Isn't it extraordinary? The amount of time spent on finding a he/she (which IMNSHO doesn't matter an iota) could have been spent on finding a cure for cancer, hunger, the list is endless... – Brent.Longborough Feb 27 '13 at 10:05
• @Brent.Longborough There has been a fair bit of research on bias in textbooks and such influencing students behaviour. – Canageek Feb 28 '13 at 15:39
• @Brent.Longborough If it's unimportant to you, consider to write "she" and "her" all the time. – lockstep Mar 1 '13 at 19:43

The he-she package now does everything you need. (I have added a package option as the result of this question.) Let's first see how you would do this without automating (and why this is probably preferable.)

## Partial automation

The he-she package implements two different sets of macros for pronouns: one set (\heshe, \himher, and \hisher) outputs a pronoun and switches the gender for the next use of any one of the same set. So, for example:

\Heshe put  \hisher coat beside a statue of \himher.


will output

He put her coat beside a statue of him.

or:

She put his coat beside a statue of her.

depending on the current state.

However, the second set of pronouns (\he, \him, \his) allows you to continue with the current gender state as long as you like, in your case, for a whole paragraph if you wish. So in this case:

\Heshe put  \his coat beside a statue of \him.


will output

He put his coat beside a statue of him.

or:

She put her coat beside a statue of her.

depending on the current state.

So if you want to change pronouns every paragraph, you can do so by making the first instance of a pronoun in a paragraph be the switching version, and every subsequent pronoun a non-switching (anaphoric) version.

Now this obviously doesn't automatically switch every paragraph, but I'm not sure that's desirable anyway. Just as a the sentence is not the right level at which to change genders, it's not clear to me that the paragraph is the right level either, since you probably really want to change at some sort of higher level of structure (something like "topic change"). So it might not be the best idea to reset the gender every paragraph, but every set of one or more paragraphs that form a coherent topic.

However, if you're wedded to automation (and after all that's one of the things we all love about LaTeX anyway) it can be done:

## Total automation

Adapting the everypar solution to the he-she package, we can do the following. I've used the everyhook package to interface with \everypar. This has now been added as an option to the package itself.

\documentclass{article}
\usepackage{everyhook}
\usepackage{he-she}
\PushPreHook{par}{\makebox[0pt][0pt]{\heshe}}
\begin{document}
When a player rolls the dice \he will have to do something. \He will do that thing
with all of \his powers and \he will make sure that nobody sees \him.

When a player rolls the dice \he will have to do something. \He will do that thing
with all of \his powers and \he will make sure that nobody sees \him.

\end{document}


The idea here is that we hook into \par and issue the switching version of the pronoun command in a zero width box. Then we use the anaphoric version of the pronoun in the running text.

## As a package option

This has been implemented into the package as an option [para]. So with the current version of the package (v1.1) you can just do:

\documentclass{article}
\usepackage[para]{he-she}

\begin{document}
When a player rolls the dice \he will have to do something. \He will do that thing
with all of \his powers and \he will make sure that nobody sees \him.

When a player rolls the dice \he will have to do something. \He will do that thing
with all of \his powers and \he will make sure that nobody sees \him.

\end{document}


• +1 for everyhook. My CTAN bookmarks are starting to get a little out-of-control. This is a much nicer solution. – Sean Allred Mar 1 '13 at 21:23
• That's beautiful, @AlanMunn. – Mars Mar 2 '13 at 6:46
• Cool, those both work well. I realized that typically it swaps each ability, and since most abilities are only one paragraph long then it works as if it was every paragraph. I like the automated solution, though. Between these two I should have everything needed to write an RPG without the community rending me a new one. – Canageek Mar 8 '13 at 1:44

EDIT
If the functionality you need is exactly as above, then Alan Munn's answer is most certainly the better solution and not nearly as ... interesting as my own. However, the answer that follows demonstrates a basic approach that may be useful in multiple other circumstances.

Creating a new if and hooking a switcher onto \everypar, you can do this. (the hook must be inside document because document apparently redefines it.)

Note, however, that lipsum doesn't seem to follow the normal rules (it may in fact redefine \everypar yet again).

\documentclass{article}

\newif\ifgendermale
\newcommand{\switchHeShe}{%
\ifgendermale%
\gendermalefalse%
\else%
\gendermaletrue%
\fi}

\newcommand{\hir}{\ifgendermale his\else her\fi}
\newcommand{\sie}{\ifgendermale he\else she\fi}

\usepackage{lipsum}

\gendermaletrue
\begin{document}
\everypar=\expandafter{\the\everypar\switchHeShe}

Nobody knows \hir{} name.  Nobody knows the size of \hir{} naval.

In this game, the player will try to determine the naval size and name
of the antagonist.  In doing so, \sie{} will probably have fun.

If \sie{} doesn't though, just hit \hir{} over the head with a naval.

As you can see, this works for the main body of text.  The minute you
introduce environments, notice,
\begin{itemize}
\item \sie{} doesn't do capitalization.
\item \hir{} nose may be offended.
\item \verb+\everypar+ gets reset all the time.
\item By valiant diligence\dots and stuff\dots \sie{} can
\begin{itemize}
\everypar=\expandafter{\the\everypar\switchHeShe}
\item see \hir{} own nose
\item know \hir{} own destiny
\item complain about built-in environments \textit{completely}
resetting the hook.
\end{itemize}
\end{itemize}
\end{document}

• (1) you dont need all the empty {} in the definition (they can actually corrupt thigns in some cases). (2) It would be nice to show how it does work mid-sentence, not just before a comma ;) – yo' Mar 1 '13 at 19:13
• @tohecz edited -- the unpredictable functionality of this while in environments is kind of off-setting. Downright annoying, actually. Fancy another approach? – Sean Allred Mar 1 '13 at 19:35
• A linguistic comment: English has 3 cases (Nominative (he/she), Accusative (him/her) and Genitive (his/her), so you need to add one more set of macros for the Accusative case. Or you could use the he-she package. :) – Alan Munn Mar 1 '13 at 21:16
• Trusted OP that the package didn't support it, but I suppose you would know better now, wouldn't you @AlanMunn? ;) I had fun doing it anyway. Learned a lot. (Mostly getting \expandafter straight in my head -- it's like C pointers: it's confusing until it makes sense.) – Sean Allred Mar 1 '13 at 21:20