## Archive for the ‘LaTeΧ’ Category

### Switched to LuaLaTeX

Monday, November 28th, 2011

Hi!

Have you ever tried to write a little bit complex command in LaTeX? I did at some occasions, and finally it somehow worked, but it has always been ugly. However, there is LuaTeX/LuaLaTeX, it provides real scripting within your documents:

\directlua{
for i=0, 15 do
tex.print("Math: $x_{" .. i .. "}$")
end
}

That is just awesome, in plain LaTeX this would be ugly, but it gets even more ugly if you have to deal with floating points, external files etc. Well, for now I do not need any complex macro, so I cannot talk about actual experiences with Lua stuff, but I encountered some problems when translating my LaTeX document to LuaLaTeX two weeks ago.

### unicode-math does not work properly

When enabling the unicode-math package for using Unicode characters in formulas (⊂∀∃∂ etc.) I have to select a font using the \setmathfont command, I tried “Latin Modern Math”, “STIXGeneral”, “XITS Math”, “Neo Euler” and “Asana Math”, otherwise Unicode symbols will not get displayed. However, with all of these fonts formulas do not look as good as with standard LaTeX lmodern-package, which is usable from LuaLaTeX, too, \setmathfont will override it. Some of them are too bold, some have ugly ℝ, ℚ, ℂ (\mathbb) and \mathcal symbols etc. Thus I decided to port the uniinput package provided by the Neo project (they create the keyboard layout I am using) to LuaLaTeX. I thought it would be nice to check the Lua capabilities that for, however, I faced the next problem.

### Lua is not Unicode aware

That is really annoying, LuaLaTeX’s claim is to support a) sophisticated scripting and b) native Unicode support. However, they choosed Lua as scripting language, which does not support Unicode natively. I could not find the functions I needed to write a succinct macro for declaring a Unicode character in math mode (for examble ℝ should be replaced with \mathbb{R}), simply something to split a 8-bit-UTF-8-string into its Unicode characters and to do conversions between character codes and strings. I did not want to write it myself. Thus I choosed a quick and dirty way: using some regexp-magic and a Ruby script to convert uniinput.sty into uniinput-lualatex.sty. It works now, you can use it if you want to…

### Making it working with KileIP

KileIP currently has the latex-command hard coded to display previews of formulas. I was too lazy to fix that and I wanted to be able to fall back to LaTeX if there were unexpected problems, thus I made my document working with both LaTeX and LuaLaTeX:

\usepackage{iftex}
\ifPDFTeX
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{uniinput}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amssymb}
\else
\ifLuaTeX
\usepackage{luatextra}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{lmodern}
\usepackage{uniinput-lualatex}
\usepackage{fontspec}
\fi
\fi

Well, next time I need a complex macro I will certainly use Lua and it will hopefully work with my setup.

### Kile Inline Preview

Friday, March 4th, 2011

Hi!

I just want to inform you about a really nice Kile-Feature-Fork: Kile Inline Preview.
When you install this patched version of Kile you will get embedded preview-images for your formulas. That is really nice, because you want to have WYSIWYM, and a rendered formula looks more like what you mean than LaTeΧ-formula-code, while “normal” text-mode commands are more expressive than the rendered version. When you move the cursor into the preview-image, it will disappear and you can edit the formula or view the code. I think it is really nice, it even works properly. Maybe it could be merged one day into git, because it is not so nice to have to wait for the developer (nice guy ;)) updating the Kile-version used by the repository (I think he is still using a SVN-version). I love this feature! In my opinion that makes Kile better than LyΧ or TeΧMacs. Try it yourself!

The User

PS:
Too lazy and tired, to create a screenshot, maybe tomorrow.

PPS:
Here it is! The cursor is currently at line 21.