I sometimes need to write that a certain prime p^k precisely divides a number n, meaning that p^k | m but it is not the case that p^{k+1} | m. It is often written as: p^k || m, where the symbol in the middle is supposed to look like a pair of vertical lines close to one another.

Is there a good way to write this in LaTeX? I am aware of the following possibilities, none of which is fully satisfactory:

  1. p^k \Vert n gives a nice pair of vertical lines, but the spacing looks wrong.
  2. p^k \mid\mid n gives the right spacing between numbers and the symbol, but the lines are very far apart.
  3. p^k \mid \!\!\: \mid n and p^k \ \Vert \ n look about right, but I hear that manually adding spacing is sometimes risky.

Are there any better possibilities?


You might use \parallel, which produces the same symbol as \Vert, but correctly spaced for a relation symbol.

Another possibility is


and $a\pdiv b$ would produce

enter image description here

If you choose \parallel, use a new command anyway, so you can easily change your mind later:

%\newcommand{\pdiv}{\parallel} % I'll use the next

There's nothing wrong in using explicit spaces, so long as you know what you're doing. Surely \: is not the right spacing command to use, because it introduces a flexible space. If you feel that \mid\!\mid is too tight, try


(requires amsmath); the command \! backs up by 3mu, while the natural space component of \: is 4mu, so \!\!\: has a natural width of –2mu. But \mspace{-2mu} has no flexibility.

Here is a comparison: first row \mid\!\mid; second row \mid\mspace{-2mu}\mid, third row \parallel

enter image description here

If I had to choose, I'd select the first one. But with a new command you're not bound to a decision until the last time.


Although it looks strange, you need \parallel:



$p^k\parallel n$

$p^k \mid \!\!\: \mid n$ and $p^k \ \Vert \ n$


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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