4

In presentations with the beamerpackage I use \put a lot to place graphic objects like this:

\newcommand{\putat}[3]{\begin{picture}(0,0)(0,0)\put(#1,#2){#3}\end{picture}} % just a shorthand
\putat{123}{45}{stuff}

Now I was thinking about writing a small macro to facilitate finding the x and y coordinate by just writing a grid of positions onto the slide from which I can read off which values to use as arguments to put:

\newcounter{xpos}
\newcounter{ypos}
\forLoop[20]{20}{200}{xpos}{%
  \forLoop[10]{20}{100}{ypos}{%
    \putat{\value{xpos}}{\value{ypos}}{(\arabic{xpos},\arabic{ypos})}
 }
}

(This uses the forloop package.)

The problem is that I forgot that put uses relative positions (apparently). Can I somehow return to the same origin in every pass of the loop?

Or is there a simpler way to generate this grid?

1 Answers1

7

Hi the most simple way seems to be using beamer itself:

   \setbeamertemplate{background}[grid][step=10]

Of course you could use full power tikz:

\documentclass{beamer}
\usepackage{tikz}
\setbeamertemplate{background}{\tikz{
    \foreach \x in {-5,...,5} \draw (\x ,-5) -- (\x ,5) node[anchor=north] {$\x$};
    \foreach \y in {-5,...,5} \draw (-5,\y) -- (5,\y) node[anchor=east] {$\y$};}}
\begin{document}
\frame{hi world}

\end{document}

I´m aware that this solution is not a bare latex one. Nevertheless i believe this is the most comfortable way.

bloodworks
  • 10,178
  • Cannot use tikz. We only have a way outdated version here, because we are stuck with CentOS :( Your first suggestion seems to work though (if I replace 10 by 10pt). – fuenfundachtzig Mar 04 '11 at 13:38
  • @fuenfundachtzig: You can use/update LaTeX package independent from the binaries. You don't need to use the version provided by our OS. Simply make your own texmf tree. – Martin Scharrer Mar 04 '11 at 13:53
  • Well step normally expects a lenght however an up to date tikz/beamer obviously accepts a dimension free figure too. I guess, that it is replaced with an default dimension. – bloodworks Mar 04 '11 at 13:57
  • Number without an unit will be taken as multiple to the specific unity vector, which can be something very simple like an unit or something more complex like a 3-D vector. But do not mix numbers with and without units in the same expression because then pt are assumed! – Martin Scharrer Mar 04 '11 at 14:04