Shakespearean works
Shakespearean works, the plays and sonnets of William Shakespeare, and the Star Trek franchise have always been closely linked. Characters in the series quote the bard, episodes are titled after his works, and stories are adapted to fit the outer space locales. The following is a list of examples taken from the various series.

The Original Series 

 The title is a reference to Macbeth (II.i.38-39): "Or art thou but / A dagger of the mind, a false creation, / Proceeding from the heat-oppressed brain?"

 The title is a reference to Hamlet, Act II, Scene II: "the play's the thing wherein I'll catch the conscience of the king." The entire episode is around Shakespeare's works and themes, including the Karidian company performing both Hamlet and Macbeth on screen.

 The crew of the  beams down to the surface of the planet Pyris VII. Once on the ground, they investigate and are confronted by three witches reminiscent of those from Macbeth who chant: 

"Winds shall riseand fog descendSo leave here allor meet your end."

At this point, the logical Commander Spock replies, "Very bad poetry, Captain." 

 The title is from Romeo and Juliet, Act II, Scene II. Kirk makes additional reference while talking with a woman as he holds out a rose-like flower and says, "As the Earth poet Shakespeare wrote, 'That which we call a rose by any other name would smell as sweet'."

 Here the plot is lifted straight from The Taming of the Shrew with Kirk playing the part of Petruchio. Also, Captain Kirk's difficulty escaping Elaan's charms to fight a threatening Klingon warship echoes Antony and Cleopatra.

 Kollos, in Spock's body, references The Tempest when Kollos sees Miranda Jones for the first time through humanoid eyes: "O brave new world, That has such creatures in't." Miranda replies with the play's next line, "'Tis new to thee."  Additionally, the character Miranda Jones would seem to be named after Prospero's daughter Miranda from the play.

 Kirk recites part of Sonnet 57 while being manipulated by the Platonians. 

 Although the phrase itself has passed into the modern vernacular and may not have been intentionally taken from Shakespeare, it originates in  (V.ii.112-133): "every wink of an eye some new grace will be born: our absence makes us unthrifty to our knowledge." A Voyager episode would later be called , a commonly used variant.

 Marta partially quotes Sonnet 18.1-4 to Garth of Izar and claims authorship. Garth is not fooled by Marta's attempt. Marta drops a beat and uses a modern translation of a line, "and summer's lease hath all too soon" instead of the original, "too short a date." Though her interpretation is correct, the missing beat causes the iambic pentameter of the sonnet to break. This disruption may be a reflection on the chaotic situations of the episode.

 The plot of this episode borrows parts of The Tempest.

 The title comes from Macbeth, Act V, Scene V. It refers to the inhabitants of Sarpeidon, who intended to escape from the future by living in the past.

 The coat of arms of the Roman Proconsul,  was actually Shakespeare's coat of arms.

The Animated Series 
 The title is taken from a passage in King Lear, Act I scene IV: "How sharper than a serpent's tooth it is / To have a thankless child!"

The Next Generation 
 Picard briefly references the line from Henry VI, Part II "The first thing we do, let's kill all the lawyers" (IV.ii.74).

 Data recreates Shylock's court monologue from The Merchant of Venice, asking, "When you prick me do I not... leak?" The original line, in which the Jewish character Shylock tries to convince a group of Christians that Jews too are people, reads, "If you prick us, do we not bleed? If you tickle us, do we not laugh? If you poison us, do we not die?" (III.i.60-63).

 Q misquotes , saying "All the galaxy is a stage." Picard corrects him. Later Picard states that he does view mankind as "one day becoming that" which Hamlet asserts of it in irony: "Oh I know Hamlet. And what he might say with irony, I say with conviction: What a piece of work is man! How noble in reason, how infinite in faculty, in form and moving how express and admirable, in action how like an angel, in apprehension how like a god!" (II.ii.304-308). Later in the episode, declining Riker's offer to endow him with Humanity, Data again references Hamlet, quoting "This above all: to thine own self be true," from Polonius' speech to Laertes in Act 1, Scene 3.

  When it becomes clear that before Doctor Ira Graves died he must have programmed his own mind into Data's body, Picard, marveling at the achievement, recites the last two lines from Shakespeare's Sonnet 18: "So long as men can breathe, or eyes can see, / So long lives this, and this gives life to thee."

 While searching through Data's belongings, Bruce Maddox finds a book of Shakespeare's works, a gift from Captain Picard. Inside is a quote from Sonnet 29: "When in disgrace with fortune in men's eyes, / I all alone beweep my outcast state."

 The episode begins with Data performing Act IV, Scene I of Henry V, unaware that Captain Picard is watching. After the captain applauds his performance, Data says that he is using Shakespeare's works as a way to study Humanity, specifically observing the title-role performances of Olivier, Branagh (whose  was still in theaters when the episode aired), Shapiro, and Kullnark.
