6

Working on my answer to Better way of designing memory layout in tikz I've found that the distribution of a number of consecutive \bullet (or \cdot) is different if the number is even or odd. Space between two last elements in an even list is shorter. Why? How could it be corrected?

\documentclass{article}
\usepackage{pgffor} 

\newcommand{\mydots}[1]{$\foreach\i in {1,...,#1}{\bullet}$}

\begin{document}
\foreach\i in {1,...,15}
{\noindent\mydots{\i}\\}
\end{document}

enter image description here

Ignasi
  • 136,588
  • 1
    It has to do with \bullet being a binary operator I think (\mathbin), but I don't know the rules for their spacing, so can't give details. – Torbjørn T. May 08 '18 at 10:05
  • @TorbjørnT. You're right, using \mathop{\bullet} solves the problem. Could you write an answer? – Ignasi May 08 '18 at 10:26
  • this is essentially a duplicat eof this one (but with cdot rather than star) https://tex.stackexchange.com/a/372329/1090 – David Carlisle May 08 '18 at 10:50

1 Answers1

5

try:

\documentclass{article}
\usepackage{pgffor}

\newcommand{\mydots}[1]{$\foreach\i in {1,...,#1}{\bullet}{}$}% <-- added {}

\begin{document}
\foreach\i in {1,...,15}
{\noindent\mydots{\i}\\}
\end{document}

enter image description here

edit:

  • as explained in Torbjørn T. comment, \bullet is binary opreator
  • it can also be solved by using \mathop{\bullet} as say Ignasy
  • or for `\mydots use beside my first proposition also with:

    \newcommand{\mydots}[1]{\foreach\i in {1,...,#1}{\textbullet\ }}

Zarko
  • 296,517