amunn / tikz-backgammon

Display backgammon games with TikZ
12 stars 2 forks source link

bk@setstate inserts whitespace #1

Closed eranlambooij closed 1 year ago

eranlambooij commented 2 years ago

I was playing around with the package and I came across the following issue. When you set points manually (for example through blackpoint and whitepoint) the left hand margin of the generated image grows. I was able to reduce the problem to the bk@setstate macro by trial and error, but since my pgf and tikz skills are bad I could (sadly) not fix it myself.

A MWE would be:

\documentclass{standalone}
\usepackage{tikz-backgammon}
\begin{document}
\double{neutral}{0}
\bk@setstate{0}{white}
...
\bk@setstate{0}{white}
\blackboard

Where if one is to increase the number of set states the margin on the left hand increases.

amunn commented 2 years ago

Hi thanks for the report. The code you've posted doesn't really allow me to reproduce the problem, however. You can't use \bk@setstate inside the main document, and I also don't actually understand the effect you're describing. Can you reproduce it with a complete compilable document using article class, and using only \blackpoint or \whitepoint commands?

For example the following document produces no shift that I can see, but maybe I'm misunderstanding something.

\documentclass[12pt]{article}
\usepackage{tikz-backgammon}
\begin{document}
\blankboard
\foreach\x in {1,...,24}{
\blackpoint{\x}{1}
}
\blackboard
\end{document}
eranlambooij commented 1 year ago

The given code it does not give. So I guess it is because of the standalone class. I get the same behaviour when I add it to a resizebox environment (inside an article class). Basically the following code misbehaves:

\documentclass[12pt]{article}                                                   
\usepackage{tikz-backgammon}                                                    
\begin{document}                                                                
\resizebox{\textwidth}{!}{                                                      
\double{neutral}{0}                                                             
\foreach\i in {1,...,24}{                                                      
\blackpoint{\i}{1}                                                             
}                                                                              
\blackboard                                                                     
}                                                                               
\end{document}    

To see the difference comment out the for loop.

amunn commented 1 year ago

@eranlambooij Thanks for this example. That is indeed an odd behaviour! Turned out to be quite easy to fix. I've updated the package. You still need to add a % after the opening brace of the loop, but the commands themselves no longer introduce spurious spaces.