XeLaTeX and pdfLaTeX ignore \hyphenation

The default language (American English) sets \lefthyphenmin=2 and \righthyphenmin=3. Thus no TeX engine will hyphenate past the m, whatever hyphenation points you define.

If you try

\documentclass{article}
\usepackage[italian,english]{babel}

\begin{document}

\hyphenation{Py-ra-mi-de}

\showhyphens{Pyramide}

\selectlanguage{italian}

\hyphenation{Py-ra-mi-de}

\showhyphens{Pyramide}

\end{document}

you get

Underfull \hbox (badness 10000) in paragraph at lines 8--8
\TU/lmr/m/n/10 Py-ra-mide

Underfull \hbox (badness 10000) in paragraph at lines 14--14
\TU/lmr/m/n/10 Py-ra-mi-de

It wouldn't be necessary to set the hyphenation points again, actually, because the hyphenation you want fits into the patterns for Italian. The settings for this language have \lefthyphenmin=2 and \righthyphenmin=2.


You must set the hyphenmins correctly:

\documentclass{standalone}
\hyphenation{Py-ra-mi-de}


\begin{document}
\showhyphens{Pyramide}

\righthyphenmin1
\lefthyphenmin1

\showhyphens{Pyramide}

\end{document}

The first \showhyphens gives your output but the second now

\TU/lmr/m/n/10 Py-ra-mi-de