"The Shakespeare Code" is the second episode of the third series of the revived British science fiction television series Doctor Who. It was broadcast on BBC One on 7 April 2007. According to the BARB figures this episode was seen by 7.23 million viewers and was the fifth most popular broadcast on British television in that week. Originally titled "Love's Labour's Won", was also titled by David Tennant as "Theatre of Doom" during the "David's Video Diaries 2", part of the Series 3 DVD, the episode was re-titled as a reference to The Da Vinci Code.

In the episode, the alien time traveller the Doctor (David Tennant) takes his new travelling companion Martha Jones (Freema Agyeman) in her first trip in time and space. They arrive in 1599 near the Globe Theatre in Southwark, where they meet the playwright William Shakespeare. Shakespeare is being bewitched by three witch-like Carrionites to rewrite the ending to his play Love's Labour's Won so that the performance will create the right words to free the rest of the Carrionite race from imprisonment.

Plot The Tenth Doctor, who promised to take Martha on one trip, takes her to a performance of Love's Labour's Lost at the Globe Theatre in Southwark in 1599. At the end of the play, William Shakespeare announces a forthcoming sequel entitled Love's Labour's Won. A witch called Lilith uses a voodoo doll to influence Shakespeare to declare that the new play will premiere the following evening. When Lynley, the Master of the Revels, demands to see the script before allowing the play to proceed, Lilith plunges a voodoo doll made of his hair into a bucket of water and stabs it in the chest. Lynley collapses on the ground dead. Lilith compels Shakespeare to write a strange concluding paragraph to Love's Labour's Won before flying away on a broom.

In the morning, the Doctor, Martha and Shakespeare proceed to the Globe Theatre, and the Doctor asks why the theatre has 14 sides. They decide to visit the architect of the theatre in Bethlem Hospital. They find the architect, Peter Streete, in a catatonic state. The Doctor helps him emerge from his catatonia long enough to reveal that the witches dictated the Globe's tetradecagonal design to him. The witches Lilith, Doomfinger, and Bloodtide observe this through their cauldron, and Doomfinger teleports to the cell and kills Peter with a touch. The Doctor identifies the witches as Carrionites, a species whose magic is based on the power of words which allows them to manipulate psychic energy. By uttering the name Carrionite the Doctor is able to repel her.

The Doctor deduces that the Carrionites intend to use the powerful words of Love's Labour's Won to break their species out of imprisonment. The Doctor confronts Lilith, who explains that the three witches were released from their banishment by Shakespeare's genius words after he lost his son Hamnet. Lilith temporarily stops one of the Doctor's two hearts and flies to the Globe Theatre. Shakespeare fails to stop the play from being performed. The actors speak the last lines of the play. A portal opens up, allowing the Carrionites back into the universe. The Doctor tells Shakespeare that only he can find the words to close the portal. Shakespeare improvises a short rhyming stanza but is stuck for a final word until Martha blurts out Expelliarmus. The Carrionites and all the copies of Love's Labour's Won are sucked back through the closing portal.

Continuity

Shakespeare in Doctor Who Shakespeare has appeared in one earlier Doctor Who episode, and the Doctor has also mentioned prior meetings. The Bard is seen by the Doctor and his companions on the screen of their Time-Space Visualiser in The Chase (1965), conversing with Elizabeth I; in Planet of Evil (1975), the Fourth Doctor mentions having met Shakespeare, and in City of Death (1979) he claims that he helped transcribe the original manuscript of Hamlet; and in The Mark of the Rani (1985) the Sixth Doctor says "I must see him [Shakespeare] again some time".

Among non-TV material, Shakespeare features in the Virgin Missing Adventures novels The Empire of Glass and The Plotters, and in the Big Finish Productions audio drama The Kingmaker. In another Big Finish drama, The Time of the Daleks, a child is revealed to be Shakespeare at the story's end. This has a sequel in Ian Potter's short story Apocrypha Bipedium in Short Trips: Companions, which concerns the young Shakespeare's anachronistic meeting with some of the characters he will later portray in Troilus and Cressida. Finally, the Bard also appears in the Doctor Who Magazine Ninth Doctor comic A Groatsworth of Wit (also written by Gareth Roberts).

Producer Russell T Davies and screenwriter Gareth Roberts have both stated that they were aware of these past references to meeting Shakespeare, but that they would neither be mentioned nor contradicted in the episode. Roberts added that although an early draft of "The Shakespeare Code" contained "a sly reference to City of Death", it was removed because "it was so sly it would have been a bit confusing for fans that recognised it and baffled the bejesus out of everyone else."

References to earlier Doctor Who episodes and stories The name of the Carrionites derives from screenwriter Gareth Roberts' own New Adventures novel, Zamper (1995), which refers to a slug-like race known as "arrionites". Roberts has said, "I always thought it was a nice word, and I was thinking of the witches as carrion creatures, so I bunged a C in front of it".Doctor Who Magazine 382

In Douglas Adams' lost adventure Shada, there is a passing reference to a Time Lord, Scintilla, who was imprisoned for conspiring with Carrionites; the novelisation of Shada was also written by Roberts.

