Facets of current online LaTeXing

May 11, 2010 by Daniel Stender · 3 comments · Printer friendly version
Filed under: TeX 

Some projects and techniques of online TeXing which I came across these days:

LaTeX Lab

Latex-lab.org (hosted at Google Code) is an online LaTeX editor and processor which uses GoogleDocs as a platform. If you have an account for that you can create and manage your LaTeX documents online in the browser and also generate your PDFs (PSs, DVIs) here quite comfortable with line numbering, spell checking and syntax highlighting (although basic editing features like search-and-replace are missing so far). GoogleDocs is popular for real-time collaborative editing (RTCE) and so there is really a whole new perspective for LaTeXing here. The default LaTeX Lab compiler employs even Koma Script for example and also diacritics are possible as always with ucs.sty. It’s also possible to poll other installations through the CLSI (Common LaTeX Service Interface) and it is to watch if this port establishes as a standard. LaTeX Lab has an option for split screen preview, to have some kind of an on-the-fly processing here is certainly an obvious perspective for this relatively new project (currently on “preview release”). The whole thing is perfect for beginners because nothing has to be installed and as a sandbox, but generally LaTeX Lab seems to go even far beyond that. Click this screenshot here to realize immediately what is going on there. A fresh project and useful as it is even if there is much room for further development.

By the way: as has been posted on the (my new favourite) blog Random Determinism in February, the as always highly versatile ConTeXt is able to retrieve its TeX source code directly from GoogleDocs: see here (on ConTeXt see this previous posting here).

LaTeX and WordPress

It seems that LaTeXing at WordPress (WP) is actually a big issue. For it makes no sense to provide all the subtleties of LaTeX also for WP it looks as the main goal of the efforts is to make available foremost the exquisite mathematical typesetting of LaTeX – it’s is quite popular in the natural sciences even for that. Plugins like Youngwhan’s Simple LaTeX for example provides the processing of LaTeX math formulae code within WP postings in working together with the a CGI (Common gateway interface) script for the generation which could run on your own server if a TeX installation is available here, but it’s also available in several instances somewhere on the net. There are some server-side scripts available like mimeTeX and the successor mathTeX for providing an online port for TeX installations.

Other solutions do not need even a plugin to run on WP: a somewhat different approach is it to poll one of the web based equation compilers which are generating images from LaTeX source on-the-fly simply through image hotlinks in the postings, although they are a little bit more complicated to handle. See on the Cameron.bracken.bz blog this posting here for several examples. LaTeXRender offers LaTeX source generation for a whole range of PHP applications like WP, Drupal, Simple Machines etc., but here a LaTeX installation and ImageMagick is required to be installed. That’s true also for some of the other available LaTeX plugins for WP, see here.

There is also a whole interesting blog dedicated to the issue of Using LaTeX in WordPress.

Online LaTeX

The web frontend Texify provides on-the-fly image based LaTeX code generation also simply through it’s URL, try: http://texify.com/?$\textit{test:} x^2+y^2$. MathURL follows a similar approach but additionally has the advantage of short coding the URLs like TinyURL does. That’s an elegant way to post equations in emails or wherever mathematics would need to post them resp. links to them.

In contrast, it seems that full online compiling of complete LaTeX documents is still in its infancy even if I am not yet investigated the matter any closer so far. It would be ideal if the maintainers of the standard distributions like TeX Live would run web based generators on their sites through CGI scripts, and it seems that something like this soon could be really available. Definitely online LaTeXing is a thing to watch.

Experiences in ConTeXt

February 21, 2010 by Daniel Stender · 1 comment · Printer friendly version
Filed under: TeX 

