Function Definition in LaTeX (f: A \to B)

f:A→Bf: A \to B
LaTeX command
f: A \to B
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Declares f as a function from the domain A to the codomain B.

This signature line opens most definitions in analysis and algebra, often followed by the element rule x \mapsto x^2. Typing a bare colon gives relation spacing on both sides, which looks too wide; \colon gives proper tight punctuation spacing, f\colon A \to B. \to and \rightarrow produce the same arrow; \longrightarrow adds emphasis in displays. Pair it with \mapsto for the element-level rule: f\colon \mathbb{R} \to \mathbb{R}, x \mapsto x^2. Diagrams with several maps between several objects are better drawn with a dedicated commutative-diagram environment.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

f ⁣:R→R,x↦x2f\colon \mathbb{R} \to \mathbb{R}, \quad x \mapsto x^2
\documentclass{article}
\usepackage{amssymb}
\begin{document}
Function Definition: $f: A \to B$

\[ f\colon \mathbb{R} \to \mathbb{R}, \quad x \mapsto x^2 \]
\end{document}

Related symbols

All الدوال والتعيين →

Frequently asked questions

How do I write Function Definition in LaTeX?
Type f: A \to B in math mode, for example $f\colon \mathbb{R} \to \mathbb{R}, \quad x \mapsto x^2$. It works in plain LaTeX without loading any package.
Which package do I need for f: A \to B?
None. f: A \to B is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use f: A \to B in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $f: A \to B$ in running text.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث