1

I am learning how to write a package by looking at code from existing packages. A nice one on GitHub (https://github.com/amunn/tikz-backgammon/blob/master/tikz-backgammon.sty) uses a lot of \newcommand definitions which contain the @ character (e.g. \bk@BW , \bk@doublestate etc.). Is this just a style of writing \newcommand or does the @ character have special significance?

Ted Black
  • 453
  • 2
  • 8
  • 3
    Commands normally can't contains @ --- they do in package and style files so that you can have a kind-of private namespace and avoid clashes. – Rmano Mar 27 '21 at 08:21
  • The @ is a character that can normally not appear in macro names. It is allowed in macro names in .sty files and if it is 'turned on' with \makeatletter ... \makeatother. This means that it is often used in 'internal' macros that package users should normally not have to interact with. Using unique prefixes (like bk) together with @ can avoid name clashes. You can read more at https://tex.stackexchange.com/q/8351/35864. – moewe Mar 27 '21 at 08:24
  • It's only a sort of "protection" by using special characters with a catcode switch. As long as the character has letter catcode in its current usage, you could use whatever you want. LaTeX traditionally uses @, expl3 uses _ and :; ConTeXt uses _, ! and ? among others as reserved characters... –  Mar 27 '21 at 08:25
  • Great replies. It's all clear now, thanks guys. – Ted Black Mar 27 '21 at 08:35

0 Answers0