For a couple of days I am now playing around with ConTeXt and I have to say it’s really great. ConText (developer’s homepage) is, like LaTeX, a macro package for the extension of Donald Knuth’s original (Plain)TeX and so could be seen somewhat as an alternative to LaTeX. It makes use of the Pdf producing engine Pdftex (this team is designated as “ConTeXt Mark II”), but is also able to employ the enhanced, up-to-date Unicode capable engines XeTeX and LuaTeX. Seen from this point ConTeXt is an application belonging to the category “Pdf software”. ConTeXt is to my experience lean, effective and always just on the point. The LuaTeX format files for LaTeX have become available lately (see here), but if you really want to roll LuaTeX incl. working hyphenation etc. it’s better to work with ConTeXt – as a matter of fact it was developed very closely to LuaTeX (this couple is designated as “Mark IV”). With the LuaTeX engine it’s possible to set up customs implementations through Lua code which makes ConTeXt ultra versatile (see here).

Mk IV is available through TeX Live, but there is also a lean distribution, ConTeXt Minimals.  Except for a few third party modules (see here) everything is integrated which has its advantages. A challenge for switchers is the fact that ConTeXt seems to be even more arcane than LaTeX. But there is some info especially for LaTeX leavers (see here, here, and here), the ConTeXt guys are running a wiki named ConTeXt garden which helps to establish you, and there is the seems to be newbie friendly mailing list here. The are many excursions, references and manuals by the programmers to be found on the net. A useful resource is the the page context-xml.

On the first run of MkIV on Tex Live 2009 you have to integrate the font directories first (on Linux: export OSFONTDIR=”/usr/share/fonts/;/usr/local/share/fonts” or similar) and to rebuild the LuaTeX cache with: luatools –generate. Now you can process a basic document test.tex like: \starttext Hello world! \stoptext with context test.tex into a Pdf document. Welcome to ConTeXt!

Next there has to be a shopping list of basic features:

  • For enabling Unicode input encoding you have to give a \enableregime[utf], the right language/hyphenation option is switched with \mainlanguage[de] resp. [en] (see options here)
  • The employment of custom fonts has made been easy through the module Simplefonts, a simple \usemodule[simplefont][size=10pt] or similar together with \setmainfont[xyz] switches it (elements like footnotes are not changed through that, is it that this could be improved or there is a deeper reason for that, but furthermore there has to be a \definesimplefonttypeface[myfont][xyz] and then \setupfootnotes[bodyfont=myfont] – for the page number there has to be given \setuppagenumbering[bodyfont=myfont])
  • The whitespace between paragraphases could be manipulated with \setupwhitespace[1.5ex] or something like this (an “ex” is the “high of an x”)
  • The interline space could be manipulated simply through \setupinterlinespace[line=1.5\bodyfontsize] or similar
  • The Pdf metadata could be passed through with \setupinteraction[state=start, title={My document}, author={me}], a clickable table of contents in blue there you’ll get with \setupcombinedlist[content][interaction=all, color=blue]

That’s great but what’s in here for the philologists? What first caught my attention is the fact that at MkIV there weren’t any problems with multiple combined diacritical marks (Unicode 0300-036F) of the IndUni-H by John Smith (Vedic stuff like r-underdot-macron-acute/grave). I don’t know who made a mistake, but there are still some problems with XeTeX and that font (which is the only free full fledged Helvetica available). Being reliable with minority stuff like this leaves a very confident impression.

Another very interesting development is that of CritTeXt which is planned to be a luxurious functionality for the production of textual editions with ConTeXt. Idris Hamid at the Colorado State University and the Oriental TeX project are the driving force behind CritTeXt. What has been presented at the TUG 2007 talk and that outline of text critical typesetting features (here) looks very promising. Unfortunately that’s all what is on the net towards this and till now I haven’t found out if the project got far enough in the meanwhile to be able to plan with that or even switch over for that. But I’ve been told that everything is going to be implemented into ConTeXt – eat this, Word! Next to the still available TeX critical edition solutions, Ledmac and Ednotes for LaTeX and the Stammvater Edmac for PlainTeX (no, not running with ConTeXt), this could be another chance for getting what I know is the wet dream of many of my peers: parallel typesetting in a critical edition environment. I’ll report further discoveries.

