If we talk about relative pronouns with preposition we mean something like that.
The knife
with which
she sliced the cake lies on the table.
The sea
above which
the bird flew was deep blue.
The plate
from which
he had eaten had a golden rim.
Philosophical remark: As far as English is concerned a distinction between a direct and an indirect object is not really necessary, because even in the case that the direct object / indirect object is a pronoun, there is no difference.
direct object: I see him.
indirect object: I give him the cake.
In both cases it is him. That's why in English grammars we find very often the term object pronouns, a term that doesn't make any sense in most languages, because at least the pronouns have different forms. In Portuguese for instance him (direct object) is o and him (indirect object) is lhe. It is very useful to know the difference between a direct object and an indirect object, because that is crucial for understanding the grammar of almost any other language, but in English there is no difference in the form.
The situation in Portuguese and other roman languages is a little bit different. In English it is irrelevant whether the personal pronoun is used as a direct object, an indirect object or is used together with a preposition, it is always the same pronoun.
direct object: I see you.
indirect object: I give you the book.
pronoun used with a preposition: I don't want to go there with you.
In Portuguese and roman languages in general we have a totally different system. We have a clear distinction in the personal pronouns between direct and indirect object, see personal pronouns. However there are as well the so called pronomes oblíquos tônicos, that are used with prepositions. The problem is that in Portuguese any kind of object that is added to the verb through a preposition is called indirect object. This is a little bit confusing, because the difference between a direct object and an indirect object, a difference clearly made in the case of the personal pronouns, is blurred. As far as only nouns are concerned the term indirect object make sense. The indirect object in Portuguese is marked by the preposition a. We can say that this is not a special case, but just a preposition with a noun that follows the same pattern as any other combination of preposition + noun or preposition + que / quem / qual. That's the way brasilians grammars see it and as far as nouns are concerned it is correct. However in the case of the pronouns the indirect object has a specific form.
O Objeto Indireto é um complemento verbal obrigatoriamente acompanhado por preposição. Ele tem como função completar o sentido dos verbos transitivos que por eles só não fornecem informação completa.
The indirect object is a verbal complement always accompanied by a preposition. In the case of transitive verbs they provide the information not provided by the verb alone.
Actually what is called in Brasilian grammars objeto indireto would be called in English a prepositional object (He learned a lot about plants / They did it without any help / He apologized for the inconvenient). If it is a good idea to call an prepositional object a direct object can be questioned. It is true that in a lot of languages, although not in the majority of languages, the indirect object is or can be added to the verb by a preposition (I give the book to Jim), however in most languages the indirect object is not a prepositional object, but has its own form and there are very few languages, for instance English and Persian, where the personal pronouns don't have a specific form for the indirect object. This remark may seem very philosophical to most people, however if someone wants to learn russian, Arabic, german, hungary etc.. he or she will come into touch with something called declension and in this case one should understand the difference between a case an a prepositional object. End of the philosophical remark.
In the case of monosyllabic prepositions there is a preference for quem in case that preposition refers to a person.
Quem, in case that the prepositional object is a person
Desaponto
as
pessoas
de
quem
mais
gosto.
Disappoint
the
persons
of
whom
more
like.
I disappoint the persons I am most fond of.
Esta
é
a
menina
a
quem
dei
um
presente.
This
is
the
girl
to
whom
gave
a
present.
This is the girl I gave a present to.
O
bandido
por
quem
fomos
atacados
fugiu.
The
bandit
by
whom
were
attacked
fled.
The bandit who mugged us fled.
Que, in case the prepositional object is a thing.
O
avião
em
que
nós
viajamos
fez
escala
em
Madrid.
The
airplane
in
which
we
travelled
made
stopover
in
Madrid.
The flight we booked made a stopover in Madrid.
Comprei
a
casa
a
que
você
se
referiu.
Bought
the
house
to
which
you
yourself
referred.
I bought the house you referred to.
A
casa
em
que
moro
é
bem
cuidada.
The
house
in
which
live
is
well
maintained.
The house I live in is well maintained.
A
peça
de
que
te
falei
estreia
hoje.
The
play
of
which
you
spoke
performs
today
The play I talked you about is performed today.
Those who speak Spanish should pay attention to the fact that que in Portuguese is invariable. It is simple preposition + que and not as in Spanish preposition + article + que.
Portuguese:
É o livro
com que
estudo.
Spanish:
Es el libro
con el que
estudio.
That is the book I learn with.
Portuguese:
São os livros
com que
estudo.
Spanish:
Son los libros
con los que
estudio.
These are the books I learn with.
Que is very often described as "universal". That means that it can refer to persons as well as to things, it can be the subject and the direct object in relative clause and can be used together with disyllabic prepositions.
If the relative pronoun is the indirect object of the relative clause and a person the relative pronoun is quem. For those who speak Spanish: No, in opposite to Spanish a plural form, in Spanish quienes, doesn't exist. Whether it is only one person or several persons, it is always quem.
The relative pronoun is an indirect object in the relative clause and is a person. As any indirect object it is marked with the preposition a.
A
mulher
a quem
dou
o
livro.
The
woman
to whom
I gave
the
book.
O
homem
a quem
dou
o
livro.
The
man
to whom
I gave
the
book.
As
mulheres
a quem
dou
o
livro.
The
women
to whom
I gave
the
book.
Os
homens
a quem
dou
o
livro.
The
men
to whom
I gave
the
book.
If the relative pronoun is subject or direct object of the relative clause in general que is used. In some grammars we can read the quem is possible as well if the relative pronoun refers to a person, but the author of these lines has the impression that this is only possible in the case of nonrestrictive relative clauses. (Concerning the difference between nonrestrictive and restrictive relative clauses see 10 relative pronouns.) Furthermore, even in the case that quem is the DIRECT object in the relative clause, in case it is the indirect object a is obviously needed, the preposition a is needed. In Portuguese exists therefore something similar to the Spanish acusativo personal. If the the direct object is a person, we have to add the preposition a, that is normally a marker for an indirect object. Quem can only be used in nonrestrictive relative clauses.
(Remark: In English the relative pronoun can be omitted. This in never possible in Portuguese: The man that I talk with. <=> The man I talk with.)
subject: quem is possible in nonrestrictive relative clauses
1) rectrictive relativ clause:
Os homens
que
falam muito e fazem pouco são inúteis.
The men who talk a lot but do nothing are useless.
2) nonrestrictive clause:
No Rio de Janeiro conheceu Machado de Assis,
quem
o ajudou a se inserir no meio literário.
In Rio de Janeiro he got acquainted with Machado de Assis, who helped him gain a foothold in the world of literature.
direct object: quem is possible in nonrestrictive relative clauses
3) rectrictive relativ clause:
A todos os meus amigos
que
encontrei aqui.
For all my friends I met here.
4) nonrestrictive clause:
O homem perdeu a esposa,
a quem
tanto amava.
The man lost his wife, who he loved so much.
Explanations concerning the difference between a restrictive relative clause and a nonrestrictive relative clause.
1)
Without the relative clause we would have "The men are useless" and the meaning completely different compared to the original sentence. The relative clause restricts the group and is therefore a restrictive relative clause. (The restrictive clause is NOT separated by a comma, nor in Portuguese nor in English.)
2)
Machado de Assis is a famous Brasilian author. The relative clause only adds some information, but without the relative clause, "In Rio de Janeiro he got acquainted with Machado de Assis", the meaning of the sentence doesn't change, only some information would get lost. Given that the meaning of the sentence is only extended, but not changed, it is a nonrestrictive relative clause. (The nonrestrictive relative clause is separated, in English and in Portuguese, by a comma.)
3)
Without the relative clause he would refer to all of his friends, but the original meaning is, that he only refers to the friends who are there. Without the relative clause the meaning would change, because the group is restricted and therefore it is a restrictive relative clause.
4)
Without the relative clause we would get "The man lost his wife" and the meaning remains unchanged by the relative clause. We get some extra information, but the meaning remains the same. There is no restriction and therefore it is a nonrestrictive relative clause.
In all roman languages, and therefore as well in Portuguese, only the nonrestrictive relative clause is separated by a comma.