28

I am doing my first LaTeX work using TeXstudios and I'm having trouble with an Undefined control sequence.

When I've checked solutions on google it appears as this is caused by typos in the different commands.

However, I have used the TeXstudios implemented menus to generate the codes so it shouldn't be any problem with that.

The code I'm having trouble with is

$x\in\mathbb{R}^{n}$

which I intend to become x belonging to the real numbers with n as an exponent.

I get the error

Undefined control sequence $x\in\mathbb
44

Load the package

\usepackage{amssymb}

to enable the macro \mathbb.

Loading the amsmath package too is always a good idea:

\usepackage{amsmath}

Here you'll find some more information.

  • Well thank you kind sir! I was under the impression that any missing packages would be detected and a prompt would show up asking if I wanted to install them! So basically, I have overlooked anything connected to packages. =) EDIT: Unfortunately I cannot rate your answer up as I lack the reputation – Cenderze Feb 26 '14 at 8:57
  • @GustavDanell: No, that it a MikTeX feature, where if you ask to load a file in the preamble (as the above), and it is not already installed, then MikTeX may attempt to install it for you. – daleif Feb 26 '14 at 9:29
  • Just to elaborate on what daleif said: MikTeX can install the packages (i.e. download them into your local TeX install), but it is still the user's responsibility to know which packages they need and to load them in the preamble. – Ubiquitous Feb 26 '14 at 12:52
  • 4
    actually, \mathbb is defined in amsfonts, but since amsfonts is loaded by amssymb, the effect is the same (at the cost of defining quite a few extra commands for symbol names). – barbara beeton Feb 26 '14 at 14:48
0

Using mathtools (amsmath + extensions), amsfonts has to be loaded to enable \mathbb.

\usepackage{mathtools}  % amsmath with extensions
\usepackage{amsfonts}  % (otherwise \mathbb does nothing)

If commands from amssymb are needed, just use it instead of amsfonts:

\usepackage{mathtools}  % amsmath with extensions
\usepackage{amssymb}  % (otherwise \mathbb does nothing)

(amssymb loads amsfonts)

  • This answer seems to provide the exact information already given in Herbert's answer and barbara beeton's comment. – Sandy G Jan 9 '18 at 20:33
  • @Sandy This answer is useful, in my opinion. Actually, I wrote it after searching whether it was exactly the same for mathtools or not... – ederag Jan 10 '18 at 19:45

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.