[Tex/LaTex] Real Number Symbol \R not working

amsmathamssymb

I want to insert an in-line equation with the symbol of Real Number as the code below:

Let $X$ be a continuous random variable with CDF $F(x) = log_{c}(x)$
where $x \in [1,c]$ and $c \in \R_{++}$.

LaTex gives me this error "Undefined control sequence …" when inserting \R.

Don't know why this happens. Maybe it's related to the amsmathpackage.

This my preamble:

\documentclass[12pt, a4wide]{article}

\usepackage{graphicx}
\usepackage{color}

\usepackage{framed}
\usepackage{alltt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage[backref=page]{hyperref}
\usepackage[labelfont=bf]{caption}
\usepackage{capt-of}
\usepackage{adjustbox}
\usepackage{amsmath,amsfonts,amssymb}
%\usepackage{showframe}
\usepackage[authoryear]{natbib}
\usepackage{float}

\usepackage{tikz}
\usepackage{environ}
\makeatletter
\newsavebox{\measure@tikzpicture}
\NewEnviron{scaletikzpicturetowidth}[1]{%
  \def\tikz@width{#1}%
  \def\tikzscale{1}\begin{lrbox}{\measure@tikzpicture}%
  \BODY
  \end{lrbox}%
  \pgfmathparse{#1/\wd\measure@tikzpicture}%
  \edef\tikzscale{\pgfmathresult}%
  \BODY
}
\makeatother

\usepackage{booktabs}

\usepackage[all]{nowidow}
\widowpenalty=1000

\addtolength{\footnotesep}{1mm}
\skip\footins=4ex plus 1ex
\usepackage{lipsum}
\usepackage[bottom,norule,hang]{footmisc}

\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{University Name}
\chead{}
\rhead{Course Name}
%\lfoot{Student Name}
\cfoot{\thepage}
%\rfoot{Student ID}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}

I know there are lots of packages. Maybe there some problems among them.

Best Answer

\R is not a predefined command, you need to define it yourself if you want to use it as a shortcut.

\newcommand{\R}{\mathbb{R}}

Thus:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}

\newcommand{\R}{\mathbb{R}}

\begin{document}

Let $X$ be a continuous random variable with CDF $F(x) = \log_{c}(x)$
where $x \in [1,c]$ and $c \in \R_{++}$.

\end{document}

enter image description here

Note \log for log.