To enter code in LaTeX documents, the \verb|...| command can be used for inline code, as shown in examples like \[\verb|$y=2x+1$|\] and \[\verb|\prod_{i=m}^{\infty}x_{i}=\lim_{n\to\infty}\prod_{i=m}^{n}x_{i}|\]. For larger blocks of code, the \begin{verbatim}...\end{verbatim} environment is recommended. This approach allows for clear formatting and presentation of code within LaTeX documents.