13.11.2015 Views

my Latex and Tex4ht cheat sheet

my Latex cheat sheet - 12000.org

my Latex cheat sheet - 12000.org

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.43 Some lualatex examples using Lua inside <strong>Latex</strong><br />

2.43.1 Making counter<br />

% !TEX TS-program = lualatex<br />

\documentclass{article}<br />

\usepackage{luacode}<br />

\usepackage{amsmath}<br />

%------------------------<br />

\begin{luacode}<br />

local x = 0<br />

function add()<br />

x = x +1<br />

tex.print(x)<br />

end<br />

function sub()<br />

x = x - 1<br />

tex.print(x)<br />

end<br />

function reset()<br />

x = 0<br />

end<br />

\end{luacode}<br />

\newcomm<strong>and</strong>\add[0]{ \directlua{add()}}%<br />

\newcomm<strong>and</strong>\sub[0]{ \directlua{sub()}}%<br />

\newcomm<strong>and</strong>\reset[0]{ \directlua{reset()}}%<br />

%-------------------<br />

\begin{document}<br />

\reset<br />

\add<br />

\add<br />

\sub<br />

\add<br />

\end{document}<br />

2.43.2 simplify fraction<br />

see http://tex.stackexchange.com/questions/253693/reducing-fraction-using-latex-3/253716#253716<br />

41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!