I am getting some strange behaviour using luaLaTeX and a rather simple command definition. I am using TeXLive 2012, Linux x86_64.
When \settowidth is used in the preamble to compute the width of some characters in the following example, the width is terribly underestimated, and when that width is used to negatively indent some text, it does not line up.
If the \settowidth operating is moved inside the document environment, the calculation is just fine.
Here is a minimum working example:
\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{fontspec}
\newdimen\arrowwidth
\settowidth{\arrowwidth}{$\rightarrow$\ }
\newcommand{\note}[1]{\noindent\hskip-\arrowwidth{$\rightarrow$\ }{#1}}
\begin{document}
\lipsum[1]
%\settowidth{\arrowwidth}{$\rightarrow$\ }
\note{HELLO WORLD!}
\lipsum[2-2]
\end{document}
If you uncomment the line above the \note{HELLO WORLD}, everything works as expected.
Changing the 12pt option also changes the issue somewhat drastically.
The → character isn't the problem. You can substitute roman text for the right arrow and it will still give problems.
Does anyone have any idea what causes this? Can anyone else reproduce it?
\settowidthin the preamble set issue the command\rmfamily. This forces your font choices to take effect at that point rather than being delayed to the \begin{document} command. – Andrew Swann Nov 1 '12 at 15:50