%! Main part of luatexja-otf
\RequireLuaModule{luatexja.otf}
-\protected\def\CID#1{\char\directlua{luatexja.otf.cid(#1)}\relax}
+\newcount\ltj@tempcnta
+
+\protected\def\CID#1{\ifvmode\leavevmode\fi\ltj@tempcnta#1\relax\directlua{luatexja.otf.cid(\the\ltj@tempcnta)}\relax}
+
+%% \UTF compatible with the OTF package for pLaTeX
+\protected\def\UTF#1{\ifvmode\leavevmode\fi\directlua{luatexja.otf.append_jglyph(0x#1)}}
+
+%% Load ajmacros
+\ifltj@in@latex %<*LaTeX>
+ \RequirePackage{luatexja-ajmacros}[2011/09/19]
+\else %<*!LaTeX>
+ \input luatexja-ajmacros.sty %
+\fi %</LaTeX>
-%% \UTF being compatible with the OTF package for pLaTeX
-\protected\def\UTF#1{\char"#1\relax}
%%------------------ all done
\ltj@otf@AtEnd