# \placeongrid and \moveongrid not working in ConTeXt

I am trying to use the grid features in ConTeXt, but some of the commands are somehow not recognized by the compiler.

Whenever I try to use the commands \placeongrid or \moveongrid, the compiler exits with an error message such as:

l.27 \moveongrid [both] ? >Exit code: -1073741510


the grid=yes option for the \setuplayout works well, but this is not what I intend to use.

I have both the TeXLive 2012 package and the ConTeXt Standalone (ver. 2012.10.17), and both distributions produce the same error message.

One concern is that when I try to update my ConTeXt standalone files, I get a message saying

The program can't start because kpathsea611.dll is missing from your computer. Try reinstalling the program to fix this problem.


I wonder if this has any relevance to the issue. Btw, I am on a Win7-x64 system.

-
Welcome to TeX.sx! –  Kurt Oct 18 '12 at 7:33
1. have you read the grid related instructions in the reference? 2. \moveongrid is mkii only, if you think you need it you will have to run your file through texexec. 3. kpathsea is linked into LuaTeX. It is, however, unnecessary and even disabled in Context (mkiv) so afaict the warning shouldn’t hurt. –  phg Oct 18 '12 at 7:56
1. yes I am relying on this reference 2. this explains why I am having problems since I have been using context instead of texexec. Using texexec solved the problem. thank you! 3. actually, the kpathsea problem is quite annoying since it makes the texexec unavailable for the standalone package. The distribution that comes with the TeX Live package has no problems with kpathsea so this can be my solution. 4. I found an adhoc solution in case I want to use context. Repeated usage of \startlinecorrection and \stoplinecorrection until I get desired results seems to work a bit. –  user21044 Oct 18 '12 at 8:20
For some reason it is not mentioned in the manual that you do in fact need \setuplayout[grid=yes] (or strict or verystrict) to activate snapping in the first place. What do you mean when you say you do not intend to use it? Btw. here is some additional documentation in the details doc and on the wiki in case you missed it. –  phg Oct 18 '12 at 8:27
In fact, I have just been testing and noticed that without the [grid =yes] the commands don't make a difference. Guess I kinda misunderstood the mechanism. I thought that the snapping commands would effectively bring in a grid locally. Now, my options seem to be narrowed down to either using the global grid setting or just living with \startlinecorrection on a non-grid. Probably the grid is the way to go. Anyway, thanks for all your help! –  user21044 Oct 18 '12 at 9:47

The command \moveongrid is specific to MkII and has been removed in MkIV. It used to be a fairly low-level command that others like \placeongrid built onto. Since most of the grid functionality has been reimplemented in Lua as part of a gigantic callback, \moveongrid lacks an equivalent on the TeX end. However, there is the comparably low-level counterpart \snaptogrid that user macros like for instance the \startlinecorrection environment rely on.

\snaptogrid receives an \hbox or \vbox as mandatory argument (custom boxes created by \newbox won’t cut it). An optional first argument determines the snapping method. If it is missing, it defaults to the globally active one. A short example demonstrating three of the available methods:

\useMPlibrary [dum]
\setuppapersize [A6]
\showgrid
\setuplayout [grid=yes] %% set the global snap method

\def \makedummy {
%% create a dummy figure with a vsize that is not a multiple of the
\externalfigure [dummy] [height=\dimexpr4.25\lineheight]%
}

\starttext
\input ward \par

method: default
\snaptogrid\vbox{\makedummy} \par
\input ward \par

method: top
\snaptogrid [top] \vbox{\makedummy} \par
\input ward \par

method: line
\snaptogrid [line] \vbox{\makedummy} \par
\input ward \par
\stoptext


The default method is yes (aliases: normal and standard). For an exhaustive list of available methods see the source code.

-