# How to write Euclidean distance

How would one implement Euclidean distance in LaTeX. Please some one help me. Here is the below link:

http://en.wikipedia.org/wiki/Euclidean_distance

-
\documentclass{article}\begin{document}Euclidean Distance\end{document} ? What exactly do you want to implement? – percusse Sep 4 '12 at 0:55
do you mean $\mathbf{\overline{pq}}$? – Harish Kumar Sep 4 '12 at 0:56
Also if you click on Edit link on the right upper part on Wiki you can see the source code of the page. – percusse Sep 4 '12 at 0:56
Do you mean perhaps how to write the norm of a vector? – Gonzalo Medina Sep 4 '12 at 1:00
if you look at the source code of the wikipedia page (CTRL-U), you can see the latex code for the formulae – prettygully Sep 4 '12 at 1:39

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}


-

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.)

-

Building on @GonzaloMedina's answer, I suggest you create a command called \norm in the document's preamble

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


which will place double vertical bars around the command's argument. Note the use of the \left and \right commands, which will automatically "grow" the size of the double bars as may be necessary.

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.

-
The package commath provides the \norm command with an optional argument for its size. – jofel Jun 23 at 13:22