I am writing an article regarding the history of the Morse code and I am having difficulties printing the dots and dashed (they get combined when the document is printed).

Is it also possible to write a macro that can map the Morse code to words and letterrs? For example the letter a is ".-" etc.

8 Answers 8


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


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.


% the alphabet list

% get the numbers 48-57

% letters
\@for \i:=\morselist\do{%
  \texttt{\char\thect =\i}\par
  \expandafter\xdef\csname\thect @\endcsname{\MM}%
% numbers
\@for \i:=\morsenumbers \do{%
  \texttt{\char\thect =\i}\par
  \expandafter\xdef\csname\thect @\endcsname{\MM}%



  \getMorseWord@ #1\relax

% type in the word you want printed in
% morse code here.
\getMorseWord{saltypen sos}
  • What is the upside of writing this yourself vs the morse package below?
    – Canageek
    Sep 24, 2011 at 18:06
  • 4
    @Canageek The upside for me was and is that I retain my skills with TeX/LaTeX programming:) If you learn to program you can do amazing things.
    – yannisl
    Sep 25, 2011 at 10:12

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

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

{\morse Some Text}

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:


 the letter #1 is {\morse #1}}



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

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


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.

  • Letters seem to match with what Wikipedia says, punctuation doesn't.
    – Caramdir
    May 26, 2011 at 2:28

Another solution, using the listings package and the literate key :







The result is

enter image description here


ConTeXt has a lua based module for morse code. It should be straight forward to translate it to LaTeX.

Here is an example usage:


\Morse{This is some text in English that will be translated to Morse code}


\MorseCode{—·—· ——— —· — · —··— —+—— —·— ·· ···—}

which gives

enter image description here

  • 404 - Object does not exist Apr 2, 2018 at 7:57

Here a solution based on TikZ. The idea is based loosly on my package TikZ-Timing. So far it only includes A-Z and 0-9 letters. You can change the length by using the x=<unit> key.



\def\@morse@char#1{\expandafter\def\csname @morse@char@#1\endcsname}

\def\tikzmorse@wordsep{++(4, 0)}
\def\tikzmorse@charsep{++(2, 0)}
\def\tikzmorse@Dit{ -- ++(1,0) ++(1,0) }
\def\tikzmorse@Dah{ -- ++(3,0) ++(1,0) }


\tikzset{morse/.style={thick,x=2pt}, morse draw/.style={}}
\newcommand\tikzmorse[2][]{\tikz[morse,#1] \@morse@draw{#2};}

    \draw [morse draw] (0,0) \@morse@path;

            \csname @morse@char@#1\endcsname




\tikzmorse[ultra thick]{ABEEEEEEECD}



enter image description here


When I needed to typeset a little Morse code for a book, I just used \rule and experimented with the width and length to make a nice dot and dash. I defined macros for those and then I used them to typeset what I wanted. Unfortunately $\rule{2pt}{2pt}$ doesn't work here.

  • I'm not sure that I understand... Does this work? If so please provide a demonstration.
    – qubyte
    Feb 19, 2012 at 13:43
  • You can use $\rule{2pt}{2pt}$ to typeset a 2pt square of ink. Treat that like a "dot". Similarly, you can use the \rule command to typeset "dashes" that are wider than they are high. Feb 19, 2012 at 20:45
  \def\tb{\textbullet $\;$}

  Morse code for alphabets. Normally these contain 4 dots or dashes and their


  $\t{a}$ & \tb  \tn & $\t{ b}$ & \tn  \tb \tb \tb & $\t{c}$& \tn \tb\tn \tb 
  &$\t{d}$&\tn\tb\tb \\\hline
   $\t{f}$&\tb\tb\tn\tb&$\t{g}$&\tn \tn\tb&$\t{h}$&\tb\tb\tb\tb\\\hline
   $\t{i}$&\tb\tb&$\t{j}$&\tb \tn\tn\tn&$\t{k}$&\tb\tn\tb&$\t{l}$&\tb\tn\tb\tb 
    $\t{m}$ & \tn\tn & $\t{n}$ & \tb\tb\tn & $\t{o}$ & \tn\tn\tn & $\t{p}$ &  
    \tb\tn\tn\tb \\\hline
   $\t{q}$& \tn\tn\tb\tn & $\t{r}$ & \tb\tn\tb & $\t{s}$&\tb \tb\tb&$\t{t}$&  
   $\t{u}$&\tb \tb \tn& $\t{v}$ &\tb\tb\tb\tn&$\t{w}$&\tb \tn \tn & $\t{x}$&  
   \tn \tb\tb \tn\\\hline
   $\t{y}$ & \tn\tb \tn\tn & $\t{z}$ & \tn\tn\tb\tb & & & & \\\hline


        The numerals are generated by 5 \tb and \tn.


     1 & \tb \tn\tn\tn\tn
     &2& \tb\tb\tn\tn\tn&3 & \tb\tb
    \tb\tn\tn & 4 & \tb \tb \tb \tb \tn\\\hline
    5 & \tb\tb\tb\tb\tb & 6 & \tn \tb \tb \tb \tb
      & 7& \tn\tn\tb\tb\tb & 8& \tn \tn \tn \tb \tb \\\hline
    9 & \tn \tn \tn \tn \tb & 0 & \tn\tn\tn\tn\tn && & & \\\hline


     Other useful Morse codes.

     full stop .& \tb \tn \tb \tn \tb& comma , & \tn \tn \tb \tb \tn \tn& quest   
   mark ? & \tb \tb \tn \tn\tb \tn \\\hline  
   apos trophe ' & \tb \tn \tn \tn \tb& excl !& \tn \tb \tb \tb\tn & slash    
   open par " &\tn \tb \tn \tn \tb & close par & \tn\tb \tn \tn \tn \tn& \& &   
   \tb \tn \tb \tb \tb \\\hline
   semi colon ;&\tn\tb\tn\tb\tn\tb& equal sign =&\tn\tb\tb\tb\tn& plus sign +&   
   \tb\tn\tb\tn\tb \\\hline
    hyph- en -& \tn\tb\tb\tb\tn & under score&\tb\tb\tn\tn\tb\tn& ques- tion    
    mark ?&\tb\tn\tb\t\tn\tb\\\hline
    dolar sign \$ & \tb \tb \tb \tn \tb \tb \tn& amp @ & \tb\tn\tn\tb\tn\tb\tb&  




    end of work&\tb\tb\tb\tn\tb\tn& error & \tb\tb\tb\tb  \tb\tb\tb\tb& invi
     te to start&\tn \tb \tn\\\hline
   starting signal & \tn \tb \tn \tb \tb& new page & \tb \tn \tb \tn \tb& under   
    wait & \tb \tb \tb \tb \tb&&&&\\\hline



    This is what I compiled for the Morse code after seeing a manual. It will    
    be useful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .