%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% filename:	tikzschnitt.tex
%% author:	Hermann Lorenz
%% date:	24. Mär 2014 06:52
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{minimal}

\usepackage{luacode}

\newcommand{\haha}{HeLLas}
\newcommand{\hoho}{World}

\begin{document}

%--------------------------------------------------------------------
\textbf{Textersetzung}
%--------------------------------------------------------------------

\begin{luacode}
  local text = '\haha'
  local ersetzt, n = text:gsub('a', 'o')
  tex.sprint(ersetzt)

  tex.sprint(' ')

  local text = '\string\\haha'
  local ersetzt, n = text:gsub('a', 'o')
  tex.sprint(ersetzt)
\end{luacode}


\vspace{\baselineskip}
%--------------------------------------------------------------------
\textbf{\textbackslash renewcommand in luacode}
%--------------------------------------------------------------------

\renewcommand{\haha}{HeLLos}

\begin{luacode}
  tex.print('\string\\renewcommand{\string\\haha}{World}')
  tex.sprint('\haha')
\end{luacode}
--
\begin{luacode}
  tex.sprint('\haha')
\end{luacode}
--
\haha

\vspace{\baselineskip}
%--------------------------------------------------------------------
\textbf{\textbackslash renewcommand in directlua}
%--------------------------------------------------------------------

\directlua{
  tex.print('\string\\renewcommand{\string\\haha}{World}')
  tex.sprint('\haha')
}
--
\directlua{
  tex.sprint('\haha')
}
--
\haha

\end{document}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% TeX-PDF-mode: t
%%% TeX-engine: luatex
%%% End: 
