Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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

Another possibility is

\newcommand{\pdiv}{\mid\!\mid}

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
\newcommand{\pdiv}{\mid\!\mid}

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

\mid\mspace{-2mu}\mid

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

share|improve this answer

Although it looks strange, you need \parallel:

\documentclass{article}

\begin{document}

$p^k\parallel n$

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

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

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.