6

I recently discovered at that one can make many symbols by pressing Alt + num pad. I then tried to insert these symbols into my latex file, and it compiled, but just seemed to insert a space there.

The symbols I am talking about are: ☺☻♥♦♣♠•◘○ (Alt + 1-9).

They show up in my editor (winEdt 8).

MWE:

\documentclass{article}
\begin{document}
☺☻♥♣♠•○
\end{document}
  • AFAIK, they are control (non-printable) characters. See Unicode tables here or here – karlkoeller Jul 17 '13 at 4:38
  • @karlkoeller those are the ascii chars 1-9. These are other characters. The heart for example is U+2665. – soandos Jul 17 '13 at 4:42
10

Symbols can be looked up in "The Comprehensive LaTeX Symbol List":

ascii

UTF-8 as input encoding

If UTF-8 is used as input encoding, then the symbols can be defined using packages ascii for the symbols and newunicodechar for an easier interface of \DeclareUnicodeCharacter:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{ascii}
\usepackage{newunicodechar}
\newunicodechar{☺}{\SOH}
\newunicodechar{☻}{\STX}
\newunicodechar{♥}{\ETX}
\newunicodechar{♣}{\ENQ}
\newunicodechar{♠}{\ACK}
\newunicodechar{•}{\BEL}
\newunicodechar{○}{\HT}

\begin{document}
☺☻♥♣♠•○
\end{document}

Result

Remarks:

  • The symbol is already defined with \textbullet. Therefore \newunicodechar generates a warning, when replacing it with \BEL:

    Package newunicodechar Warning: Redefining Unicode character on input line 11.
    

8-bit encodings

Some of the control character slots are covered by package inputenc. Others cannot be used, because line ends control characters are needed for line ends, for example.

However, if an 8-bit encoding is used with package inputenc, then usually the control characters are not assigned. With package ascii for the symbols it can be done the following way. To avoid trouble with copy and paste from the web page, I have used the ASCII replacement notation with ^^ after \begin{document}:

\documentclass{article}

\usepackage{ascii}
\usepackage[ansinew]{inputenc}
% \NUL
\DeclareInputText{1}{\SOH}% ^^A
\DeclareInputText{2}{\STX}% ^^B
\DeclareInputText{3}{\ETX}% ^^C
\DeclareInputText{4}{\EOT}% ^^D
\DeclareInputText{5}{\ENQ}% ^^E
\DeclareInputText{6}{\ACK}% ^^F
\DeclareInputText{7}{\BEL}% ^^G
\DeclareInputText{8}{\BS}% ^^H
% \HT
% \LF
\DeclareInputText{11}{\VT}% ^^K
% \FF
% \CR
\DeclareInputText{14}{\SO}% ^^N
\DeclareInputText{15}{\SI}% ^^O
\DeclareInputText{16}{\DLE}% ^^P
\DeclareInputText{17}{\DCa}% ^^Q
\DeclareInputText{18}{\DCb}% ^^R
\DeclareInputText{19}{\DCc}% ^^S
\DeclareInputText{20}{\DCd}% ^^T
\DeclareInputText{21}{\NAK}% ^^U
\DeclareInputText{22}{\SYN}% ^^V
\DeclareInputText{23}{\ETB}% ^^W
\DeclareInputText{24}{\CAN}% ^^X
\DeclareInputText{25}{\EM}% ^^Y
\DeclareInputText{26}{\SUB}% ^^Z
\DeclareInputText{27}{\ESC}% ^^[
\DeclareInputText{28}{\FS}% ^^    \DeclareInputText{29}{\GS}% ^^]
\DeclareInputText{30}{\RS}% ^^^ or ^^1e
\DeclareInputText{31}{\US}% ^^_
\DeclareInputText{127}{\DEL}% ^^?

\begin{document}
  \noindent
  \NUL^^A^^B^^C^^D^^E^^F^^G\\
  ^^H\HT\LF^^K\FF\CR^^N^^O\\
  ^^P^^Q^^R^^S^^T^^U^^V^^W\\
  ^^X^^Y^^Z^^[^^\^^]^^1e^^_\\
  ^^?
\end{document}

Result

| improve this answer | |
  • Why is that the char appear fine in the source file and need to be remapped? – soandos Jul 17 '13 at 6:15
  • 1
    TeX only see bytes as input. Without further treatment, they are mapped directly to the font slots of the current font. And in the often used font encodings OT1 or T1 these slots contain different characters. Package inputenc makes the non-printable ASCII characters active and allows a mapping. This is mostly used for 8-bit characters and are loaded via option of pacakage inputenc (e.g. ansinew). – Heiko Oberdiek Jul 17 '13 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.