LuaLatex と TikZ

LuaLatex と TikZ

LuaLatex と TikZ で問題があります。次の MWE の何が問題なのか説明していただけますか。

\documentclass{amsart}

\usepackage{luacode} % read this somewhere, doesn't change anything.
\usepackage{tikz}

\begin{document}

\section{Some sections}
  Some random text.

  \directlua{ tex.print([=[
    \begin{tikzpicture}[thick]
      \draw (0,0) to (1,1);
    \end{tikzpicture}]=])
  }

\end{document}

同じ種類のLuaコードは外部スクリプトから使用する場合にも機能します。しかし、次のようにすると

! Undefined control sequence.
\GTS@RemoveLeft ...{}{}\GTS@Nil }\edef \GTS@Token

答え1

代替コーディングluacode:

\documentclass{article}
\usepackage{luacode}
\usepackage{tikz}

\begin{document}
\luaexec{
tp=tex.print
tp("\\begin{tikzpicture}[thick]")
tp("\\draw (0,0) to (1,1);")
tp("\\end{tikzpicture}")
}
\end{document}

関連情報