18

I would like to add this symbol: � to a beamer presentation. It is shown when something went wrong with the encoding.

Sadly, I can't simply include this symol:

[53]
! Package inputenc Error: Unicode char \u8:� not set up for use with LaTeX.
See the inputenc package documentation for explanation.

and I don't have any idea how to get it in LaTeX

(An image is not the solution I would like to use!)

Detexify didn't help either.

Description of the symbol (to make it easier to find):

  • a black diamond with a white question mark within or
  • a black sexagon with a white question mark
  • seems to be "\xa0" in sed

How is this symbol � called? How can I print it with LaTeX?

4 Answers 4

8

Following David Carlisle's suggestion here's a TikZ solution:

\documentclass{standalone}

\usepackage{tikz}
% w/o following space!
\newcommand{\quem}{\tikz[baseline=(wi.base)]{\node[fill=black,rotate=45,inner sep=.1ex, text height=1.8ex, text width=1.8ex] {};%
\node[ font=\color{white}] (wi) {?};}}

\begin{document}

 Some  \quem Text

\end{document}

You may alter the size of the black triangle by playing with inner sep and keep in mind that there is no space an the end of the macro.

11

The symbol you actually pasted into this question is U+FFFD Thus is the Unicode replacement character that applications use as a substitute when they are otherwise confused. It doesn't have a default presentation as it is essentially a kind of control character. The font here is showing it in that form.

If you don't specifically need it as a single text character you could of course produce it in latex by including an image or by over-printing a white question mark over a black diamond.

So in pdflatex this works:

enter image description here

\documentclass{beamer} 

\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{FFFD}{\colorbox{black}{\color{white}?}}

\usepackage{array}

\begin{document}      

% Methode 1                                             
\begin{frame}

This is U+FFFD (�)

\end{frame}
\end{document}

Obviously you can put more design into the white on black ? if needed, this just shows the basic idea.

2
  • +1. I was so free as to use your suggestion (over-printing) for another answer. Now there are three solutions: \DeclareUnicodeCharacter, TikZ, over-printing. Nice!
    – Stephen
    Nov 11, 2012 at 11:35
  • @Stephen the \DeclareUnicodeCharacter is an input side declaration independent of the way the character is rendered, you could use it with either of the other two solutions posted so that the input character (�) produce the tikz code \DeclareUnicodeCharacter{FFFD}{\quem} or the overprint \DeclareUnicodeCharacter{FFFD}{\encodingerror} Nov 11, 2012 at 11:47
7

and a solution without loading a bombastic package:

\documentclass{standalone}
\usepackage{graphicx,color}
\makeatletter
\newsavebox\Diam@nd \newlength\x@D\newlength\y@D
\newcommand\Quem{%
  \sbox\Diam@nd{\raisebox{-1ex}{\scalebox{1}[1.2]{\rotatebox{45}{\rule{1em}{1em}}}}}%
  \makebox[\wd\Diam@nd]{\makebox[0pt]{\usebox\Diam@nd}\makebox[0pt]{\textcolor{white}{?}}}}
\makeatother

\begin{document}

Some  \Quem\ Text \huge \Quem\ Text 

\end{document}

enter image description here

It also takes the fontsize into account

3
4

Over-printing a white question mark over a black diamond, as suggested by David Carlisle, could be accomplished by

\documentclass{article}

\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{relsize}
\usepackage{xspace}

\newlength{\encerr}

\newcommand{\encodingerror}{%
  \hbox{%
    $\blacklozenge$%
    \settowidth{\encerr}{$\blacklozenge$}%
    \hspace{-0.77\encerr}%
    {\color{white}\textsmaller[2]{?}}%
   }%
  \xspace%
 }

\begin{document}

An \encodingerror occurred.

\end{document}

An <?> [encoding error] occurred.

The xspace could also be used for bloodworks' answer, of course.

You must log in to answer this question.

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