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

3
  • 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. Commented May 8, 2018 at 10:05
  • @TorbjørnT. You're right, using \mathop{\bullet} solves the problem. Could you write an answer?
    – Ignasi
    Commented May 8, 2018 at 10:26
  • this is essentially a duplicat eof this one (but with cdot rather than star) tex.stackexchange.com/a/372329/1090 Commented May 8, 2018 at 10:50

1 Answer 1

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\ }}

2
  • 1
    Could you explain what does {} at the end of the list? And why it's not necessary into an odd list?
    – Ignasi
    Commented May 8, 2018 at 10:06
  • @Ignasi see Davids comment
    – daleif
    Commented May 8, 2018 at 11:12

Not the answer you're looking for? Browse other questions tagged .