The role of Michael Williams was played, under heavy makeup, by Patrick Stewart, who, a noted Shakespearean actor, had asked to appear as one of his characters.

 Believing that Data is dead, Picard reads aloud from the android's copy of Shakespeare's works, quoting from Hamlet: "He was a man, take him for all in all, / I shall not look upon his like again" (I ii 187-188).

 Picard recites a string of quotes from Shakespeare's sonnets and Othello as part of his facade:
 Sonnet 147.1-2
 Sonnet 141.1-4
 Sonnet 18.1-2
 Othello. V.ii.13–16
It is interesting to note that Shakespeare's sonnets as a collective represent a ménage à trois that Shakespeare was believed to have been a part of (the young man, the dark lady, and the rival poet). Whether or not this information about the sonnets inspired the title of the episode, "Ménage à Troi," is unknown.

 This title may have been taken from Hamlet (I.i.112) "A mote it is to trouble the mind's eye." The phrase is also referenced later in Hamlet (I.ii.186). The phrase also appears in Plato's Republic.

 Trapped in the past (San Francisco in the 1880s), Captain Picard explains their seemingly odd behavior by explaining that they are practicing a performance of A Midsummer Night's Dream. They later rehearse Act II Scene i with Riker as Oberon, Data as Puck, and Crusher as the First Fairy. 

 When Picard awakens in Q's "afterlife", Q quotes briefly from Hamlet's famous "To Be Or Not To Be" speech with the words "Now that you've shuffled off the mortal coil," from Act 3 Scene 1.

 The title is taken from Polonius' advice in Hamlet, Scene I, Act III: "This above all: to thine own self be true, / And it must follow, as the night the day, / Thou canst not then be false to any man."

 The episode opens with Data performing the final scene in the The Tempest as Prospero. Also, much of the plot is taken from The Tempest as well as character names. 
An interesting note is that this is one of the series' final episodes and the use of the play is seen as an homage, since it is widely believed that The Tempest is Shakespeare's own farewell to the theater.

Deep Space Nine 
 The title is taken from The Tempest, Act II, Scene I. It actually reads "What's past is prologue." As prologue is something that comes before the body, the intention is that the past (specifically that of Kira Nerys) is the prologue for the series, as this was only its second episode.

 Writer Peter Allan Fields based Kor (as seen in DS9) on Falstaff. ()

 The title is taken from Twelfth Night (III.iv.201), in which Olivia pleads with a man who is actually Viola in disguise: "I have said too much unto a heart of stone." In the episode, Odo is similarly trapped with a Founder pretending to be Kira and betrays his love for her only to learn he has been talking to an impostor all along.

 The title is from Julius Caesar's The Gallic Wars while the following lines were paraphrased from Julius Caesar I.ii. 
 Tain: "How could this happen?"
 Elim Garak: "The fault, dear Tain, is not in our stars but in ourselves. Something I learned from Dr. Bashir."

 While watching Damar's speech,  quotes Shakespeare twice: first a line from Henry IV, Part II: "Uneasy lies the head that wears the crown" and then a paraphrased line from Macbeth: "Methought I heard a voice cry 'Sleep no more! Damar does murder sleep."

 The title is taken from Henry V, Act III, Scene I. "Once more unto the breach, dear friends, once more." (The title is also spelled "Once More Into the Breach" in re-run listings.)

 Dr. Bashir uses the phrase "never say die" at one point, which catches Senator Cretak by surprise. When she asks what it means, Luther Sloan, who claims etymology is one of his hobbies, politely interrupts to explain that the line originates from The Merchant of Venice and has passed into the vernacular as "an exhortation never to give up".

 Kahless is quoted as saying "Great men do not seek power; they have power thrust upon them."  This is a variation on a line from Shakespeare's Twelfth Night :"Be not afraid of greatness: some are born great, some achieve greatness, and some have greatness thrust upon them." This parallel may explain 's claim that the Bard was originally written in Klingon.

 The title is taken from Julius Caesar. The quote is "...and Caesar's spirit, ranging for revenge with Ate by his side comes hot from hell, shall in these confines with a monarch's voice Cry Havoc, and let slip the dogs of war, that this foul deed shall smell above the earth, with carrion men moaning for burial."

Voyager 
 The title character's speech to Captain Janeway claiming that he's a separate living creature with his own will and rights is reminiscent of (though not necessarily directly referential to) Shylock's speech from The Merchant of Venice. 

 The title is taken from Hamlet, Act III, Scene I: "To sleep: perchance to dream: ay, there's the rub; / For in that sleep of death what dreams may come / When we have shuffled off this mortal coil...".