TeX Live 2009: LuaLaTeX rolls on Debian (and the others)

January 23, 2010 by Daniel Stender · 2 comments · Printer friendly version
Filed under: TeX 

Previous posting on this issue here.

1. TeX Live 2009 at Debian unstable

Since my Debian Unstable/”Sid” jumped over to TeX Live 2009 a couple of days before (after being backward with 2007 as standard TeX distribution for a long time they skipped 2008 which is really pleasing, see also here) it’s now possible to run LuaLateX without a manual install – the relevant LaTeX format files have been included in Tex Live 2009 and the lualatex executable is now available on the console (LuaTeX version 0.50). The relevant macro packages (see http://tug.ctan.org/tex-archive/macros/luatex/, github collection) are made available most convenient through the new packet texlive-luatex (2009-7). Pretty soon the whole smack is going to be available also at mostly unstable branch Debian derivates like Ubuntu. TeX Live also runs on  other operating systems.

2. Hello world!

So now a rudimentary LuaLateX document like:

\documentclass{article}
\usepackage[utf8]{luainputenc}

\begin{document}
Hello world!
\end{document}

… runs. By the way, luainputenc (doc) calls luatextra (doc) which is also included in the texlive-luatex bundle.

3. Running Lua code from within the document

But Luatex is not only an alternative project which you could use to replace the other up-to-date Unicode capable/pdf creating LaTeX engine XeTeX (BTW see an introduction to XeTeX in German here), the advantage of LuaTeX is that the scripting language Lua is implemented into the engine which converts it to a kind of “eierlegende Wollmilchsau” one could say in German (for a collection of advantages of that approach see here). On the professional level that means that the rebuild engine could have been made much more faster in processing and versatile than everything which has been possible before (see Kastrup’s presentation at BachoTeX 2008) – on the user level it just means that it is possible to run Lua code while processing the document.  Lua code can be called from the macro package but also from within the document (a for somewhat comparable TeX project is Perltex). Let’s give it a try:

\documentclass{article}
\usepackage[utf8]{luainputenc}

\begin{document}
So it's time to say:
\begin{luacode}
tex.print("Hello world!")
\end{luacode}
\end{document}

Results in:

But more significant:

\documentclass{article}
\usepackage[utf8]{luainputenc}

\begin{document}
A random number:
\begin{luacode}
tex.print(math.random())
\end{luacode}
\end{document}

Results in:

4. Font selection

The one about font selection would be the next question. The availables packets are not quite mature but LuaTeX is under heavy development. The packet luaotfload (doc) is made for the purpose of font switching, the packet loads automatically with luainputenc resp. luatextra. The usage is the same as with the True/Opentype fontloader which is provided for the Plain/ConTeXt sister (see here). The basic usage would be something like:

\documentclass{article}
\usepackage[utf8]{luainputenc}
\font\myfont="FreeSans.ttf"

\begin{document}
\myfont Mahābhārata
\end{document}

The font file has to be in the working directory. An alternative is going to be the LuaTeX implementation of Fontspec, which is known from XeTeX (see here) and which employs a font file lookup. An experimental 2.0 version (.dtx and makefile) is provided by Khaled Hosny at his Github account. But I couldn’t get it to run so far.

The LaTeX Notebook 1-3 (repost)

July 16, 2009 by Daniel Stender · 3 comments · Printer friendly version
Filed under: TeX 

Document classes

The KOMA script (3.0) document classes and packets developed by Markus Kohm and Jens-Uwe Morawski are replacements for the standard LaTeX classes and are widely used and very rich in features. A basic attribute is that in difference to the standard classes of LaTeX they implement typical European typestting defaults like the principle of the Golden Section (Der goldene Schnitt) following the highly influential 20th century typographer legend Jan Tschichold. The developers run a special page for documentation, the documentation is here, and a short reference is to be found here. Read the Practex 3 (2006) article Replacing LaTeX2e standard classes with KOMA-Scipt.

Confproc (0.4f) is a document class for conference proceedings created for the DAFx-06 (9th International Conference on Digital Audio Effects Montréal). A packet like this demonstrates the power of a macro based typesetting system like LaTeX. It features an own BibTeX style and is mend to produce Pdf, so it makes full integrated use of the Hyperref packet. The documentation is here, there is a Report on the making of the DAFX-06 proceedings and finally here are the proceedings. A broad use of tools like this might help speeding up the publishing of conference proceedings in the future. Cf. Vefaille’s A new package for conference proceedings [Confproc] {PracTeX Journal 2007,4}.

Wordlike (1.2b) simply manipulates the standard LaTeX layout in a way that the output looks like made with Word. For whatever reason (being spoiled or the fact that in certain situations something else would be considered as behind), with Wordlike you are able to look like Word but you can use everything else which comes with LateX. Product of the year! The documentation (here) selfevidently is written in Wordlike.

Papertex (1.2a) is a highly customizable class for creating little newspapers, newsletters etc. The developers say that “it is possible to change the aspect of (almost) everything”. There are special environments for news, shortnews etc. Very interesting. Package documentation, example newspaper page here. It seems that the Vidūaka was also made with Papertex. Cf. Tortosa/Bleda’s PaperTeX: Creating newspapers using LaTeX 2e {Tugboat 28 (2007), 20-23}.

Exam (2.3) is a class for easy typesetting of exam scripts (Klausuren). There are environments for apropriate headers and footers, fields for student’s name, multiple choice questions environments, answer fields for the master copy etc. etc. Might be very useful for teachers (there are alternative packets Examdesign and Exams. Documentation here.

Refman (2.0e) provides report and article-style classes for classy (technical) references and manuals with the main feature of a wide left margin for notes, inspired by manuals of Adobe (but a wide right margin would be useful, too). There is a demo document Changing the layout with LaTeX, the package documentation is here.

Some minor hacks

⚫ Setting section titles and description label the same font like the rest:

\setkomafont{sectioning}{\normalfont}
\setkomafont{descriptionlabel}{\normalfont}

Let every new section begin on a fresh page, this can be done with Titlesec:

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

⚫ No reset of the footnote counter at a new chapter (book and report classes) is possible with Remreset:

\usepackage{remreset}
\makeatletter
\@removefromreset{footnote}{chapter}
\makeatother

⚫ \pagestyle{empty} for multi-page toc:

\makeatletter
\let\myTOC\tableofcontents
\renewcommand{\tableofcontents}{\begingroup\let\ps@plain%
\ps@empty\pagestyle{empty}\myTOC\clearpage\endgroup}
\makeatother

Footnotes

⚫ Prevent footnotes to be broken to the next page (a standard hack):

\interfootnotelinepenalty=10000

⚫ Proposal for custom footnotes:

\renewcommand{\footnoterule}{\rule{0ex}{0ex}}
\setlength{\footnotesep}{2.5ex}
\deffootnote[1.5em]{0em}{1em}{\textsuperscript%
{\thefootnotemark}
\hspace{0.5em}}

⚫ Continuing (”paragraphed”) footnotes could be done with the Fnpara packet, but the same code is also part of the more versatile Footmisc (option “para”). Multiple levels of footnotes could be realized with the Manyfoot packet (part of the Ncctools bundle by Alexander Rozhenko), but both functions and other features like per page numbering are also provided by the comparatively new Bigfoot packet by David Kastrup. So it’s a good idea to choose Bigfoot until you need even a much more fancier functionality provided only by special much complex critical edition packets like Ledmac (a post on that coming up). For Bigfoot cf. (if available) Kastrup’s Benefits, care and feeding of the bigfoot package {TugBoat 29 (2008), 181 ff.}.

A useful collection of footnote related packets (usually treated together with endnotes and marginnotes) could be found here

Sloppy typesetting and hack ressources

When typing a lot of Sanskrit LaTeX usually has to deal with comparatively long text blocks while often the system is not able to locate hyphenation spots within an English or German or other non-Sanskrit environments (no to mention that proper hyphenation patterns for romanized Sanskrit are still a desideratum). For this it’s widespread to turn the spacing tolerance to \sloppy even if to turn to sloppypar somewhere and in the preamble in particular is considered to be inappropriate (c.f. Trettin/Fenn – Obsolete commands and packages, 1.8: Should I use \sloppy? ). But there are compromising solutions around slightly changing several linebreaking and spacing parameters in a balanced way to to loose up the normally very strict specifications of LaTeX like the hack invented by Axel Reichert:

\tolerance 1414
\hbadness 1414
\emergencystretch 1.5em
\hfuzz 0.3pt
\widowpenalty=10000
\vfuzz \hfuzz
\raggedbottom

I’ve found that hack on Texnik.de which is generally a very good ressource for hacks resp. workarounds. Another very useful ressource for solutions like this or for finding the right packet is the Tex-faq by the German usergroup DANTE. I also recommend Anselm Lingnau’s LaTeX Hacks (O’Reilly 2007, ISBN 978-3-89721-477-4, also German) and a title can’t be missed is certainly Frank Mittelbach/Michel Goossens’ LaTeX Companion (2nd ed. Addison-Wesley 2004, ISBN 0-201-36299-6).

Parallel typesetting

The parallel typesetting of different texts esp. of text and its translation is common and in Indology there are the famous editions made by Ernst Waldschmidt (1897-1985) for example. There are different packets for LaTeX to deal with parallel typesetting of text streams, basically that means providing and aligning custom boxes.

Parrun by M. Dominci (1.1) provides two environments fframe and sframe, which makes the usage a little bit complicated I think. It seems unless not invoked with the option multicol the packet is mend for vertical parallel typesetting (not tested).

Parcolumns (1.2) is part of the sophisticated Sauerj bundle by J. Sauer. The packet provides an environment parcolumns in which the columns are generated with the command \colchunk. Even more than 2 columns are possible on the same page, it’s possible to customize colwidth and distance, it’s possible to leave out column fills … works fine.

The ‘classic’ for parallel typesetting is Parallel (beta 4) by M. Eckermann. That one has basically the same basic usage using an environment Parallel with subcommands ParallelLText and ParallelRText while only two columns are possible. The names are displeasing to type and even for auto 50/50 width there must be empty braces invoking the environment (\begin{Parallel}{}{}). A nice feature is that it’s possible to arrange the columns on different (odd/even) pages. C.f. Mittelbach/Goossens, LaTeX Companion {2nd ed., Addison-Wesley 2004}, p. 3.5 seq. (3.5.2: parallel – Two text streams aligned).

Generally there are some conspicuities dealing with footnotes in the tested packets. Parcolumns withdraw footnotes as far as I can see it completely (a workaround is the use of the packet Footnote (1.13) being a part of the fabulous Mdwtools by M. Wooding: the command \makesavenoteenv which makes footnotes emerge even in traping environments like tabular [!] and parcolumns or one can wrap the environment savenotes around). Parallel generates an own layer of footnotes and places them immediately after the environment ends (if demanded or not) but employs an option SeparatedFootnotes for columnwise handling of its footnotes.

Another solution is Ledpar (03b patch 0.4) by P.R. Wilson which belongs to the Ledmac package for critical editions. Ledmac is one of the most versatile LaTeX packets for textediting available and will be the issue in this series in the future. If one uses Ledmac and wants additional parallel typesetting support surely Ledpar is going to be the choice because it’s somewhat guaranteed to be compatible. Ledpar runs nested environments for the columns (\begin{pairs} \begin{Leftside} \end{Leftside} \begin{Rightside} \end{Rightside} \end{pairs}) and I think that could be improved in the future, but there are a lot of options incl. setting on facing pages, line enumeration, verse typesetting etc. which makes the packet interesting for users which are interested in parallel typesetting but have demands going beyond what is provided by the other ones described above.

When typesetting poetry resp. verses an ordinary tabular might be just enough because there are always comparatively short single corresponding lines and not text streams which have to be aligned. Custom linewidth wide cells could be done for example with the tabular* environment like:

\begin{tabular*}{\textwidth}[]{p{0.4\textwidth}p{0.6\textwidth}}
Test test test & Test test test \\
Test test test & Test test test
\end{tabular*}

To use a tabular for typesetting parallel verses is a highly customizeable method.

LaTeX reloaded: Lua(La)TeX is coming up

June 11, 2009 by Daniel Stender · 2 comments · Printer friendly version
Filed under: TeX 

LuaTeX is an ambitious TeX project which combines the TeX engine with the highly versatile scripting language Lua through embedding a Lua interpreter into it. Like its somewhat cognate XeTeX it is a replacement for pdfTeX and produces Pdf documents from the TeX source directly. LuaTeX is natively Unicode capable and makes use of up-to-date OpenType font technology. But the most advantage this TeX engine is getting from embedding Lua. It’s not only working as extension to the typesetting engine but also as extension to the macro language itself. So LuaTeX packages could consist of only one line calling a Lua source code file to the document and it’s also possible to run Lua code directly from the document. In the not so far away future this could mean to have dream LaTeX applications like a postprocessor-free Sanskrit sorting order index module or other very fancy things like this. It’s definitely a development to watch!

The first beta (0.10) was released at the TUG 2007 conference, currently 0.25.4 is included in TeX Live 2008, 0.40 came out recently (BachoTeX 2009 release) and is going to be part of Tex Live 2009, 0.50 and 0.60 are announced still for this year (see the roadmap on the project homepage). It is sponsored by the Oriental TeX project at the Colorado State University (cf. I.S. Hamid: OrientalTeX. A new direction in scholarly complex-script typesetting {TUGboat 28,1 (2007), 11). Developing it means also to make more and more of the TeX internals available to the Lua interpreter. Currently LuaTeX is primarily working as an engine for TeX and TeX formats like ConTeXt, but recently there are the first basic LuaLaTeX packages available.

A set of rudimentary LuaLaTeX packages providedby Manuel Pégourié-Gonnard are now available at his GitHub account (Git is a version control system – you can download them manually but the best way is to use a Git client software). The packets are also to be found on CTAN, directory macros/luatex.The packet luatextra includes low-level macros and an inputenc. And there is also a fontspec module. That’s enough to get a LuaLaTeX document rolling but unfortunately it came out that it is not so easy to get a running LuaLaTeX distribution right now. My Linux (Debian Squeeze/Testing) employs an independent LuaTeX 0.40 (here), which is really up-to-date but comes without compiled LuaLaTeX format files, which are no that easy to hand-make. I don’t know how the situation is going to be on other OSs. Anyway, I’ve been told that TeX Live 2009 is going to include the format files and so that is going to be the next big toy.

Further readings/watchings:

Towards LuaTeX: H. Hagen: Introduction to the LuaTeX project {talk at TUG 2007 conference}; Where does TeX end, Lua start and vice-versa {talk at TUG 2008 conference}; LuaTeX. Howling to the moon {TUGboat 26,2 (2006), 152-57}; The TeX-Lua mix {TUGboat 29,3 (2008), 383-91}; T. Hoekwater: LuaTeX: what has been done, and what will be done {talk at TUG 2008 conference}, LuaTeX {TUGboat 28,3 (2007), 312-13}; OpenType fonts in LuaTeX {TUGboat 29,1 (2008), 34-35}

Towards Lua: R. Ierusalimschy: About Lua {talk TUG 2007}; K. Jung / A. Brown: Beginning Lua programming. Wiley 2007. ISBN 978-0-470-06917-2; Lua 5.1 Reference Manual; bookshelf at the project page