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

Is there a way to get a dotted line with prescribed density, for instance 10 dots per centimeter, instead of the default?

With Jesse's comment :


\tikzstyle{cm dotted}=[dash pattern=on \pgflinewidth off .85mm ]


\draw[cm dotted,line width=.15mm,step=.5] (0,0) grid (5,4) ;


Still an unwanted shift of half a linewidth. The horizontal and vertical crossing points are not on at the right place. I understand why, but I don't know how fix it.

share|improve this question
Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. A suggestion: Do us a favour and change your username to something more telling than "user45209" (any nickname is good). – egreg Feb 1 '14 at 11:46
This could provide some directions -- tex.stackexchange.com/a/45276/34618 – Jesse Feb 1 '14 at 12:32
@Jesse, it goes in the good direction. It works but still a unwanted shift of half a linewith. – Tarass Feb 1 '14 at 13:14
You could update your question and give a more specific concerns, experts here are ready to help out. – Jesse Feb 1 '14 at 13:33
I did it and I put a try in the direction you've give. – Tarass Feb 1 '14 at 13:51
up vote 12 down vote accepted

I think this does it. The size of the dot is determined by the line width. The trick is to use a dash of length 0. Which I suppose shouldn't work, but seems to.


  dots/.style args={#1per #2}{%
    line cap=round,
    dash pattern=on 0 off #2/#1


\foreach \i in {1,...,20}{
    \draw [help lines] grid (4,1);
    \draw [very thick, dots=\i per 1cm] 
      (0,.5) -- (4,.5) 
      node [at start, above right] {\i\ dot\ifnum\i>1s\fi\ per 1cm};


enter image description here

share|improve this answer
It works just fine, the grid is perfect. – Tarass Feb 1 '14 at 14:20

With dotsep in PSTricks.


enter image description here



    \foreach \i in {2,...,10}{%
        \rput[t](3,1.75){\i\ dots per cm}   

enter image description here

share|improve this answer
With pstricks I usualy use psgrid and it works find. I know how to do this with metapost. But now I need a tikz command (without foreach), but a style to apply on a line or on a grid. – Tarass Feb 1 '14 at 12:50
@Tarass: OK. The multido in my answer is trivial. – kiss my armpit Feb 1 '14 at 12:53
My question was not clear enought. – Tarass Feb 1 '14 at 13:46
Look carefully the difference with Mark Wibrow tikz solution: the first and the last points are not on the grid, it means that it isn't precise enought especialy to make a grid. Exactly the grid pstrciks does and you use for your example. With you solution, the vertical and horizontal lines don't match at crossing points. – Tarass Feb 2 '14 at 8:03

The “old” plain TeX actually does this out of the box in one line, without the need of external complex packages:

my text\leaders\hbox to 1em{\hss.\hss}\hfill other text

Other options are:

  • use \hskip 5cm instead of \hfill to produce a dotted line 5cm long
  • use \hbox to 0.1cm instead of hbox to 1em to change the dot separation to 1mm
  • use \cleaders instead of \leaders to center the leaders, instead of having them alined
  • use \xleaders to have the leaders expanded to fill out the entire space (in this case the separation provided is a lower limit only).
share|improve this answer
I need a tikz style like dotted densely, but with a way to prescribe the number of points in a cm. – Tarass Feb 1 '14 at 12:47

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.