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 Functions at Mapping →

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 poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers