How do I typeset morse code with LaTeX

Here is a slightly different solution than the others posted.

First we define two lists to hold the morse code. One for letters and another one for numbers

\def\morselist{.-,-...,-.-.,-..,.,..-.,%
    --.,....,..,.---,-.-,.-..,%
    --,-.,---,.--.,--.-,.-.,%
    ...,-,..-,...-,.--,-..-,-.--,--..}

This list is then used to create macros for every letter and number. Once this is achieved one can parse any word and print the corresponding Morse symbols.

\documentclass{article}
\usepackage{soul}
\newcounter{ct}
\begin{document}
\makeatletter

% the alphabet list
\def\morselist{.-,-...,-.-.,-..,.,..-.,%
--.,....,..,.---,-.-,.-..,%
--,-.,---,.--.,--.-,.-.,%
...,-,..-,...-,.--,-..-,-.--,--..}

% get the numbers 48-57
\def\morsenumbers{.----,..---,...--,....-,
.....,-....,--...,---..,----.,-----}

% letters
\setcounter{ct}{97}
\@for \i:=\morselist\do{%
  \texttt{\char\thect =\i}\par
  \def\MM{\i}%
  \expandafter\xdef\csname\thect @\endcsname{\MM}%
  \stepcounter{ct}%
}
% numbers
\setcounter{ct}{48}
\@for \i:=\morsenumbers \do{%
  \texttt{\char\thect =\i}\par
  \def\MM{\i}%
  \expandafter\xdef\csname\thect @\endcsname{\MM}%
  \stepcounter{ct}%
}

\def\printMorse#1{%
  \texttt{\@nameuse{\number`#1@}}
}

\def\getMorseWord@#1#2\relax{%
  \ifx\relax#2\relax
     #1=\printMorse{#1}
   \else
      #1=\printMorse{#1}%\par
      \getMorseWord@#2\relax
  \fi
 }

\def\getMorseWord#1{%
  \getMorseWord@ #1\relax
}

% type in the word you want printed in
% morse code here.
\getMorseWord{saltypen sos}
\makeatother
\end{document}

There's the morse package; it's a little old, but it seems to work fine, although I wouldn't know for sure since I don't know anything about the Morse code (except that it exists); a little example:

\documentclass[12pt]{article}
\usepackage{morse}

\newcommand\LatMor[1]{%
 the letter #1 is {\morse #1}}

\begin{document}

\LatMor{a}\LatMor{b}\LatMor{x}\LatMor{y}\LatMor{z}

{\morse M o r s e T e x t}

{\Large\morse  M o r s e T e x t}

\end{document}

Probably you will have to install the package manually, but it seems easy; I just did the test copying all the files in my working directory and everything was OK.

EDIT: I updated the answer with the definition of the \LatMor command.


Then answer


More seriously, if you have a Morse code font in ttf or otf format, you can use fontspec to you that font:

% compile with lualatex or xelatex
\documentclass{article}
\usepackage{fontspec}

\newfontface\morse{Morse Code} % replace with the actual name of the font

\begin{document}
{\morse Some Text}
\end{document}