Enterprise 
 Captain Drennik quoted from Hamlet, Act I, Scene V: ""There are more things in Heaven and Earth than are dreamt of in your philosophy."

Discovery 
 The title is taken from Macbeth, Act I, Scene VII. "I have no spur to prick the sides of my intent but only vaulting ambition, which o'erleaps itself and falls on the other"

 Like , the title is taken from The Tempest, Act II, Scene I. 

 Spock quotes Hamlet, Act I, Scene V: "Time is out of joint. O cursed spite, that I was born to set it right."

 and  The title is taken from Romeo and Juliet, Act II, Scene II: "Parting is such sweet sorrow that I shall say goodnight till it be morrow."

 The title is taken from Julius Caesar, Act IV, Scene III: "There is a tide in the affairs of men, which, taken at the flood, leads on to fortune; Omitted, all the voyage of their life, Is bound in shallows and in miseries. On such a full sea are we now afloat, And we must take the current when it serves, Or lose our ventures."

Lower Decks 
 In her role as Vindicta, Beckett Mariner quotes The Tempest: "Hell is empty. And all the devils are here. Our revels now are ended." (I.ii..215; IV.i.138).

 The episode's title comes from Shakespeare's erotic narrative poem Venus and Adonis. In the poem, the goddess Venus beseeches the beautiful mortal man Adonis, "Graze on my lips, and if those hills be dry, / Stray lower, where the pleasant fountains lie." (lines 233–234).

 Captain Dorg quotes from Julius Caesar (and from General  in ): "Cry Havoc! and let slip the dogs of war" (III.i.273)

Strange New Worlds 
 The title is taken from The Merchant of Venice, Act IV, Scene I: "The quality of mercy is not strained."

Films 
 A copy of King Lear and a book labeled Complete (illegible) Shakespeare sit upon Khan's bookshelf on the Botany Bay.

 The only Shakespeare reference here is Dr. McCoy, who again quotes Hamlet: "Angels and ministers of grace, defend us!" (I.iv.3). 

 The title is from Hamlet, Act III, Scene I: "But that the dread of something after death, / The undiscovered country from whose bourn / No traveller returns....".

One character, General Chang (Christopher Plummer), constantly quotes Shakespeare: Romeo and Juliet (II.ii.184), 2 Henry IV (III.ii.212), Richard II (III.ii.155-56), Henry V (III.i..1; III.i.32),  (III.ii.168; III.i.60; III.i.274), The Tempest (III.i..148), Merchant of Venice (III.i.56-63), and Hamlet (V.ii.10-11; I.iii.78; V.i..163; III.i.58-60; III.i.57).

The character of Martia (Iman), a shapeshifter, quotes from Hamlet when she says, "I thought I would assume a pleasing shape" (II.ii.612).

 A wounded alternate reality Spock quotes from Measure for Measure, saying "The miserable have no other medicine but only hope."

Apocrypha 
In the script for , Picard makes a toast to new worlds, to which he adds "to brave new worlds", referencing the Tempest. The line was cut by the time the scene was filmed, and the scene was then deleted wholly.

An okudagram that does not appear to have been used on screen contained a character called B. Ornot Tobe, referencing the "[To] be, or not to be" quote from Hamlet.

Several Star Trek comics have bore titles taken from Shakespeare:
 Marvel TOS
 #15 "The Quality of Mercy"
 DC TOS volume 2
 #10 "The First Thing We Do..."
 #11 "... Let's Kill All the Lawyers!"
 Star Trek: The Next Generation - Perchance to Dream
 "To Take Arms Against a Sea of Troubles"
 "By a Sleep to Say We End"
 "In the Sleep of Death, What Dreams May Come"
 "Enterprises of Great Pitch and Moment"

Also, several  Star Trek novels have titles that reference Shakespeare:

Pocket  TOS
 Thin Air
 Past  Prologue
 Foul Deeds Will Rise
Pocket  TNG
 Perchance to Dream
 The Death of Princes
 Immortal Coil
 Slings and Arrows ebook miniseries
 A Sea of Troubles
 The Oppressor's Wrong
 The Insolence of Office
 That Sleep of Death
 A Weary Life
 
 The Stuff of Dreams
 Shadows Have Offended
 Star Trek:  The Lost Era
 Deny Thy Father
Pocket  DS9
 Lust's Latinum Lost (and  Found) ebook
Pocket  ENT
 The Good That Men Do

External link 
 Shakespeare and Star Trek - an essay by Sean Hall, created for Dr. Michael Delahoyde of Washington State University in spring of 2002
Star Trek and pop culture