There are several references to races from earlier Doctor Who episodes. At one point, the Doctor uses the title "Sir Doctor of TARDIS," which had been awarded to him by Queen Victoria in "Tooth and Claw" (2006). The Carrionites' contribution to Love's Labour's Won includes a reference to "Dravidian shores"; a "Dravidians starship" is mentioned in The Brain of Morbius (1976). Lilith refers to the Eternals, a race introduced in the original series serial Enlightenment (1983). In addition, the Doctor finds a skull in Shakespeare's prop store that reminds him of the Sycorax race from "The Christmas Invasion" (2005); when the Doctor mentions the name "Sycorax" to Shakespeare, Shakespeare says that he will use the name (the joke is that the name in fact derives from Caliban's mother in Shakespeare's play The Tempest.)

Other sequences include subtle references to much earlier episodes. One of the putative lines of Love's Labour's Won, "the eye should have contentment where it rests", is taken from episode three of the 1965 serial The Crusade — a story consciously written in Shakespearean style.

Outside references

References related to Shakespeare The episode concerns the "lost" Shakespeare play Love's Labour's Won, which is referred to in more than one historical document, but which may be just an alternative title for an extant play. Historically, a reference to Love's Labour's Won (in Francis Meres's Palladis Tamia, Wits Treasury, 1598) predates the construction of the Globe Theatre (1599).

The Doctor and Martha make numerous references to Shakespeare's appearance: she notes that he looks nothing like his portrait, and wonders why he is not bald, while the Doctor says he could make his head bald if he rubs it and later gives him a ruff to keep (calling it "a neck brace"). Shakespeare himself speaks with a noticeable Midlands accent, a reference to his birth and upbringing in Stratford-upon-Avon.

The episode makes reference to the many debates about Shakespeare's sexuality. Shakespeare flirts with Martha multiple times during the episode, and ultimately composes Sonnet 18 for her, calling her his "Dark Lady". This is a reference to the enigmatic female character in Shakespeare's Sonnets, although Sonnet 18 is in fact one of those addressed to a male character, the Fair Youth. Shakespeare subsequently flirts with the Doctor as well, at which the Doctor observes, "Fifty-seven academics just punched the air," a reference to the debates on this subject.

There is a running joke throughout the episode in which the Doctor creates an apparent ontological paradox by inspiring Shakespeare to borrow phrases that the Doctor quotes from his plays. Examples of this include the Doctor telling Shakespeare that "all the world's a stage" (from As You Like It) and "the play's the thing" (from Hamlet), as well as the name Sycorax from The Tempest. However, when Shakespeare himself coins the phrase "To be, or not to be", the Doctor suggests he write it down, but Shakespeare considers it "too pretentious". In a different version of the joke, the Doctor exclaims "Once more unto the breach", and Shakespeare initially likes the phrase, before realising it is one of his own from Henry V, which was probably written in early 1599. When questioning Shakespeare about witches, Martha remarks that he has written about witches; a reference to Macbeth, which Shakespeare denies. At the time in which the episode is set, Shakespeare had yet to write Macbeth or Hamlet, which prominently feature the paranormal, such as witches and ghosts.

There are numerous other allusions to Shakespeare's plays. Just before the Doctor steps out of the TARDIS, he exclaims "Brave new world", from Act V Scene I of The Tempest. In an early scene a sign is glimpsed for an inn named "The Elephant". This is the name of an inn recommended in Twelfth Night. The three Carrionites allude to the Weird Sisters from Macbeth (which was written several years after the setting of this episode); like them, the Carrionites use trochaic tetrameter and rhyming couplets to cast spells. When regressing the architect in Bedlam, The Doctor uses the phrase "A Winter's Tale", whilst the architect himself uses the phrase "poor Tom" in the same way as the 'mad' Edgar in King Lear.

Lilith credits the Carrionites' escape from the Eternals' banishment to 'new...glittering' words. Shakespeare is credited with adding two to three thousand words to the English language, including 'assassination', 'eyeball', 'leapfrog' and 'gloomy'.

The character Kempe is William Kempe, a highly regarded comic actor of the era, who was a member of the Lord Chamberlain's Men along with Shakespeare and Richard Burbage.

Wiggins is named after Doctor Martin Wiggins, an academic in the field of Elizabethan and Jacobean literature and the editor of several editions of influential plays of this period. Wiggins is also a Doctor Who fan and a friend of writer Gareth Roberts. According to Roberts, "if anyone was gonna trip me after transmission it'd be him, so I thought I'd butter him up first".

Other There are several references to the Harry Potter franchise. At one point, Martha says "It's all a bit Harry Potter", which prompts the Doctor to claim that he has read the final book in the series (which would not be released until three months after the episode was aired; the Doctor refers to it as "Book 7" because the title had not been made public at the time of filming). At the end of the episode, Shakespeare, the Doctor and Martha use a word from Harry Potter, "Expelliarmus", to defeat the Carrionites, and the Doctor exclaims "Good old J.K.!". These references include some metatheatrical humour, since David Tennant played the villain Barty Crouch, Jr in the film adaptation of Harry Potter and the Goblet of Fire.