How to write Euclidean distance

I am not sure what exactly do you want to write; does the following help?

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator{\dis}{d}

\begin{document}

\[
\lVert \mathbf{p} \rVert = \dis(\mathbf{p},\mathbf{0}).
\]

\end{document}

enter image description here


Building on @GonzaloMedina's answer, I suggest you create a macro called \norm in the document's preamble, using either of the following two approaches:

  • auto-size the double-bar "fence" symbols:

    \newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
    

    This will place double vertical bars around the command's argument. Because of the use of the \left and \right modifiers, the double-bar fence symbols will "grow" automatically as may be necessary.

  • preserve the option to assign explicit sizes to the "fence" symbols:

    \usepackage{mathtools}
    \DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
    

    With this setup, \norm*{...} will produce automatically sized double-bar fence symbols around the macro's, whereas (say) \norm[\bigg]{...} will generate \bigg double-bar symbols. There are four sizing modifiers: \big, \Big, \bigg, and \Bigg.

If need be, you can indicate whether the norm is supposed to be an $L_2$, $L_1$, or $L_p$ norm by adding a suffix $_2$, $_1$, $_p$, etc to the expression. E.g., you could write \norm{x}_{2} and \norm{y}_p.


Here are some tips if you're looking for symbols:

  1. Use DeTeXify.
  2. Since you linked to Wikipedia, here is another suggestion:

    View the source of LaTeXified math1 for viewing the TeX equivalent.

  3. If you're strong, you may also search through this massive authentic database of extant symbols in the entire TeX universe.

1 In Internet Explorer, it roughly translates to right clicking on the image and clicking on "View Source". In Chrome, this translates to "Inspect Element" after the element. In chrome, it is much more pleasant too. In Firefox, go to the page you want to view and then press Ctrl+U. A new Window appears with the HTML code visible and colored appropriately.

(In Internet Explorer, you can press Alt+V to open the View menu, then press C to select the Source command. A Notepad window appears with the HTML code available for editing.)

Tags:

Math Mode