TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
\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
up vote 11 down vote accepted

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




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


enter image description here

share|improve this answer

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

share|improve this answer

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.