In English, it is common to leave a preposition at the end of a sentence or clause (e.g., "the person I am traveling with"). In Portuguese, the preposition cannot be separated from the pronoun it modifies. It must always come right before the relative pronoun (e.g., "the person with whom I am traveling").
When connecting ideas to specify a person after a preposition, always use the relative pronoun quem (who/whom).
To describe someone you are doing an activity with, use com quem (with whom).
Many Portuguese verbs require the preposition de (of/from/about). Common examples include gostar de (to like), falar de (to speak about), and cuidar de (to take care of). When these verbs appear in a relative clause describing a person, you must use de quem.
Using "a quem" and "em quem"
When an action is directed to someone, such as writing a message or giving something, use a quem (to whom). This acts as the indirect object of the relative clause.
Similarly, some verbs require the preposition em (in). For example, the verb confiar (to trust) is always followed by em. To say "the friend I trust", you literally say "the friend in whom I trust" (em quem).