5

I can't figure out why LaTeX won't let me use the symbol (U+1D53D, mathematical double-stuck capital F). When I try, I get the error Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.

The input file is UTF-8 encoded. Here is a minimal working (or rather, non-working) example to demonstrate the issue.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\begin{document}
% \newcommand{\eff}[1]{F\text{#1}}
\newcommand{\eff}[1]{\text{#1}}
$ \eff{some} $
\end{document}

When using the first variant of \eff, everything works (the output is rendered as "Fsome" with an italic F, just as expected). However, if I comment that one out and instead uncomment the second variant, I get the error on line 8 (where I actually use the freshly defined command).

I'm using pdfLaTeX 3.1415926-1.40.10-2.2 from and on Debian Squeeze (package texlive-latex-base version 2009-11+squeeze1) with no special options at all (just pdflatex mwe.tex) to try to render the document.

I find it hard to believe that nobody would have wanted to use this particular symbol in a LaTeX document, so surely it can be done. What am I missing?

lockstep
  • 250,273
user
  • 153
  • 5
    You can use \mathbb{F} from the package amssymb, see http://texblog.org/2007/08/27/number-sets-prime-natural-integer-rational-real-and-complex-in-latex/ – N.N. Sep 29 '12 at 08:02
  • 1
    I would assume that not every symbol defined in Unicode is actually mapped to a glyph that is available in the fonts you are using. This is also going to create portability problems for your source code. – Christian Lindig Sep 29 '12 at 08:03
  • @N.N. \mathbb{F} worked perfectly, thank you! If you make that an answer, I'll accept it. – user Sep 29 '12 at 08:06
  • 1
    @ChristianLindig As for source code portability, this is a personal document so portability is not a great concern for me. (And on that note it's worth noting that the particular symbol happens to be mapped to a glyph in the window title bar font I use, but not the font Firefox uses for active only tab title text. Go figure. :)) – user Sep 29 '12 at 08:06
  • @MichaelKjörling The fonts used for window decoration by your operating system are not necessarily the ones used by LaTeX to render your document to PDF or PostScript. – Christian Lindig Sep 29 '12 at 09:06
  • @ChristianLindig Quite right. I just mentioned it as an aside, illustrating your very point about glyph availability in fonts. – user Oct 01 '12 at 11:10

2 Answers2

14

If you want to use inside your document you can use:

Edit:

As egreg pointed out you can use the package newunicodechar which makes it easier:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage{newunicodechar}
\newunicodechar{}{\ensuremath{\mathbb{F}}}
\begin{document}

\end{document}

Original:

% !TEX program = pdflatex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}

\expandafter\def\csname u8:\detokenize{}\endcsname{\ensuremath{\mathbb{F}}}
\begin{document}

\end{document}

The command \ensuremath is testing whether you are in math mode or not and sets the argument in math mode.

Frank Mittelbach wrote a great explanation about inputenc:

How can I get utf8 character

Marco Daniel
  • 95,681
  • 4
    \usepackage{newunicodechar} and then \newunicodechar{}{\mathbb{F}} is simpler. :) – egreg Sep 29 '12 at 08:46
  • @egreg: Oh a new package ;-) -- However I use \ensuremath ;-) – Marco Daniel Sep 29 '12 at 08:47
  • It's not new (2011/02/18); don't use \ensuremath: that's a math symbol and ought to be used only in math. I added an answer to Frank's. – egreg Sep 29 '12 at 08:57
  • @egreg: The package is new in my repertoire ;-). – Marco Daniel Sep 29 '12 at 09:08
  • 1
    Package selinput v1.3 (requires rempreamblecmds v1.0) provides \DeclareInputUnicodeChar and \DeclareInputChar that also support utf8x.def from package ucs that has a different syntax for \DeclareUnicodeCharacter. Also these commands can be used after \begin{document}. (The PDF files above also contain the DTX files as attachments that are unpacked using plain TeX, release to CTAN later.) – Heiko Oberdiek Sep 29 '12 at 12:30
7

As explained at LaTeX Matters you can use the package amssymb or amsfonts together with the macro \mathbb and F as an argument. Note that you have to use \mathbb in math mode.

\documentclass{article}

\usepackage{amssymb}            % or \usepackage{amsfonts}

\begin{document}

\(\mathbb{F}\)

\end{document}

If you want to define your own macro like you do in your example this is possible with \mathbb{F} too.

N.N.
  • 36,163
  • This worked perfectly. Now, in my actual document it's claiming that I'm not in math mode, but that's a completely separate issue. Thank you! – user Sep 29 '12 at 08:12
  • 1
    @MichaelKjörling You have to use \mathbb inside math mode, e.g. as \(\mathbb{F}\). – N.N. Sep 29 '12 at 08:13
  • Yes, I had a mix of math mode and text mode, and had got the ordering wrong. That was a trivial fix once I saw the error (which was easy to spot from the differences between my actual document and the MWE). – user Sep 29 '12 at 08:17