1. Take out a pencil out of the pencil case.

2. Take out a pencil from the pencil case.

3. Take out a pencil in the pencil case.
----------------------
Are they all grammatical? Does #1 mean #2? Which one is a common expression? Is #3 okay? Does #3 mean that there is only one pencil?

1 -- remove the first "out"

2 -- remove "out"
3 -- Awkward sentence, but it's not incorrect. The prepositions "out of" and "from" are better for this meaning.

All of them seem to mean to take out one pencil from many in the pencil case.

Out of the three sentences you provided, #2 is the most common and grammatically correct way to express the action of retrieving a pencil from a pencil case.

Sentence #1, "Take out a pencil out of the pencil case," contains redundant wording. The phrase "out of" is unnecessary since "take out" already implies removing something from a specific location. Therefore, it is grammatically incorrect.

Sentence #3, "Take out a pencil in the pencil case," is grammatically correct, but it may cause confusion or ambiguity. It suggests that there might be multiple pencils inside the pencil case, but only one pencil is being taken out. To clarify that there are multiple pencils in the case, you could use a phrase like "one of the pencils" or "a pencil from among those in the pencil case."

In summary, the most common expression is sentence #2, "Take out a pencil from the pencil case." It clearly conveys the action of removing a pencil from the pencil case without redundancy or ambiguity.