6

This question already has an answer here:

I'm looking for a LaTeX symbol that has the letters 'NUL' in a single character width. It's a pretty representation for what's often entered as \0 in C-derived programming languages as the string termination character. In Unicode, this is represented as code point U+2400.

To be clear, I'm not looking for:

  • \varnothing
  • \emptyset
  • and definitely not \phi!

I should also be clear that I'm looking for a representation of a control character, to print or display it rather than have it perform its intended function as a control character.

As a strongly related side question, assume I know the code point of a Unicode glyph. Is there a way to determine what the glyph's equivalent is in LaTeX? I'm relatively new to LaTeX typesetting, so I haven't yet found such a reference.

marked as duplicate by user13907, Stefan Pinnow, Mico, darthbith, Seamus Apr 15 '16 at 11:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

If you are on pdflatex, you can use the ascii package:

\documentclass{article}
\usepackage{ascii}

\begin{document}

Is this it? \NUL

\end{document}

enter image description here

You can also input the symbol directly as Unicode, so the code can be portable to XeLaTeX or LuaLaTeX.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{ascii}
\usepackage{newunicodechar}

\newunicodechar{␀}{\NUL}

\begin{document}

Is this it? ␀

\end{document}

With XeLaTeX or LuaLaTeX and fontspec, find a font with the character and then do like

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\newfontface{\ASCIICONTROLS}{FreeMono} % <--- or another font
\newunicodechar{␀}{{\ASCIICONTROLS ␀}}

\begin{document}

Is this it? ␀

\end{document}

enter image description here

9

If a TeX engine is used with Unicode/OpenType font support, then it is just a matter to find a font that contains the Unicode code point U+2400, e.g.:

% lualatex or xelatex
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\def\test#1{#1:&\fontspec{#1}\symbol{"2400}\\}
\begin{tabular}{l@{ }l}
  \test{FreeMono}
  \test{FreeSans}
  \test{FreeSerif}
  \test{Quivira}% http://www.quivira-font.com/
\end{tabular}
\end{document}

Result

2

If you wanted it to conform to the current font, both in size and style, you could build your own:

\documentclass[a2]{article}
\usepackage{stackengine,scalerel}
\newcommand\NUL{\scalerel*{$\Shortstack[l]{N \phantom{N}U \phantom{NU}L}$}{X}}
\begin{document}
\LARGE
This is \NUL

\normalsize
This is \NUL

\itshape
This is \NUL

\upshape\ttfamily
This is \NUL

\end{document}

enter image description here

If one wanted the symbol always in bold, for clarity, then

\newcommand\NUL{\scalerel*{$\bfseries\Shortstack[l]{N \phantom{N}U \phantom{NU}L}$}{X}}

would remedy that:

enter image description here

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