Posts tagged ‘LuaLaTeX’

Python und LaTeX in einem Lauf kombinieren mit pylualatex

Mi dem pylualatex Paket gibt es eine neue Möglichkeit, Python und LaTeX miteinander zu „verheiraten“. Das Besondere an diesem Paket ist, dass es keine zwei Durchläufe benötigt, sondern nur einen einzigen.

%!TEX TS-program = Arara
% arara: lualatex: {shell: yes}
 
\documentclass{article}
 
\usepackage[executable=python.exe,localimports=false]{pyluatex} 
 
\begin{document}
 
\py{2**2**2}
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Silbentrennung und Kerning anzeigen mit showhyphenation und showkerning

Für LuaLaTeX gibt es mit showhyphenation und showkerning zwei interessante Pakete, die die möglichen Trennstellen bzw. das Kerning anzeigen.

%!TEX TS-program = lualatex
\documentclass[12pt,ngerman]{scrartcl}
 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{microtype}
 
\usepackage{showhyphenation}
\usepackage[ontop]{showkerning}
\begin{document}
 
\blindtext
 
\blindtext
 
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Generating math exercises for kids with LuaLaTeX

Arno T. has sent me a nice piece of LuaLaTeX code that does more or less the same thing as my Python code. I guess, I should have a closer look at LuaLaTeX.

\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage{luacode}
\usepackage{longtable}
 
\begin{document}
\begin{longtable}{rcrcl}
\toprule
\luaexec{
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
random = math.random
tp = tex.print
%
min = 1
max = 10
math.randomseed(os.time())
for i = 1,20 do
a = random(min,max)
b = random(min,max)
op = random(1,4)
if (op==1) then
c = a+b
tp(a.."&+&"..b.."&=&"..c.."\\\\")
elseif (op==2) then
c = a-b
tp(a.."&-&"..b.."&=&"..c.."\\\\")
elseif (op==3) then
c = a*b
tp(a.."&*&"..b.."&=&"..c.."\\\\")
elseif (op==4) then
c = a/b
tp(a.."&/&"..b.."&=&"..round(c,3).."\\\\")
end
end
tex.print("\\bottomrule")
}
\end{longtable}
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website